This repository has been archived on 2024-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
line-cost-js/app.js

46 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2021-04-27 00:42:22 +00:00
// 背景執行 forever start -a -l line-cost-js.log app.js
// 重新背景執行 forever restart -a -l line-cost-js.log app.js
// npm start
// npm run dev
// Debug nodemon --inspect=192.168.168.15:9229 app.js
2021-12-26 07:15:28 +00:00
// git clone ssh://JianMiau@192.168.168.15:1922/volume1/github/line-cost-js
2021-04-27 00:42:22 +00:00
const dateFormat = require('dateformat');
require('dotenv').config()
// require("./plug/DateFormat");
// 引用linebot SDK
var linebot = require('linebot');
const fs = require('fs');
//讀取憑證及金鑰
2021-12-26 07:15:28 +00:00
const prikey = fs.readFileSync('../certificate/privkey.pem', 'utf8');
const cert = fs.readFileSync('../certificate/cert.pem', 'utf8');
const cafile = fs.readFileSync('../certificate/chain.pem', 'utf-8');
2021-04-27 00:42:22 +00:00
//建立憑證及金鑰
const credentials = {
key: prikey,
cert: cert,
ca: cafile
};
// 用於辨識Line Channel的資訊
var bot = linebot({
channelId: process.env.toZhuHantoJianMiau,
channelSecret: process.env.ZhuHanchannelSecret,
channelAccessToken: process.env.ZhuHanchannelAccessToken
});
var JianMiaubot = linebot({
channelId: process.env.toJianMiau,
channelSecret: process.env.channelSecret,
channelAccessToken: process.env.channelAccessToken
});
const LineBotAPI = require('./LineBotClass');
// Bot所監聽的webhook路徑與port
const path = process.env.URLPATH || "/";
const port = process.env.PORT || 3001;
2021-12-26 07:15:28 +00:00
new LineBotAPI(path, port, credentials, bot, JianMiaubot);