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-26 01:39:42 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
197c41e7af7eaa60f759b5bb42a4f4ae97a88b47
197c41e7
1 parent
f02c82c5
ADD: checkItems function with checkMamul and push message to client
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
server/chatbot/checkMamul/checkMamul.js
server/chatbot/index.js
server/chatbot/checkMamul/checkMamul.js
View file @
197c41e
...
...
@@ -10,7 +10,7 @@ const db = require("../../apis/database");
// database.getAllUsers = async function()
// database.getAllKeywords = async function()
const
c
heckMamul
=
(
client
)
=>
{
const
multiC
heckMamul
=
(
client
)
=>
{
db
.
getAllKeywords
().
then
((
keywords
)
=>
{
for
(
let
i
=
0
,
pending
=
Promise
.
resolve
();
i
<
keywords
.
length
;
i
++
)
{
pending
=
db
.
getUsersByKeyword
(
keywords
[
i
]).
then
((
userIds
)
=>
{
...
...
@@ -22,4 +22,14 @@ const checkMamul = (client) => {
});
};
module
.
exports
=
{
checkMamul
};
const
checkMamul
=
(
client
,
userId
)
=>
{
db
.
getKeywordsByUserId
(
userId
).
then
((
keywords
)
=>
{
for
(
let
i
=
0
,
pending
=
Promise
.
resolve
();
i
<
keywords
.
length
;
i
++
)
{
pending
=
marketMultiSearch
(
keywords
[
i
]).
then
((
res
)
=>
{
client
.
pushMessage
(
userId
,
setCarouselMessage
(
res
));
});
};
});
};
module
.
exports
=
{
multiCheckMamul
,
checkMamul
};
...
...
server/chatbot/index.js
View file @
197c41e
...
...
@@ -18,7 +18,7 @@ const fs = require("fs");
// Cron for Mamul Notification
const
schedule
=
require
(
"node-schedule"
);
const
job
=
schedule
.
scheduleJob
(
"0 */1 * * *"
,
()
=>
{
c
heckMamul
(
client
);
multiC
heckMamul
(
client
);
});
// Database APIs
...
...
@@ -39,7 +39,8 @@ const config = {
};
// Cron for Mamul Notification
const
{
checkMamul
}
=
require
(
"./checkMamul/checkMamul"
);
const
{
multiCheckMamul
,
checkMamul
}
=
require
(
"./checkMamul/checkMamul"
);
// Line chat bot client & event
const
client
=
new
line
.
Client
(
config
);
...
...
@@ -71,18 +72,7 @@ function handleEvent(event) {
}
}
else
if
(
event
.
postback
.
data
==
"checkItems"
)
{
return
Promise
.
resolve
(
client
.
replyMessage
(
event
.
replyToken
,
{
type
:
"flex"
,
altText
:
"등록된 매물"
,
contents
:
setFlexMessage
(
"daangn"
,
"RTX 3080"
,
"1000000"
,
"https://dnvefa72aowie.cloudfront.net/origin/article/202205/94cdd237258671d5806a70f64ab2b3c7dcd790da0384b394ef5809fe10c08ced.webp?q=95&s=1440x1440&t=inside"
,
"https://www.daangn.com/articles/403755360"
,
"채굴X, 흡연X, 반려동물X 입니다.\n직거래 희망하며, 쿨거래시 네고 1만원 가능합니다."
),
})
checkMamul
(
client
,
event
.
source
.
userId
),
);
}
}
...
...
Please
register
or
login
to post a comment