line.js
1.73 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.post('/webhook', function (request, response) {
var eventObj = request.body.events[0];
var source = eventObj.source;
var message = eventObj.message;
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', request.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
if(message.type == "text"){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, 'welcome sooinzzang.com');
}
/*
if(message.type = "text" && message.text.indexOf("@momo") != -1){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, actionBasic.getBasicExpress());
}
else if(message.type = "text" && /^@.+/g.test(message.text)){
var cmd = message.text.split('@')[1];
console.log('[command]', cmd);
if(typeof cmd !== "undefined" && cmd != ""){
if(cmd == "h" || cmd == "help"){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, actionHelp.getHelpExpress());
}
else if(/^r\[.+\]/g.test(cmd)){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, actionEnjoy.getRandomExpress(cmd));
}
else if(cmd == "food" || cmd == "밥집"){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, actionEnjoy.getFoodExpress());
}
else if(cmd == "contact" || cmd == "ct"){
reply.send(config.CHANNEL_ACCESS_TOKEN, eventObj.replyToken, actionHelp.getContactExpress());
}
}
}
*/
response.sendStatus(200);
});