diff --git a/src/onebot/helper/cqcode.ts b/src/onebot/helper/cqcode.ts index b0be9e0c8..247f94d68 100644 --- a/src/onebot/helper/cqcode.ts +++ b/src/onebot/helper/cqcode.ts @@ -1,6 +1,6 @@ import { OB11MessageData } from '../types'; -const pattern = /\[CQ:(\w+)((,\w+=[^,\]]*)*)\]/; +const pattern = /\[CQ:(\w+)((,\w+=[^,\]]*)*)]/; function unescape(source: string) { return String(source) @@ -49,14 +49,14 @@ export function encodeCQCode(data: OB11MessageData) { const CQCodeEscapeText = (text: string) => { return text.replace(/&/g, '&') .replace(/\[/g, '[') - .replace(/\]/g, ']'); + .replace(/]/g, ']'); }; const CQCodeEscape = (text: string) => { return text.replace(/&/g, '&') .replace(/\[/g, '[') - .replace(/\]/g, ']') + .replace(/]/g, ']') .replace(/,/g, ','); }; @@ -66,7 +66,10 @@ export function encodeCQCode(data: OB11MessageData) { let result = '[CQ:' + data.type; for (const name in data.data) { - const value = data.data[name]; + const value = + // eslint-disable-next-line + // @ts-ignore + data.data[name]; if (value === undefined) { continue; } @@ -79,4 +82,4 @@ export function encodeCQCode(data: OB11MessageData) { } result += ']'; return result; -} \ No newline at end of file +}