Skip to content

Commit

Permalink
更新kmd转义
Browse files Browse the repository at this point in the history
  • Loading branch information
modcrafts committed Jul 4, 2024
1 parent b68dc34 commit 3226cbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/services/commander/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Bot } from '../../bot';
import { Next } from '../middleware';
import { CardTemplate } from './Template';
import Schema from 'schemastery';
import { escapeKmdText } from '../../utils';

export { CommandInstance };

Expand Down Expand Up @@ -127,7 +128,7 @@ export class Commander {
return;
}

return `没有找到指令 ${argv.command}`;
return `没有找到指令 ${escapeKmdText(argv.command ?? '')}`;
},
);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ export async function allPagesRequest<DataType, Input extends Omit<Pagination, '
}

const kmarkdownChars = /([*~\[\]()>\-\\:`])/g;
export function escapeKmdText(text: string): string {
return text.replace(kmarkdownChars, '\\$1');
export function escapeKmdText(text: string = ''): string {
return text?.replace(kmarkdownChars, '\\$1');
}

0 comments on commit 3226cbf

Please sign in to comment.