mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix cqcode format
This commit is contained in:
parent
c906bcf7ea
commit
7bdb84b11b
@ -46,15 +46,22 @@ export function decodeCQCode(source: string): OB11MessageData[] {
|
||||
|
||||
|
||||
export function encodeCQCode(data: OB11MessageData) {
|
||||
const CQCodeEscape = (text: string) => {
|
||||
return text.replace(/\[/g, '[')
|
||||
const CQCodeEscapeText = (text: string) => {
|
||||
return text.replace(/\&/g, '&')
|
||||
.replace(/\[/g, '[')
|
||||
.replace(/\]/g, ']')
|
||||
|
||||
};
|
||||
|
||||
const CQCodeEscape = (text: string) => {
|
||||
return text.replace(/\&/g, '&')
|
||||
.replace(/\[/g, '[')
|
||||
.replace(/\]/g, ']')
|
||||
.replace(/\&/g, '&')
|
||||
.replace(/,/g, ',');
|
||||
};
|
||||
|
||||
if (data.type === 'text') {
|
||||
return CQCodeEscape(data.data.text);
|
||||
return CQCodeEscapeText(data.data.text);
|
||||
}
|
||||
|
||||
let result = '[CQ:' + data.type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user