From ba0a99b0727ec56001bd26224c92049758560ea1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 30 Aug 2020 10:16:18 +0900 Subject: [PATCH] nanka --- src/modules/core/index.ts | 21 ++++++++++++++++++++- src/utils/or.ts | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/modules/core/index.ts b/src/modules/core/index.ts index 25ec82d..8efc580 100644 --- a/src/modules/core/index.ts +++ b/src/modules/core/index.ts @@ -25,7 +25,8 @@ export default class extends Module { return ( this.transferBegin(msg) || this.transferEnd(msg) || - this.setName(msg) + this.setName(msg) || + this.modules(msg) ); } @@ -107,6 +108,24 @@ export default class extends Module { return true; } + @autobind + private modules(msg: Message): boolean { + if (!msg.text) return false; + if (!msg.or(['modules'])) return false; + + let text = '```\n'; + + for (const m of this.ai.modules) { + text += `${m.name}\n`; + } + + text += '```'; + + msg.reply(text); + + return true; + } + @autobind private async contextHook(msg: Message, data: any) { if (msg.text == null) return; diff --git a/src/utils/or.ts b/src/utils/or.ts index e03f87b..32fabbf 100644 --- a/src/utils/or.ts +++ b/src/utils/or.ts @@ -14,6 +14,11 @@ export default function(text: string, words: (string | RegExp)[]): boolean { function denoise(text: string): string { text = text.trim(); + if (text.startsWith('@')) { + text = text.replace(/^@[a-zA-Z0-1\-_]+/, ''); + text = text.trim(); + } + function fn() { text = text.replace(/[!!]+$/, ''); text = text.replace(/っ+$/, '');