This commit is contained in:
手瓜一十雪 2024-05-03 14:02:40 +08:00
parent c174fce227
commit 870a915377

View File

@ -1,12 +1,23 @@
import { WebApi, WebApiGroupNoticeRet } from '@/core/apis/webapi';
import { WebApi, WebApiGroupNoticeFeed, WebApiGroupNoticeRet } from '@/core/apis/webapi';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
interface PayloadType {
group_id: number
group_id: number
}
export class GetGroupNotice extends BaseAction<PayloadType, WebApiGroupNoticeRet> {
interface GroupNotice {
sender_id: number
publish_time: number
message: {
text: string
image: Array<{
height: string
width: string
id: string
}>
}
}
export class GetGroupNotice extends BaseAction<PayloadType, GroupNotice[]> {
actionName = ActionName.GoCQHTTP_GetGroupNotice;
protected async _handle(payload: PayloadType) {
@ -15,6 +26,19 @@ export class GetGroupNotice extends BaseAction<PayloadType, WebApiGroupNoticeRet
if (!ret) {
throw new Error('获取公告失败');
}
return ret;
let retNotices: GroupNotice[] = new Array<GroupNotice>();
for (let key in ret.feeds) {
let retNotice: GroupNotice = {
sender_id: ret.feeds[key].u,
publish_time: ret.feeds[key].pubt,
message: {
text: ret.feeds[key].msg.text,
image: []
}
}
retNotices.push(retNotice);
}
return retNotices;
}
}