From 5b59823edd35ebbd22edc274976f322190cf76f6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 2 Sep 2018 10:44:09 +0900 Subject: [PATCH] Improve AI --- src/modules/core/index.ts | 8 +++++++- src/serifs.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/core/index.ts b/src/modules/core/index.ts index aa224fa..c826ba0 100644 --- a/src/modules/core/index.ts +++ b/src/modules/core/index.ts @@ -115,6 +115,8 @@ export default class CoreModule implements IModule { } private greet = (msg: MessageLike): boolean => { + if (msg.text == null) return false; + const incLove = () => { //#region 1日に1回だけ親愛度を上げる const today = getDate(); @@ -130,6 +132,10 @@ export default class CoreModule implements IModule { //#endregion }; + const tension = (msg.text.match(/[!!]{2,}/g) || []) + .sort((a, b) => a.length < b.length ? 1 : -1)[0] + .substr(1); + if (includes(msg.text, ['こんにちは', 'こんにちわ'])) { msg.reply(serifs.core.hello(msg.friend.name)); incLove(); @@ -143,7 +149,7 @@ export default class CoreModule implements IModule { } if (includes(msg.text, ['おは', 'お早う'])) { - msg.reply(serifs.core.goodMorning(msg.friend.name)); + msg.reply(serifs.core.goodMorning(tension, msg.friend.name)); incLove(); return true; } diff --git a/src/serifs.ts b/src/serifs.ts index 635acca..28d5af5 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -10,7 +10,7 @@ export default { helloNight: name => name ? `こんばんは、${name}♪` : `こんばんは♪`, - goodMorning: name => name ? `おはようございます、${name}!` : 'おはようございます!', + goodMorning: (tension, name) => name ? `おはようございます、${name}!${tension}` : `おはようございます!${tension}`, goodNight: name => name ? `おやすみなさい、${name}!` : 'おやすみなさい!',