mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 08:10:25 +00:00
Refactor type handling and improve message parsing
Updated several actions to use more precise type casting and type guards, improving type safety and clarity. Enhanced message parsing logic for forward messages and group/friend message history. Standardized return schemas and error handling for avatar and group portrait actions.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { OB11MessageMixType } from '@/napcat-onebot/types';
|
||||
import { ContextMode, normalize, ReturnDataType, SendMsgBase, SendMsgPayload } from '@/napcat-onebot/action/msg/SendMsg';
|
||||
import { ActionName } from '@/napcat-onebot/action/router';
|
||||
|
||||
// 未验证
|
||||
type GoCQHTTPSendForwardMsgPayload = SendMsgPayload & { messages?: any; };
|
||||
type GoCQHTTPSendForwardMsgPayload = SendMsgPayload & { messages?: OB11MessageMixType; };
|
||||
|
||||
export class GoCQHTTPSendForwardMsgBase extends SendMsgBase {
|
||||
protected override async check (payload: GoCQHTTPSendForwardMsgPayload) {
|
||||
@@ -20,14 +21,14 @@ export class GoCQHTTPSendForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
}
|
||||
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
override actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg;
|
||||
override async _handle (payload: SendMsgPayload): Promise<ReturnDataType> {
|
||||
override async _handle (payload: GoCQHTTPSendForwardMsgPayload): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Private);
|
||||
}
|
||||
}
|
||||
|
||||
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsgBase {
|
||||
override actionName = ActionName.GoCQHTTP_SendGroupForwardMsg;
|
||||
override async _handle (payload: SendMsgPayload): Promise<ReturnDataType> {
|
||||
override async _handle (payload: GoCQHTTPSendForwardMsgPayload): Promise<ReturnDataType> {
|
||||
return this.base_handle(payload, ContextMode.Group);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user