-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
27 lines (23 loc) · 893 Bytes
/
app.js
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
const linebot = require('linebot');
const followController = require('./controllers/follow.controller');
const messageController = require('./controllers/message.controller');
const postbackController = require('./controllers/postback.controller');
const etf = require('./services/etf');
const mongodb = require('./database/mongodb');
require('dotenv').config();
const bot = linebot({
channelId: process.env.channelId,
channelSecret: process.env.channelSecret,
channelAccessToken: process.env.channelAccessToken,
});
etf.loadEtfInfo();
setInterval(() => etf.loadEtfInfo(), 5 * 60000);
(async () => {
await mongodb.connect();
})();
bot.on('follow', followController);
bot.on('message', messageController);
bot.on('postback', postbackController);
bot.listen('/webhook', process.env.PORT || 3000, () => {
console.info(`LineBot is running in ${process.env.PORT || 3000} PORT.`);
});