mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
style: 强类型大法
This commit is contained in:
@@ -15,11 +15,10 @@ const SchemaData = Type.Object({
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
class GetMsg extends OneBotAction<Payload, OB11Message> {
|
||||
actionName = ActionName.GetMsg;
|
||||
payloadSchema = SchemaData;
|
||||
override actionName = ActionName.GetMsg;
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload, adapter: string, config: NetworkAdapterConfig) {
|
||||
// log("history msg ids", Object.keys(msgHistory));
|
||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('参数message_id不能为空');
|
||||
}
|
||||
@@ -30,19 +29,20 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
|
||||
}
|
||||
const peer = { guildId: '', peerUid: msgIdWithPeer?.Peer.peerUid, chatType: msgIdWithPeer.Peer.chatType };
|
||||
const orimsg = this.obContext.recallMsgCache.get(msgIdWithPeer.MsgId);
|
||||
let msg: RawMessage;
|
||||
let msg: RawMessage|undefined;
|
||||
if (orimsg) {
|
||||
msg = orimsg;
|
||||
} else {
|
||||
msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0];
|
||||
}
|
||||
if (!msg) throw Error('消息不存在');
|
||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
||||
if (!retMsg) throw Error('消息为空');
|
||||
try {
|
||||
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!;
|
||||
retMsg.message_seq = retMsg.message_id;
|
||||
retMsg.real_id = retMsg.message_id;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
return retMsg;
|
||||
|
||||
Reference in New Issue
Block a user