This commit is contained in:
syuilo 2020-09-02 20:46:54 +09:00
parent b8e71b47e3
commit e29ca5a12c
2 changed files with 18 additions and 3 deletions

View file

@ -2,11 +2,10 @@ import autobind from 'autobind-decorator';
import Module from '../../module'; import Module from '../../module';
import Message from '../../message'; import Message from '../../message';
import serifs from '../../serifs'; import serifs from '../../serifs';
import { safeForInterpolate } from '../../utils/safe-for-interpolate';
const titles = ['さん', 'くん', '君', 'ちゃん', '様', '先生']; const titles = ['さん', 'くん', '君', 'ちゃん', '様', '先生'];
const invalidChars = ['@', '#', '*', ':', '(', '[', ' ', ' '];
export default class extends Module { export default class extends Module {
public readonly name = 'core'; public readonly name = 'core';
@ -87,7 +86,7 @@ export default class extends Module {
return true; return true;
} }
if (invalidChars.some(c => name.includes(c))) { if (!safeForInterpolate(name)) {
msg.reply(serifs.core.invalidName); msg.reply(serifs.core.invalidName);
return true; return true;
} }

View file

@ -0,0 +1,16 @@
const invalidChars = [
'@',
'#',
'*',
':',
'(',
')',
'[',
']',
' ',
' ',
];
export function safeForInterpolate(text: string): boolean {
return !invalidChars.some(c => text.includes(c));
}