This commit is contained in:
syuilo 2019-01-24 01:21:40 +09:00
parent 7206dc0dc6
commit 28826e145a
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
3 changed files with 8 additions and 2 deletions

View file

@ -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;
}

View file

@ -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 => {

View file

@ -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);