diff --git a/src/modules/core/index.ts b/src/modules/core/index.ts index 68fb47a..3c00c14 100644 --- a/src/modules/core/index.ts +++ b/src/modules/core/index.ts @@ -66,16 +66,22 @@ export default class extends Module { if (!msg.text.includes('って呼んで')) return false; if (msg.text.startsWith('って呼んで')) return false; - const name = msg.text.match(/^(.+?)って呼んで/)![1]; + const matchResult = msg.text.match(/^(.+?)って呼んで/)![1]; - if (name.length > 10) { - msg.reply(serifs.core.tooLong); - return true; - } + if (matchResult !== null) { + const name = matchResult[1]; - if (!safeForInterpolate(name)) { - msg.reply(serifs.core.invalidName); - return true; + if (name.length > 10) { + msg.reply(serifs.core.tooLong); + return true; + } + + if (!safeForInterpolate(name)) { + msg.reply(serifs.core.invalidName); + return true; + } + } else { + console.log("setName: 一致するものが見つかりませんでした") } const withSan = titles.some(t => name.endsWith(t));