diff --git a/manifest.json b/manifest.json index 5d62896c..1b814087 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "3.1.3", + "version": "3.1.4", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index db9f7aea..d9132e18 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "3.1.3", + "version": "3.1.4", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", @@ -13,6 +13,7 @@ "devDependencies": { "@babel/preset-typescript": "^7.24.7", "@log4js-node/log4js-api": "^1.0.2", + "@protobuf-ts/runtime": "^2.9.4", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", "@types/cors": "^2.8.17", @@ -23,29 +24,28 @@ "@types/ws": "^8.5.12", "@typescript-eslint/eslint-plugin": "^8.3.0", "@typescript-eslint/parser": "^8.3.0", + "ajv": "^8.13.0", + "async-mutex": "^0.5.0", + "chalk": "^5.3.0", + "commander": "^12.1.0", + "cors": "^2.8.5", "eslint": "^8.57.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", + "fast-xml-parser": "^4.3.6", + "file-type": "^19.0.0", + "image-size": "^1.1.1", + "json-schema-to-ts": "^3.1.1", "typescript": "^5.3.3", "vite": "^5.2.6", "vite-plugin-cp": "^4.0.8", - "vite-tsconfig-paths": "^4.3.2", - "@protobuf-ts/runtime": "^2.9.4", - "ajv": "^8.13.0", - "fast-xml-parser": "^4.3.6", - "chalk": "^5.3.0", - "commander": "^12.1.0", - "async-mutex": "^0.5.0", - "file-type": "^19.0.0", - "json-schema-to-ts": "^3.1.1", - "image-size": "^1.1.1", - "cors": "^2.8.5" + "vite-tsconfig-paths": "^4.3.2" }, "dependencies": { - "qrcode-terminal": "^0.12.0", - "fluent-ffmpeg": "^2.1.2", "express": "^5.0.0-beta.2", + "fluent-ffmpeg": "^2.1.2", "log4js": "^6.9.1", + "qrcode-terminal": "^0.12.0", "silk-wasm": "^3.6.1", "ws": "^8.18.0" } diff --git a/src/common/version.ts b/src/common/version.ts index 4ce85e80..4235ff80 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '3.1.3'; +export const napCatVersion = '3.1.4'; diff --git a/src/core/apis/packet.ts b/src/core/apis/packet.ts index d381c225..b51bbff2 100644 --- a/src/core/apis/packet.ts +++ b/src/core/apis/packet.ts @@ -91,7 +91,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 8b7d3277..3875ab55 100644 --- a/src/core/packet/packer.ts +++ b/src/core/packet/packer.ts @@ -25,6 +25,7 @@ import { PacketMsgConverter } from "@/core/packet/msg/converter"; import { PacketClient } from "@/core/packet/client"; import { OidbSvcTrpcTcp0XE37_1700 } from "@/core/packet/proto/oidb/Oidb.0xE37_1700"; import { OidbSvcTrpcTcp0XE37_800 } from "@/core/packet/proto/oidb/Oidb.0XE37_800"; +import { OidbSvcTrpcTcp0XEB7 } from "./proto/oidb/Oidb.0xEB7"; export type PacketHexStr = string & { readonly hexNya: unique symbol }; @@ -694,4 +695,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/core/services/NodeIKernelGroupService.ts b/src/core/services/NodeIKernelGroupService.ts index 252db0e8..d46255af 100644 --- a/src/core/services/NodeIKernelGroupService.ts +++ b/src/core/services/NodeIKernelGroupService.ts @@ -239,7 +239,7 @@ export interface NodeIKernelGroupService { setMemberShutUp(groupCode: string, memberTimes: { uid: string, timeStamp: number }[]): Promise; - getGroupRecommendContactArkJson(groupCode: string): unknown; + getGroupRecommendContactArkJson(groupCode: string): Promise; getJoinGroupLink(param: { groupCode: string, 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", } diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index afe3e9cb..b4b008a3 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -624,12 +624,20 @@ export class OneBotMsgApi { [OB11MessageDataType.miniapp]: async () => undefined, - [OB11MessageDataType.contact]: async ({ data }, context) => { - const arkJson = await this.core.apis.UserApi.getBuddyRecommendContactArkJson(data.id.toString(), ''); - return this.ob11ToRawConverters.json({ - data: { data: arkJson.arkMsg }, - type: OB11MessageDataType.json - }, context); + [OB11MessageDataType.contact]: async ({ data: { type = "qq", id } }, context) => { + if(type === "qq"){ + const arkJson = await this.core.apis.UserApi.getBuddyRecommendContactArkJson(id.toString(), ''); + return this.ob11ToRawConverters.json({ + data: { data: arkJson.arkMsg }, + type: OB11MessageDataType.json + }, context); + }else if(type === "group"){ + const arkJson = await this.core.apis.GroupApi.getGroupRecommendContactArkJson(id.toString()); + return this.ob11ToRawConverters.json({ + data: { data: arkJson.arkJson }, + type: OB11MessageDataType.json + }, context); + } } }; diff --git a/src/onebot/types/message.ts b/src/onebot/types/message.ts index 93ab4180..d4890e34 100644 --- a/src/onebot/types/message.ts +++ b/src/onebot/types/message.ts @@ -85,6 +85,7 @@ export interface OB11MessageText { export interface OB11MessageContext { type: OB11MessageDataType.contact, data: { + type:"qq"|"group", id: string, } } diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 55ccf7c0..274792a7 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V3.1.3', 'napcat-update-button', 'secondary'), + SettingButton('V3.1.4', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 3ee3d4f7..f2e95309 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V3.1.3", "napcat-update-button", "secondary") + SettingButton("V3.1.4", "napcat-update-button", "secondary") ) ]), SettingList([