chore: run eslint --fix in onebot module

This commit is contained in:
Wesley F. Young
2024-08-09 20:35:03 +08:00
parent 714f8327ea
commit 5990e0c2eb
110 changed files with 3832 additions and 3829 deletions

View File

@@ -10,43 +10,43 @@ interface Response {
}
const SchemaData = {
type: 'object',
properties: {
group_id: { type: ['number', 'string'] },
message_seq: { type: 'number' },
count: { type: 'number' },
reverseOrder: { type: 'boolean' }
},
required: ['group_id']
type: 'object',
properties: {
group_id: { type: ['number', 'string'] },
message_seq: { type: 'number' },
count: { type: 'number' },
reverseOrder: { type: 'boolean' }
},
required: ['group_id']
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload): Promise<Response> {
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
//处理参数
const isReverseOrder = payload.reverseOrder || true;
const MsgCount = payload.count || 20;
const peer: Peer = { chatType: ChatType.group, peerUid: payload.group_id.toString() };
//拉取消息
let msgList: RawMessage[];
if (!payload.message_seq || payload.message_seq == 0) {
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
} else {
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
}
if (isReverseOrder) msgList.reverse();
await Promise.all(msgList.map(async msg => {
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
}));
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload): Promise<Response> {
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
//处理参数
const isReverseOrder = payload.reverseOrder || true;
const MsgCount = payload.count || 20;
const peer: Peer = { chatType: ChatType.group, peerUid: payload.group_id.toString() };
//拉取消息
let msgList: RawMessage[];
if (!payload.message_seq || payload.message_seq == 0) {
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
} else {
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
}
if (isReverseOrder) msgList.reverse();
await Promise.all(msgList.map(async msg => {
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
}));
//转换消息
const ob11MsgList = await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, "array")));
return { 'messages': ob11MsgList };
}
//转换消息
const ob11MsgList = await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, "array")));
return { 'messages': ob11MsgList };
}
}