mirror of
https://github.com/syuilo/ai.git
synced 2024-11-09 23:48:01 +00:00
refactor
This commit is contained in:
parent
b8e71b47e3
commit
e29ca5a12c
|
@ -2,11 +2,10 @@ import autobind from 'autobind-decorator';
|
|||
import Module from '../../module';
|
||||
import Message from '../../message';
|
||||
import serifs from '../../serifs';
|
||||
import { safeForInterpolate } from '../../utils/safe-for-interpolate';
|
||||
|
||||
const titles = ['さん', 'くん', '君', 'ちゃん', '様', '先生'];
|
||||
|
||||
const invalidChars = ['@', '#', '*', ':', '(', '[', ' ', ' '];
|
||||
|
||||
export default class extends Module {
|
||||
public readonly name = 'core';
|
||||
|
||||
|
@ -87,7 +86,7 @@ export default class extends Module {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (invalidChars.some(c => name.includes(c))) {
|
||||
if (!safeForInterpolate(name)) {
|
||||
msg.reply(serifs.core.invalidName);
|
||||
return true;
|
||||
}
|
||||
|
|
16
src/utils/safe-for-interpolate.ts
Normal file
16
src/utils/safe-for-interpolate.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
const invalidChars = [
|
||||
'@',
|
||||
'#',
|
||||
'*',
|
||||
':',
|
||||
'(',
|
||||
')',
|
||||
'[',
|
||||
']',
|
||||
' ',
|
||||
' ',
|
||||
];
|
||||
|
||||
export function safeForInterpolate(text: string): boolean {
|
||||
return !invalidChars.some(c => text.includes(c));
|
||||
}
|
Loading…
Reference in a new issue