윤준석

ADD: checkKeywords and reply flexMessage to LINE Client

1 +const setKeywordsFlexMessage = require("../message/setKeywordsFlexMessage")
2 +
3 +const db = require("../../apis/database");
4 +
5 +const checkKeywords = (client, event) => {
6 + db.getKeywordsByUserId(event.source.userId).then((keywords) => {
7 + flexMessage = setKeywordsFlexMessage(keywords);
8 + client.replyMessage(event.replyToken, flexMessage)
9 + })
10 +};
11 +
12 +module.exports = { checkKeywords };
...\ No newline at end of file ...\ No newline at end of file
...@@ -40,7 +40,8 @@ const config = { ...@@ -40,7 +40,8 @@ const config = {
40 }; 40 };
41 41
42 // Cron for Mamul Notification 42 // Cron for Mamul Notification
43 -const { multiCheckMamul, checkMamul } = require("./checkMamul/checkMamul"); 43 +const { multiCheckMamul, checkMamul } = require("./check/checkMamul");
44 +const { checkKeywords } = require("./check/checkKeywords")
44 45
45 46
46 // Line chat bot client & event 47 // Line chat bot client & event
...@@ -90,7 +91,7 @@ function handleEvent(event) { ...@@ -90,7 +91,7 @@ function handleEvent(event) {
90 } 91 }
91 } else if (event.postback.data == "checkKeywords") { 92 } else if (event.postback.data == "checkKeywords") {
92 return Promise.resolve( 93 return Promise.resolve(
93 - console.log("키워드 확인") 94 + checkKeywords(client, event)
94 ) 95 )
95 } 96 }
96 } 97 }
......
1 function setKeywordsFlexMessage(keywords) { 1 function setKeywordsFlexMessage(keywords) {
2 let flexMessage = { 2 let flexMessage = {
3 type: "bubble", 3 type: "bubble",
4 - hero: {},
5 body: { 4 body: {
6 type: "box", 5 type: "box",
7 layout: "vertical", 6 layout: "vertical",
...@@ -32,11 +31,6 @@ function setKeywordsFlexMessage(keywords) { ...@@ -32,11 +31,6 @@ function setKeywordsFlexMessage(keywords) {
32 } 31 }
33 ] 32 ]
34 }, 33 },
35 - styles: {
36 - footer: {
37 - separator: "true"
38 - }
39 - }
40 }; 34 };
41 35
42 for (let i = 0; i < keywords.length; i++) { 36 for (let i = 0; i < keywords.length; i++) {
...@@ -44,7 +38,11 @@ function setKeywordsFlexMessage(keywords) { ...@@ -44,7 +38,11 @@ function setKeywordsFlexMessage(keywords) {
44 flexMessage.body.contents[3].contents.push(textbox); 38 flexMessage.body.contents[3].contents.push(textbox);
45 } 39 }
46 40
47 - return flexMessage 41 + return {
42 + type: "flex",
43 + altText: "키워드 조회 오류",
44 + contents: flexMessage
45 + }
48 } 46 }
49 47
50 function createKeywordTextBox(keyword) { 48 function createKeywordTextBox(keyword) {
......