diff --git a/src/core/apis/packet.ts b/src/core/apis/packet.ts index fb930e95..5a4fa20d 100644 --- a/src/core/apis/packet.ts +++ b/src/core/apis/packet.ts @@ -86,7 +86,10 @@ export class NTQQPacketApi { const retData = new NapProtoMsg(OidbSvcTrpcTcp0X9067_202_Rsp_Body).decode(body); return retData.data.rkeyList; } - + async sendGroupSignPacket(groupCode: string) { + const packet = this.packetSession?.packer.packGroupSignReq(this.core.selfInfo.uin, groupCode); + await this.sendPacket('OidbSvcTrpcTcp.0xeb7', packet!, true); + } async sendStatusPacket(uin: number): Promise<{ status: number; ext_status: number; } | undefined> { let status = 0; try { diff --git a/src/core/packet/packer.ts b/src/core/packet/packer.ts index cb53db5c..7d2bd942 100644 --- a/src/core/packet/packer.ts +++ b/src/core/packet/packer.ts @@ -18,6 +18,7 @@ import { OidbSvcTrpcTcp0x6D6 } from "@/core/packet/proto/oidb/Oidb.0x6D6"; import { OidbSvcTrpcTcp0XE37_1200 } from "@/core/packet/proto/oidb/Oidb.0xE37_1200"; import { PacketMsgConverter } from "@/core/packet/msg/converter"; import { PacketClient } from "@/core/packet/client"; +import { OidbSvcTrpcTcp0XEB7 } from "./proto/oidb/Oidb.0xEB7"; export type PacketHexStr = string & { readonly hexNya: unique symbol }; @@ -321,4 +322,17 @@ export class PacketPacker { }) ); } + packGroupSignReq(uin: string, groupCode: string): PacketHexStr { + return this.toHexStr( + this.packOidbPacket(0XEB7, 1, new NapProtoMsg(OidbSvcTrpcTcp0XEB7).encode( + { + body: { + uin: uin, + groupUin: groupCode, + version: "9.0.90" + } + } + ), false, false) + ); + } } diff --git a/src/core/packet/proto/oidb/Oidb.0xEB7.ts b/src/core/packet/proto/oidb/Oidb.0xEB7.ts new file mode 100644 index 00000000..b5543182 --- /dev/null +++ b/src/core/packet/proto/oidb/Oidb.0xEB7.ts @@ -0,0 +1,12 @@ +import { ScalarType } from "@protobuf-ts/runtime"; +import { ProtoField } from "../NapProto"; + +export const OidbSvcTrpcTcp0XEB7_Body = { + uin: ProtoField(1, ScalarType.STRING), + groupUin: ProtoField(2, ScalarType.STRING), + version: ProtoField(3, ScalarType.STRING), +}; + +export const OidbSvcTrpcTcp0XEB7 = { + body: ProtoField(2, () => OidbSvcTrpcTcp0XEB7_Body), +} \ No newline at end of file diff --git a/src/onebot/action/extends/SetGroupSign.ts b/src/onebot/action/extends/SetGroupSign.ts new file mode 100644 index 00000000..9e87446b --- /dev/null +++ b/src/onebot/action/extends/SetGroupSign.ts @@ -0,0 +1,22 @@ +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; + +const SchemaData = { + type: 'object', + properties: { + group_id: { type: 'string' }, + }, + required: ['group_id'], +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export class SetGroupSign extends BaseAction { + actionName = ActionName.SetGroupSign; + payloadSchema = SchemaData; + + async _handle(payload: Payload) { + return await this.core.apis.PacketApi.sendGroupSignPacket(payload.group_id); + } +} diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 331de2c3..a2cbf7ef 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -93,6 +93,7 @@ import { GetGroupFileUrl } from "@/onebot/action/file/GetGroupFileUrl"; import { GetPacketStatus } from "@/onebot/action/packet/GetPacketStatus"; import { FriendPoke } from "@/onebot/action/user/FriendPoke"; import { GetCredentials } from './system/GetCredentials'; +import { SetGroupSign } from './extends/SetGroupSign'; export type ActionMap = Map>; @@ -115,6 +116,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo new SetQQAvatar(obContext, core), new TranslateEnWordToZn(obContext, core), new GetGroupRootFiles(obContext, core), + new SetGroupSign(obContext, core), // onebot11 new SendLike(obContext, core), new GetMsg(obContext, core), diff --git a/src/onebot/action/types.ts b/src/onebot/action/types.ts index 509593b4..7ab3f71a 100644 --- a/src/onebot/action/types.ts +++ b/src/onebot/action/types.ts @@ -134,5 +134,7 @@ export enum ActionName { GetGuildProfile = 'get_guild_service_profile', GetGroupIgnoredNotifies = 'get_group_ignored_notifies', + + SetGroupSign = "set_group_sign", // UploadForwardMsg = "upload_forward_msg", }