From 79d240ed2ef9ebcc2c99210ede3a405846affbeb Mon Sep 17 00:00:00 2001 From: JianMiau Date: Tue, 13 Apr 2021 12:03:51 +0800 Subject: [PATCH] [mod] DB Connect Log --- MessageClass.js | 10 ++++++++++ Tools_MYSQLDBClass.js | 2 +- app.js | 8 +++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/MessageClass.js b/MessageClass.js index b3e8793..2f54fd4 100644 --- a/MessageClass.js +++ b/MessageClass.js @@ -84,6 +84,16 @@ class MessageClass { if (profile) { displayName = profile.displayName; } + + //ToJianMiau------------------------------------------------------------------------------------------------------ + if (userId !== process.env.toZhuHantoJianMiau) { + let ToJM_message = `已接收訊息:`; + ToJM_message += `\ndisplayName: ${displayName}`; + ToJM_message += `\nuserId: ${userId}`; + ToJM_message += `\nmessage: ${replyMsg}`; + let res_toJianMiau = this.JianMiaubot.push(process.env.toJianMiau, ToJM_message); + } + // JianMiau特別功能 if (userId === process.env.toZhuHantoJianMiau || userId === process.env.toZhuHantoZhuHan) { /** 訊息 */ diff --git a/Tools_MYSQLDBClass.js b/Tools_MYSQLDBClass.js index 5c55614..4e03909 100644 --- a/Tools_MYSQLDBClass.js +++ b/Tools_MYSQLDBClass.js @@ -18,7 +18,7 @@ class Tools_MYSQLDBClass { throw err; } else { - console.log("Connection established."); + console.log("jianmiau.tk Connect."); } }); } diff --git a/app.js b/app.js index 865f159..0cb3738 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,8 @@ -// 背景執行 forever start -w app.js +// 背景執行 forever start -w -a -l line-cost-js.log app.js // 監聽檔案變化 nodemon "npm start" // Debug node --inspect=192.168.168.15:9229 app.js +const dateFormat = require('dateformat'); require('dotenv').config() // require("./plug/DateFormat"); // 引用linebot SDK @@ -64,7 +65,8 @@ bot.on('event', function (event) { } }); bot.listen(path, port, credentials, function () { - console.log(`listening on ${port}`); - console.log('[BOT已準備就緒]'); + let datetime = dateFormat(new Date(), "yyyy-mm-dd HH:MM:ss"); + console.log(`${datetime} listening on ${port}`); + console.log(`${datetime} [BOT已準備就緒]`); // Tools_MYSQLDB.readData(); }); \ No newline at end of file