mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
parent
9e5b1ba28e
commit
8abde7b7d0
@ -24,21 +24,11 @@ export interface ReturnDataType {
|
||||
|
||||
// Normalizes a mixed type (CQCode/a single segment/segment array) into a segment array.
|
||||
export function normalize(message: OB11MessageMixType, autoEscape = false): OB11MessageData[] {
|
||||
if (typeof message === 'string') {
|
||||
if (autoEscape) {
|
||||
return [{ type: OB11MessageDataType.text, data: { text: message } }];
|
||||
} else {
|
||||
try {
|
||||
return decodeCQCode(message);
|
||||
} catch {
|
||||
return [{ type: OB11MessageDataType.text, data: { text: message } }];
|
||||
}
|
||||
}
|
||||
} else if (Array.isArray(message)) {
|
||||
return message;
|
||||
} else {
|
||||
return [message];
|
||||
}
|
||||
return typeof message === 'string' ? (
|
||||
autoEscape ?
|
||||
[{ type: OB11MessageDataType.text, data: { text: message } }] :
|
||||
decodeCQCode(message)
|
||||
) : Array.isArray(message) ? message : [message];
|
||||
}
|
||||
|
||||
export { createSendElements };
|
||||
|
Loading…
Reference in New Issue
Block a user