From 28826e145afad86cd729e255cdd36de7fb57eab4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 24 Jan 2019 01:21:40 +0900 Subject: [PATCH] Fix bug --- src/message.ts | 6 ++++++ src/modules/guessing-game/index.ts | 2 +- src/modules/kazutori/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/message.ts b/src/message.ts index c674e42..4b55816 100644 --- a/src/message.ts +++ b/src/message.ts @@ -28,6 +28,12 @@ export default class Message { return this.messageOrNote.text; } + public get extractedText(): string { + return this.text + .replace(new RegExp(`^@${this.ai.account.username}(@.+?)?\s?`, 'i'), '') + .trim(); + } + public get replyId(): string { return this.messageOrNote.replyId; } diff --git a/src/modules/guessing-game/index.ts b/src/modules/guessing-game/index.ts index bc9e089..805290e 100644 --- a/src/modules/guessing-game/index.ts +++ b/src/modules/guessing-game/index.ts @@ -86,7 +86,7 @@ export default class extends Module { return; } - const guess = msg.text.toLowerCase().replace(this.ai.account.username.toLowerCase(), '').match(/[0-9]+/); + const guess = msg.extractedText.match(/[0-9]+/); if (guess == null) { msg.reply(serifs.guessingGame.nan).then(reply => { diff --git a/src/modules/kazutori/index.ts b/src/modules/kazutori/index.ts index 83d2810..ef528b2 100644 --- a/src/modules/kazutori/index.ts +++ b/src/modules/kazutori/index.ts @@ -85,7 +85,7 @@ export default class extends Module { // 既に数字を取っていたら if (game.votes.some(x => x.user.id == msg.userId)) return; - const match = msg.text.match(/[0-9]+/); + const match = msg.extractedText.match(/[0-9]+/); if (match == null) return; const num = parseInt(match[0], 10);