From 1abad76ac99e015be9e407d9f6d0258ef68193b9 Mon Sep 17 00:00:00 2001 From: idranme <96647698+idranme@users.noreply.github.com> Date: Sun, 24 May 2026 20:16:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=BE=A4=E7=BB=84=E4=BB=8A=E6=97=A5=E6=89=93=E5=8D=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=9F=E8=83=BD=20(#1855)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add group signed list API and OneBot action * feat: register GetGroupSignedList action handler --- packages/napcat-core/apis/webapi.ts | 37 ++++++++++++++ .../action/extends/GetGroupSignedList.ts | 48 +++++++++++++++++++ packages/napcat-onebot/action/index.ts | 2 + packages/napcat-onebot/action/router.ts | 2 + 4 files changed, 89 insertions(+) create mode 100644 packages/napcat-onebot/action/extends/GetGroupSignedList.ts diff --git a/packages/napcat-core/apis/webapi.ts b/packages/napcat-core/apis/webapi.ts index e50364621..9eca2afcc 100644 --- a/packages/napcat-core/apis/webapi.ts +++ b/packages/napcat-core/apis/webapi.ts @@ -539,4 +539,41 @@ export class NTQQWebApi { createAlbumFeedPublish(qunId, uin, albumId, batchId) ); } + + async getDaySignedList (groupCode: string) { + const pSkey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!; + const selfUin = this.core.selfInfo.uin; + const cookie = `p_uin=o${selfUin}; p_skey=${pSkey}; uin=o${selfUin}`; + const post = await RequestUtil.HttpGetJson<{ + retCode: number, + costTime: number, + response: { + ret?: { + code: string, + msg: string, + }, + page?: { + infos?: { + uid: string, + uidGroupNick: string, + signedTimeStamp: string, + signInRank: number, + }[], + offset: number, + total: number, + }[], + }, + funcCode: number, + }>(`https://qun.qq.com/v2/signin/trpc/GetDaySignedList?g_tk=${this.getBknFromPSKey(pSkey)}`, 'POST', { + dayYmd: new Date().toISOString().slice(0, 10).replace(/-/g, ''), + offset: 0, + limit: 100, + uid: selfUin, + groupId: groupCode, + }, { + Cookie: cookie, + 'Content-Type': 'application/json', + }); + return post; + } } diff --git a/packages/napcat-onebot/action/extends/GetGroupSignedList.ts b/packages/napcat-onebot/action/extends/GetGroupSignedList.ts new file mode 100644 index 000000000..38a3fa96b --- /dev/null +++ b/packages/napcat-onebot/action/extends/GetGroupSignedList.ts @@ -0,0 +1,48 @@ +import { OneBotAction } from '@/napcat-onebot/action/OneBotAction'; +import { ActionName } from '@/napcat-onebot/action/router'; +import { Type, Static } from '@sinclair/typebox'; + +const PayloadSchema = Type.Object({ + group_id: Type.Union([Type.String(), Type.Number()], { description: '群号' }), +}); + +type PayloadType = Static; + +const ReturnSchema = Type.Array( + Type.Object({ + user_id: Type.Number({ description: '打卡者QQ' }), + nick: Type.String({ description: '打卡者昵称' }), + time: Type.Number({ description: '打卡时间' }), + rank: Type.Number({ description: '打卡排名' }), + }), + { description: '群组今日打卡列表' } +); + +type ReturnType = Static; + +export class GetGroupSignedList extends OneBotAction { + override actionName = ActionName.GetGroupSignedList; + override actionSummary = '获取群组今日打卡列表'; + override actionTags = ['群组扩展']; + override payloadExample = { + group_id: '123456', + }; + + override returnExample = { + + }; + + override payloadSchema = PayloadSchema; + override returnSchema = ReturnSchema; + + async _handle (payload: PayloadType) { + const data = await this.core.apis.WebApi.getDaySignedList(payload.group_id.toString()); + if (!data.response.page) throw new Error('无法获取该群组打卡列表'); + return data.response.page[0]?.infos?.map(info => ({ + user_id: +info.uid, + nick: info.uidGroupNick, + time: +info.signedTimeStamp, + rank: (info.signInRank - 1) / 2 + 1, + })) ?? []; + } +} diff --git a/packages/napcat-onebot/action/index.ts b/packages/napcat-onebot/action/index.ts index b016b5483..ee866c64a 100644 --- a/packages/napcat-onebot/action/index.ts +++ b/packages/napcat-onebot/action/index.ts @@ -158,6 +158,7 @@ import { ReceiveOnlineFile } from './file/online/ReceiveOnlineFile'; import { RefuseOnlineFile } from './file/online/RefuseOnlineFile'; import { GetFilesetId } from './file/flash/GetFilesetIdByCode'; import { FetchPttText } from '@/napcat-onebot/action/msg/FetchPttText'; +import { GetGroupSignedList } from './extends/GetGroupSignedList'; export function getAllHandlers (obContext: NapCatOneBot11Adapter, core: NapCatCore) { const actionHandlers = [ @@ -213,6 +214,7 @@ export function getAllHandlers (obContext: NapCatOneBot11Adapter, core: NapCatCo new MoveGroupFile(obContext, core), new RenameGroupFile(obContext, core), new TransGroupFile(obContext, core), + new GetGroupSignedList(obContext, core), // onebot11 new SendLike(obContext, core), new GetMsg(obContext, core), diff --git a/packages/napcat-onebot/action/router.ts b/packages/napcat-onebot/action/router.ts index 7c216a504..bb325bac9 100644 --- a/packages/napcat-onebot/action/router.ts +++ b/packages/napcat-onebot/action/router.ts @@ -208,4 +208,6 @@ export const ActionName = { ReceiveOnlineFile: 'receive_online_file', RefuseOnlineFile: 'refuse_online_file', CancelOnlineFile: 'cancel_online_file', + + GetGroupSignedList: 'get_group_signed_list', } as const;