Skip to content

Commit

Permalink
feat: SetGroupSign
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Oct 24, 2024
1 parent 8fe37d1 commit dbe72fa
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/apis/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions src/core/packet/packer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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)
);
}
}
12 changes: 12 additions & 0 deletions src/core/packet/proto/oidb/Oidb.0xEB7.ts
Original file line number Diff line number Diff line change
@@ -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),
}
22 changes: 22 additions & 0 deletions src/onebot/action/extends/SetGroupSign.ts
Original file line number Diff line number Diff line change
@@ -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<typeof SchemaData>;

export class SetGroupSign extends BaseAction<Payload, any> {
actionName = ActionName.SetGroupSign;
payloadSchema = SchemaData;

async _handle(payload: Payload) {
return await this.core.apis.PacketApi.sendGroupSignPacket(payload.group_id);
}
}
2 changes: 2 additions & 0 deletions src/onebot/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, BaseAction<any, any>>;
Expand All @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/onebot/action/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

0 comments on commit dbe72fa

Please sign in to comment.