index.js
923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const request = require("request");
const callRequest = require("../bus/request")
let userState = {};
async function makeMessage(replyToken, message) {
if (message === '버스') {
return await callRequest();
} else {
return "명령어를 다시 입력하세요."
}
}
function recvMessage(replyToken, messsage) {
request.post(
{
url: process.env.LINE_TARGET_URL,
headers: {
'Authorization': `Bearer ${process.env.CHATBOT_TOKEN}`
},
json: {
"replyToken": replyToken,
"messages": [
{
"type": "text",
"text": messsage
}
]
}
}, (error, response, body) => {
// console.log(body)
}
);
};
module.exports = {
recvMessage,
makeMessage,
}