diff --git a/manifest.json b/manifest.json index c0864b5e..3bcc2f2d 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.2.5", + "version": "2.2.6", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index bb5826e6..ed969952 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.2.5", + "version": "2.2.6", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", diff --git a/src/common/framework/napcat.ts b/src/common/framework/napcat.ts index ab97e1c0..9faa5453 100644 --- a/src/common/framework/napcat.ts +++ b/src/common/framework/napcat.ts @@ -2,7 +2,7 @@ import path, { dirname } from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; -export const napcat_version = '2.2.5'; +export const napcat_version = '2.2.6'; export class NapCatPathWrapper { binaryPath: string; diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 1266ed37..12852d5f 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -224,6 +224,10 @@ export class NTQQGroupApi { async kickMemberV2Inner(param: kickMemberV2Req) { return this.context.session.getGroupService().kickMemberV2(param); } + async deleteGroupBulletin(GroupCode: string, feedId: string) { + const _Pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!; + return this.context.session.getGroupService().deleteGroupBulletin(GroupCode, _Pskey, feedId); + } async quitGroupV2(GroupCode: string, needDeleteLocalMsg: boolean) { let param = { groupCode: GroupCode, diff --git a/src/core/apis/webapi.ts b/src/core/apis/webapi.ts index 05deb711..e8368b1f 100644 --- a/src/core/apis/webapi.ts +++ b/src/core/apis/webapi.ts @@ -20,15 +20,14 @@ export class NTQQWebApi { async shareDigest(groupCode: string, msgSeq: string, msgRandom: string, targetGroupCode: string) { const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); - const url = `https://qun.qq.com/cgi-bin/group_digest/share_digest?${ - new URLSearchParams({ - bkn: this.getBknFromCookie(cookieObject), - group_code: groupCode, - msg_seq: msgSeq, - msg_random: msgRandom, - target_group_code: targetGroupCode, - }).toString() - }`; + const url = `https://qun.qq.com/cgi-bin/group_digest/share_digest?${new URLSearchParams({ + bkn: this.getBknFromCookie(cookieObject), + group_code: groupCode, + msg_seq: msgSeq, + msg_random: msgRandom, + target_group_code: targetGroupCode, + }).toString() + }`; try { return RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); } catch (e) { @@ -38,18 +37,17 @@ export class NTQQWebApi { async getGroupEssenceMsg(GroupCode: string, page_start: string) { const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); - const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${ - new URLSearchParams({ - bkn: this.getBknFromCookie(cookieObject), - group_code: GroupCode, - page_start, - page_limit: '20', - }).toString() - }`; + const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({ + bkn: this.getBknFromCookie(cookieObject), + group_code: GroupCode, + page_start, + page_limit: '20', + }).toString() + }`; let ret; try { ret = await RequestUtil.HttpGetJson - (url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); + (url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); } catch { return undefined; } @@ -65,15 +63,14 @@ export class NTQQWebApi { const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); const retList: Promise[] = []; const fastRet = await RequestUtil.HttpGetJson - (`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${ - new URLSearchParams({ + (`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({ st: '0', end: '40', sort: '1', gc: GroupCode, bkn: this.getBknFromCookie(cookieObject), }).toString() - }`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) }); + }`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) }); if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) { return []; } else { @@ -86,15 +83,14 @@ export class NTQQWebApi { //遍历批量请求 for (let i = 2; i <= PageNum; i++) { const ret = RequestUtil.HttpGetJson - (`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${ - new URLSearchParams({ + (`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({ st: ((i - 1) * 40).toString(), end: (i * 40).toString(), sort: '1', gc: GroupCode, bkn: this.getBknFromCookie(cookieObject), }).toString() - }`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) }); + }`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) }); retList.push(ret); } //批量等待 @@ -127,8 +123,7 @@ export class NTQQWebApi { let ret: any = undefined; try { ret = await RequestUtil.HttpGetJson - (`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${ - new URLSearchParams({ + (`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${new URLSearchParams({ bkn: this.getBknFromCookie(cookieObject), qid: GroupCode, text: Content, @@ -136,7 +131,7 @@ export class NTQQWebApi { type: '1', settings: '{"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}', }).toString() - }`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); + }`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); return ret; } catch (e) { return undefined; @@ -147,15 +142,10 @@ export class NTQQWebApi { const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); let ret: WebApiGroupNoticeRet | undefined = undefined; try { - ret = await RequestUtil.HttpGetJson(`https://web.qun.qq.com/cgi-bin/announce/get_t_list?${ - new URLSearchParams({ - bkn: this.getBknFromCookie(cookieObject), - qid: GroupCode, - type: '1', - start: '0', - num: '1', - }).toString() - }`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); + const url = 'https://web.qun.qq.com/cgi-bin/announce/get_t_list?bkn=' + + this.getBknFromCookie(cookieObject) + '&qid=' + GroupCode + '&ft=23&ni=1&n=1&i=1&log_read=1&platform=1&s=-1&n=20'; + + ret = await RequestUtil.HttpGetJson(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); if (ret?.ec !== 0) { return undefined; } @@ -168,12 +158,11 @@ export class NTQQWebApi { async getGroupHonorInfo(groupCode: string, getType: WebHonorType) { const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); const getDataInternal = async (Internal_groupCode: string, Internal_type: number) => { - const url = `https://qun.qq.com/interactive/honorlist?${ - new URLSearchParams({ - gc: Internal_groupCode, - type: Internal_type.toString(), - }).toString() - }`; + const url = `https://qun.qq.com/interactive/honorlist?${new URLSearchParams({ + gc: Internal_groupCode, + type: Internal_type.toString(), + }).toString() + }`; let resJson; try { const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) }); diff --git a/src/core/services/NodeIKernelGroupService.ts b/src/core/services/NodeIKernelGroupService.ts index b1e519f5..118dda10 100644 --- a/src/core/services/NodeIKernelGroupService.ts +++ b/src/core/services/NodeIKernelGroupService.ts @@ -209,7 +209,7 @@ export interface NodeIKernelGroupService { getGroupBulletin(groupCode: string): unknown; - deleteGroupBulletin(groupCode: string, seq: string): void; + deleteGroupBulletin(groupCode: string, seq: string, feedId: string): void; publishGroupBulletin(groupCode: string, pskey: string, data: any): Promise; diff --git a/src/onebot/action/group/DelGroupNotice.ts b/src/onebot/action/group/DelGroupNotice.ts new file mode 100644 index 00000000..4008244e --- /dev/null +++ b/src/onebot/action/group/DelGroupNotice.ts @@ -0,0 +1,28 @@ +import { WebApiGroupNoticeFeed } from '@/core'; +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; + + +const SchemaData = { + type: 'object', + properties: { + group_id: { type: ['number', 'string'] }, + feed_id: { type: 'string' }, + }, + required: ['group_id','feed_id'], +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export class DelGroupNotice extends BaseAction { + actionName = ActionName.DelGroupNotice; + PayloadSchema = SchemaData; + + async _handle(payload: Payload) { + const NTQQGroupApi = this.CoreContext.apis.GroupApi; + const group = payload.group_id.toString(); + const feedId = payload.feed_id; + return await NTQQGroupApi.deleteGroupBulletin(group, feedId); + } +} diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 71de3fa0..f6a45c27 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -80,6 +80,7 @@ import GetGuildProfile from './guild/GetGuildProfile'; import SetModelShow from './go-cqhttp/SetModelShow'; import { SetInputStatus } from './extends/SetInputStatus'; import { GetCSRF } from './system/GetCSRF'; +import { DelGroupNotice } from './group/DelGroupNotice'; export type ActionMap = Map>; @@ -169,6 +170,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex new SetModelShow(onebotContext, coreContext), new SetInputStatus(onebotContext, coreContext), new GetCSRF(onebotContext, coreContext), + new DelGroupNotice(onebotContext, coreContext), ]; const actionMap = new Map(); for (const action of actionHandlers) { diff --git a/src/onebot/action/msg/SendMsg/create-send-elements.ts b/src/onebot/action/msg/SendMsg/create-send-elements.ts index 720c85c7..31500687 100644 --- a/src/onebot/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot/action/msg/SendMsg/create-send-elements.ts @@ -171,7 +171,7 @@ const _handlers: { } else { postData = data; } - // Mlikiowa V2.2.5 Refactor Todo + // Mlikiowa V2.2.6 Refactor Todo const signUrl = obContext.configLoader.configData.musicSignUrl; if (!signUrl) { if (data.type === 'qq') { diff --git a/src/onebot/action/types.ts b/src/onebot/action/types.ts index 835663f9..c4e2d855 100644 --- a/src/onebot/action/types.ts +++ b/src/onebot/action/types.ts @@ -109,4 +109,5 @@ export enum ActionName { SetModelShow = "_set_model_show", SetInputStatus = "set_input_status", GetCSRF = "get_csrf_token", + DelGroupNotice = "_del_group_notice", } diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 036c47f0..677fad31 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('V2.2.5', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.6', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 19be921d..18b3d297 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.2.5", "napcat-update-button", "secondary") + SettingButton("V2.2.6", "napcat-update-button", "secondary") ) ]), SettingList([