Showing
1 changed file
with
29 additions
and
30 deletions
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | const line = require("@line/bot-sdk"); | 2 | const line = require("@line/bot-sdk"); |
3 | const setFlexMessage = require("./message/setFlexMessage"); | 3 | const setFlexMessage = require("./message/setFlexMessage"); |
4 | const setCarouselMessage = require("./message/setCarouselMessage"); | 4 | const setCarouselMessage = require("./message/setCarouselMessage"); |
5 | -const setKeywordsFlexMessage = require("./message/setKeywordsFlexMessage") | 5 | +const setKeywordsFlexMessage = require("./message/setKeywordsFlexMessage"); |
6 | 6 | ||
7 | // Market Search | 7 | // Market Search |
8 | const { daangnSingleSearch } = require("./search/daangnSearch"); | 8 | const { daangnSingleSearch } = require("./search/daangnSearch"); |
... | @@ -19,7 +19,7 @@ const fs = require("fs"); | ... | @@ -19,7 +19,7 @@ const fs = require("fs"); |
19 | // Cron for Mamul Notification | 19 | // Cron for Mamul Notification |
20 | const schedule = require("node-schedule"); | 20 | const schedule = require("node-schedule"); |
21 | const job = schedule.scheduleJob("0 */1 * * *", () => { | 21 | const job = schedule.scheduleJob("0 */1 * * *", () => { |
22 | - multiCheckMamul(client); | 22 | + multiCheckMamul(client); |
23 | }); | 23 | }); |
24 | 24 | ||
25 | // Database APIs | 25 | // Database APIs |
... | @@ -41,8 +41,7 @@ const config = { | ... | @@ -41,8 +41,7 @@ const config = { |
41 | 41 | ||
42 | // Cron for Mamul Notification | 42 | // Cron for Mamul Notification |
43 | const { multiCheckMamul, checkMamul } = require("./check/checkMamul"); | 43 | const { multiCheckMamul, checkMamul } = require("./check/checkMamul"); |
44 | -const { checkKeywords } = require("./check/checkKeywords") | 44 | +const { checkKeywords } = require("./check/checkKeywords"); |
45 | - | ||
46 | 45 | ||
47 | // Line chat bot client & event | 46 | // Line chat bot client & event |
48 | const client = new line.Client(config); | 47 | const client = new line.Client(config); |
... | @@ -74,25 +73,21 @@ function handleEvent(event) { | ... | @@ -74,25 +73,21 @@ function handleEvent(event) { |
74 | ); | 73 | ); |
75 | } | 74 | } |
76 | } else if (event.postback.data == "checkItems") { | 75 | } else if (event.postback.data == "checkItems") { |
77 | - return Promise.resolve( | 76 | + return Promise.resolve(checkMamul(client, event.source.userId)); |
78 | - checkMamul(client, event.source.userId), | ||
79 | - ); | ||
80 | } else if (event.postback.data == "deleteKeyword") { | 77 | } else if (event.postback.data == "deleteKeyword") { |
81 | - var foundDelete = waitDeleteMamulList.indexOf(event.source.userId); | 78 | + var foundDelete = waitDeleteMamulList.indexOf(event.source.userId); |
82 | - if (foundDelete == -1) { | 79 | + if (foundDelete == -1) { |
83 | - waitDeleteMamulList.push(event.source.userId); | 80 | + waitDeleteMamulList.push(event.source.userId); |
84 | - console.log(`waitDeleteMamulList Changed : ${waitDeleteMamulList}`); | 81 | + console.log(`waitDeleteMamulList Changed : ${waitDeleteMamulList}`); |
85 | - return Promise.resolve( | ||
86 | - client.replyMessage(event.replyToken, { | ||
87 | - type: "text", | ||
88 | - text: "삭제할 매물 키워드를 알려주세요!", | ||
89 | - }) | ||
90 | - ); | ||
91 | - } | ||
92 | - } else if (event.postback.data == "checkKeywords") { | ||
93 | return Promise.resolve( | 82 | return Promise.resolve( |
94 | - checkKeywords(client, event) | 83 | + client.replyMessage(event.replyToken, { |
95 | - ) | 84 | + type: "text", |
85 | + text: "삭제할 매물 키워드를 알려주세요!", | ||
86 | + }) | ||
87 | + ); | ||
88 | + } | ||
89 | + } else if (event.postback.data == "checkKeywords") { | ||
90 | + return Promise.resolve(checkKeywords(client, event)); | ||
96 | } | 91 | } |
97 | } | 92 | } |
98 | return Promise.resolve(null); | 93 | return Promise.resolve(null); |
... | @@ -117,15 +112,19 @@ function handleEvent(event) { | ... | @@ -117,15 +112,19 @@ function handleEvent(event) { |
117 | 112 | ||
118 | var foundDelete = waitDeleteMamulList.indexOf(event.source.userId); | 113 | var foundDelete = waitDeleteMamulList.indexOf(event.source.userId); |
119 | if (foundDelete != -1) { | 114 | if (foundDelete != -1) { |
120 | - waitDeleteMamulList.splice(foundDelete, 1); | 115 | + waitDeleteMamulList.splice(foundDelete, 1); |
121 | - console.log(waitDeleteMamulList[foundDelete]); | 116 | + console.log(waitDeleteMamulList[foundDelete]); |
122 | - return Promise.resolve( | 117 | + return Promise.resolve( |
123 | - db.deleteKeyword(event.source.userId, event.message.text), | 118 | + db.deleteKeyword(event.source.userId, event.message.text), |
124 | - client.replyMessage(event.replyToken, { | 119 | + client |
125 | - type: "text", | 120 | + .replyMessage(event.replyToken, { |
126 | - text: `매물이 삭제되었습니다!\n삭제된 매물: ${event.message.text}`, | 121 | + type: "text", |
127 | - }) | 122 | + text: `매물이 삭제되었습니다!\n삭제된 매물: ${event.message.text}`, |
128 | - ) | 123 | + }) |
124 | + .then(() => { | ||
125 | + checkKeywords(client, event); | ||
126 | + }) | ||
127 | + ); | ||
129 | } | 128 | } |
130 | } | 129 | } |
131 | } | 130 | } | ... | ... |
-
Please register or login to post a comment