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-25 21:14:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d1e4cb6c6331ed0d1fd81b7ac9397efdcb9544c8
d1e4cb6c
1 parent
81c93c38
ADD: cron message + clean-up unessential message
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
6 deletions
server/app.js
server/chatbot/checkMamul/checkMamul.js
server/chatbot/index.js
server/package-lock.json
server/package.json
server/app.js
View file @
d1e4cb6
...
...
@@ -10,12 +10,6 @@ sequelize
.
sync
({
force
:
false
})
.
then
(()
=>
{
console
.
log
(
"database connection complete"
);
database
.
addKeyword
(
"rtx3060"
,
"junseok"
);
database
.
getKeywordsByUserId
(
"junseok"
);
database
.
deleteKeyword
(
"phobyjun"
,
"rtx3080"
);
database
.
getAllUsers
();
database
.
getUsersByKeyword
(
"rtx3060"
);
database
.
getAllKeywords
();
})
.
catch
((
err
)
=>
{
console
.
log
(
"database connection failed"
);
...
...
server/chatbot/checkMamul/checkMamul.js
0 → 100644
View file @
d1e4cb6
const
{
marketMultiSearch
}
=
require
(
"../search/marketSearch"
);
const
setCarouselMessage
=
require
(
"../message/setCarouselMessage"
);
// Database APIs
const
db
=
require
(
"../../apis/database"
);
// API List
// database.addKeyword = async function(keyword, userId)
// database.deleteKeyword = async function(userId, keyword)
// database.getKeywordsByUserId = async function(userId)
// database.getUsersByKeyword = async function(keyword)
// database.getAllUsers = async function()
// database.getAllKeywords = async function()
const
checkMamul
=
(
client
)
=>
{
db
.
getAllKeywords
().
then
((
keywords
)
=>
{
for
(
let
i
=
0
,
pending
=
Promise
.
resolve
();
i
<
keywords
.
length
;
i
++
)
{
pending
=
db
.
getUsersByKeyword
(
keywords
[
i
]).
then
((
userIds
)
=>
{
marketMultiSearch
(
keywords
[
i
]).
then
((
res
)
=>
{
client
.
multicast
(
userIds
,
[
setCarouselMessage
(
res
)]);
});
});
}
});
};
module
.
exports
=
{
checkMamul
};
server/chatbot/index.js
View file @
d1e4cb6
...
...
@@ -15,6 +15,12 @@ const { marketMultiSearch } = require("./search/marketSearch");
// File search - Will be deleted (Unused)
const
fs
=
require
(
"fs"
);
// Cron for Mamul Notification
const
schedule
=
require
(
"node-schedule"
);
const
job
=
schedule
.
scheduleJob
(
"0 */1 * * *"
,
()
=>
{
checkMamul
(
client
);
});
// Database APIs
const
db
=
require
(
"../apis/database"
);
// API List
...
...
@@ -32,6 +38,10 @@ const config = {
channelSecret
:
process
.
env
.
channelSecret
,
};
// Cron for Mamul Notification
const
{
checkMamul
}
=
require
(
"./checkMamul/checkMamul"
);
// Line chat bot client & event
const
client
=
new
line
.
Client
(
config
);
let
waitNewMamulList
=
[];
// 매물 키워드 입력 기다리는 목록
...
...
server/package-lock.json
View file @
d1e4cb6
This diff is collapsed. Click to expand it.
server/package.json
View file @
d1e4cb6
...
...
@@ -20,6 +20,7 @@
"dotenv"
:
"^16.0.1"
,
"express"
:
"^4.18.1"
,
"mysql2"
:
"^2.3.3"
,
"node-schedule"
:
"^2.1.0"
,
"nodemon"
:
"^2.0.16"
,
"sequelize"
:
"^6.20.0"
}
...
...
Please
register
or
login
to post a comment