mirror of
https://github.com/syuilo/ai.git
synced 2025-03-25 21:12:56 +00:00
fix
This commit is contained in:
parent
f72f3183af
commit
b72dc81d6c
1 changed files with 47 additions and 27 deletions
|
@ -60,39 +60,59 @@ export default class extends Module {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private setName(msg: Message): boolean {
|
private setName(msg: Message): boolean {
|
||||||
if (!msg.text) return false;
|
if (!msg.text) {
|
||||||
if (!msg.text.includes('って呼んで')) return false;
|
console.error("Message text is empty or undefined.");
|
||||||
if (msg.text.startsWith('って呼んで')) return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const name = msg.text.match(/^(.+?)って呼んで/)![1];
|
if (!msg.text.includes('って呼んで')) {
|
||||||
|
console.error("Message text does not include 'って呼んで'.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (name.length > 10) {
|
if (msg.text.startsWith('って呼んで')) {
|
||||||
msg.reply(serifs.core.tooLong);
|
console.error("Message text starts with 'って呼んで'.");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safeForInterpolate(name)) {
|
const matchResult = msg.text.match(/^(.+?)って呼んで/);
|
||||||
msg.reply(serifs.core.invalidName);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const withSan = titles.some(t => name.endsWith(t));
|
if (!matchResult) {
|
||||||
|
console.error("Name not found in the message text.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (withSan) {
|
const name = matchResult[1];
|
||||||
msg.friend.updateName(name);
|
|
||||||
msg.reply(serifs.core.setNameOk(name));
|
|
||||||
} else {
|
|
||||||
msg.reply(serifs.core.san).then(reply => {
|
|
||||||
this.subscribeReply(msg.userId, reply.id, {
|
|
||||||
name: name
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const withSan = titles.some(t => name.endsWith(t));
|
||||||
|
|
||||||
|
if (withSan) {
|
||||||
|
msg.friend.updateName(name);
|
||||||
|
msg.reply(serifs.core.setNameOk(name));
|
||||||
|
} else {
|
||||||
|
msg.reply(serifs.core.san).then(reply => {
|
||||||
|
this.subscribeReply(msg.userId, reply.id, {
|
||||||
|
name: name
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private modules(msg: Message): boolean {
|
private modules(msg: Message): boolean {
|
||||||
|
|
Loading…
Reference in a new issue