Toggle navigation
Toggle navigation
This project
Loading...
Sign in
윤준석
/
mamuri-bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
유명현
2022-05-30 18:49:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
33be809af727aef660fad4862925f82537557898
33be809a
1 parent
01ae79f9
EDIT: Carousel support multi mamul (up to 12)
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
12 deletions
server/chatbot/check/checkMamul.js
server/chatbot/message/combineCarouselMessage.js
server/chatbot/message/setCarouselMessage.js
server/chatbot/check/checkMamul.js
View file @
33be809
const
{
marketMultiSearch
}
=
require
(
"../search/marketSearch"
);
const
setCarouselMessage
=
require
(
"../message/setCarouselMessage"
);
const
combineCarouselMessage
=
require
(
"../message/combineCarouselMessage"
);
// Database APIs
const
db
=
require
(
"../../apis/database"
);
// API List
...
...
@@ -18,7 +20,7 @@ const multiCheckMamul = (client) => {
client
.
multicast
(
userIds
,
[
{
type
:
"text"
,
text
:
`유저님의
${
keywords
[
i
]}
매물 알림이 도착했어요!`
,
text
:
`유저님의 매물 알림이 도착했어요!`
,
},
setCarouselMessage
(
res
,
keywords
[
i
]),
]);
...
...
@@ -29,19 +31,35 @@ const multiCheckMamul = (client) => {
};
const
checkMamul
=
(
client
,
userId
)
=>
{
let
combinedCarousel
=
{
type
:
"flex"
,
altText
:
`유저님의 매물 알림이 도착했어요!`
,
contents
:
{
type
:
"carousel"
,
contents
:
[],
},
};
let
carousel
=
{};
db
.
getKeywordsByUserId
(
userId
).
then
((
keywords
)
=>
{
for
(
let
i
=
0
,
pending
=
Promise
.
resolve
();
i
<
keywords
.
length
;
i
++
)
{
if
(
i
%
4
==
0
)
{
combinedCarousel
[
"contents"
][
"contents"
]
=
[];
}
pending
=
marketMultiSearch
(
keywords
[
i
]).
then
((
res
)
=>
{
client
.
multicast
(
[
userId
],
[
{
type
:
"text"
,
text
:
`유저님의
${
keywords
[
i
]}
매물 알림이 도착했어요!`
,
},
setCarouselMessage
(
res
,
keywords
[
i
]),
]
);
carousel
=
setCarouselMessage
(
res
,
keywords
[
i
]);
combineCarouselMessage
(
combinedCarousel
,
carousel
);
if
(
i
%
4
==
3
||
i
===
keywords
.
length
-
1
)
{
client
.
multicast
(
[
userId
],
[
{
type
:
"text"
,
text
:
`유저님의 매물 알림이 도착했어요!`
,
},
combinedCarousel
,
]
);
}
});
}
});
...
...
server/chatbot/message/combineCarouselMessage.js
0 → 100644
View file @
33be809
const
combineCarouselMessage
=
(
mergedCarousel
,
carousel
)
=>
{
for
(
let
i
=
0
;
i
<
carousel
[
"contents"
][
"contents"
].
length
;
i
++
)
{
mergedCarousel
[
"contents"
][
"contents"
].
push
(
carousel
[
"contents"
][
"contents"
][
i
]
);
}
return
mergedCarousel
;
};
module
.
exports
=
combineCarouselMessage
;
server/chatbot/message/setCarouselMessage.js
View file @
33be809
...
...
@@ -124,7 +124,7 @@ function setCarouselMessage(mamuls, keyword) {
};
let
carouselMessage
=
{
type
:
"flex"
,
altText
:
`유저님의
${
keyword
}
매물
알림
!`
,
altText
:
`유저님의
${
keyword
}
매물
이 왔어요
!`
,
contents
:
{
type
:
"carousel"
,
contents
:
flexMessages
,
...
...
Please
register
or
login
to post a comment