From 8f4f8986756eaf47630a911362e54ef7feac846c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 12 Oct 2024 15:34:10 +0800 Subject: [PATCH] fix --- src/core/apis/group.ts | 2 +- src/core/proto/Poke.ts | 6 +++--- src/onebot/action/group/GroupPoke.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/onebot/action/group/GroupPoke.ts diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 672220484..84f0f2c16 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -53,7 +53,7 @@ export class NTQQGroupApi { uids, ); } - async sendPacketPoke(group: string, peer: string) { + async sendPacketPoke(group: number, peer: number) { let data = encodeGroupPoke(group, peer); let hex = Buffer.from(data).toString('hex'); let retdata = await this.core.apis.PacketApi.sendPacket('OidbSvcTrpcTcp.0xed3_1', hex, false); diff --git a/src/core/proto/Poke.ts b/src/core/proto/Poke.ts index d9720a649..3829d4ef0 100644 --- a/src/core/proto/Poke.ts +++ b/src/core/proto/Poke.ts @@ -14,11 +14,11 @@ export const OidbSvcTrpcTcp0XED3_1 = new MessageType("oidb_svc_trpctcp_0xed3_1", { no: 6, name: "ext", kind: "scalar", T: ScalarType.UINT32 } ]); -export function encodeGroupPoke(groupUin: string, PeerUin: string) { +export function encodeGroupPoke(groupUin: number, PeerUin: number) { let Body = OidbSvcTrpcTcp0XED3_1.toBinary ({ - uin: parseInt(PeerUin), - groupuin: parseInt(groupUin), + uin: PeerUin, + groupuin: groupUin, ext: 0 }); //console.log(Body) diff --git a/src/onebot/action/group/GroupPoke.ts b/src/onebot/action/group/GroupPoke.ts new file mode 100644 index 000000000..84d4996a1 --- /dev/null +++ b/src/onebot/action/group/GroupPoke.ts @@ -0,0 +1,26 @@ +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; +// no_cache get时传字符串 +const SchemaData = { + type: 'object', + properties: { + group_id: { type: ['number', 'string'] }, + user_id: { type: ['number', 'string'] }, + }, + required: ['group_id', 'user_id'], +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export class GroupPoke extends BaseAction { + actionName = ActionName.GetGroupList; + payloadSchema = SchemaData; + + async _handle(payload: Payload) { + if (!this.core.apis.PacketApi.PacketClient?.isConnected) { + throw new Error('PacketClient is not init'); + } + this.core.apis.GroupApi.sendPacketPoke(+payload.group_id, +payload.user_id); + } +} \ No newline at end of file