This commit is contained in:
n1lsqn 2023-11-13 15:00:16 +09:00
parent f72f3183af
commit b72dc81d6c

View file

@ -62,18 +62,38 @@ export default class extends Module {
@autobind
private setName(msg: Message): boolean {
if (!msg.text) return false;
if (!msg.text.includes('って呼んで')) return false;
if (msg.text.startsWith('って呼んで')) return false;
if (!msg.text) {
console.error("Message text is empty or undefined.");
return false;
}
const name = msg.text.match(/^(.+?)って呼んで/)![1];
if (!msg.text.includes('って呼んで')) {
console.error("Message text does not include 'って呼んで'.");
return false;
}
if (msg.text.startsWith('って呼んで')) {
console.error("Message text starts with 'って呼んで'.");
return false;
}
const matchResult = msg.text.match(/^(.+?)って呼んで/);
if (!matchResult) {
console.error("Name not found in the message text.");
return false;
}
const name = matchResult[1];
if (name.length > 10) {
console.error("Name length exceeds 10 characters.");
msg.reply(serifs.core.tooLong);
return true;
}
if (safeForInterpolate(name)) {
console.error("Invalid name.");
msg.reply(serifs.core.invalidName);
return true;
}