From 7b10d75aeb67bbc1ecd74ca501af29a950fd5120 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: Fri, 9 Aug 2024 10:48:13 +0800 Subject: [PATCH 1/7] chore: 1.8.4 --- .env.production | 2 +- README.md | 12 ++- docs/changelogs/CHANGELOG.v1.8.4.md | 12 +++ package.json | 3 +- script/BootWay05.bat | 2 +- src/common/utils/QQBasicInfo.ts | 2 +- src/core/src/apis/group.ts | 2 +- src/core/src/apis/msg.ts | 73 +++++++++++++++++-- src/core/src/data.ts | 3 - .../src/services/NodeIKernelMsgService.ts | 22 +++++- src/nwebui/Readme.md | 4 + .../action/extends/CreateCollection.ts | 1 - src/onebot11/action/extends/Debug.ts | 13 +--- .../action/extends/FetchEmojioLike.ts | 4 +- .../action/extends/GetCollectionList.ts | 2 - .../action/extends/GetRobotUinRange.ts | 1 - src/onebot11/action/extends/OCRImage.ts | 2 +- src/onebot11/action/extends/SetGroupHeader.ts | 2 - src/onebot11/action/extends/SetLongNick.ts | 1 - .../action/extends/SetOnlineStatus.ts | 8 +- src/onebot11/action/extends/SetQQAvatar.ts | 3 +- src/onebot11/action/extends/TestApi01.ts | 4 +- .../action/extends/TranslateEnWordToZn.ts | 6 +- src/onebot11/action/file/DelGroupFile.ts | 2 +- src/onebot11/action/file/GetFile.ts | 2 +- .../action/go-cqhttp/GetForwardMsg.ts | 12 +-- .../action/go-cqhttp/GetFriendMsgHistory.ts | 1 + .../action/go-cqhttp/GetGroupHonorInfo.ts | 2 +- .../action/go-cqhttp/GetStrangerInfo.ts | 1 - .../action/go-cqhttp/SendGroupNotice.ts | 2 - .../action/go-cqhttp/UploadGroupFile.ts | 2 +- .../action/go-cqhttp/UploadPrivareFile.ts | 3 +- src/onebot11/action/group/GetGroupEssence.ts | 4 - src/onebot11/action/group/GetGroupList.ts | 1 - src/onebot11/action/group/SetEssenceMsg.ts | 4 +- .../action/group/SetGroupAddRequest.ts | 4 +- src/onebot11/action/index.ts | 2 - src/onebot11/action/msg/DeleteMsg.ts | 24 +++--- src/onebot11/action/msg/ForwardSingleMsg.ts | 2 +- src/onebot11/action/msg/GetMsg.ts | 4 +- .../msg/SendMsg/create-send-elements.ts | 2 +- .../action/msg/SendMsg/handle-forward-node.ts | 16 ++-- src/onebot11/action/msg/SendMsg/index.ts | 5 +- src/onebot11/action/msg/SendPrivateMsg.ts | 1 - src/onebot11/action/msg/SetMsgEmojiLike.ts | 1 - src/onebot11/action/system/CanSendImage.ts | 1 - src/onebot11/action/system/GetLoginInfo.ts | 2 - src/onebot11/action/types.ts | 4 +- src/onebot11/action/user/GetFriendList.ts | 2 - src/onebot11/action/user/SendLike.ts | 1 - src/onebot11/config.ts | 8 +- src/onebot11/constructor.ts | 23 +++--- .../event/notice/OB11GroupAdminNoticeEvent.ts | 2 +- .../event/notice/OB11InputStatusEvent.ts | 2 +- src/onebot11/log.ts | 2 +- src/onebot11/main.ts | 15 ++-- src/onebot11/version.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 59 files changed, 193 insertions(+), 156 deletions(-) create mode 100644 docs/changelogs/CHANGELOG.v1.8.4.md create mode 100644 src/nwebui/Readme.md diff --git a/.env.production b/.env.production index 458dab00..2f6aa849 100644 --- a/.env.production +++ b/.env.production @@ -1 +1 @@ -VITE_BUILD_TYPE = Production \ No newline at end of file +VITE_BUILD_TYPE = Production diff --git a/README.md b/README.md index 895b7756..0882fd70 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,9 @@ ## 项目介绍 -NapCatQQ 是基于 PC NTQQ 本体实现的一套无头 Bot 框架。 +NapCatQQ 是基于 PC NTQQ 本体实现一套无头 Bot 框架。 -NapCat 意为「瞌睡猫」,像睡着了一样在后台低占用运行的、无需 GUI 界面的 NTQQ。 - -项目的 [v2](https://github.com/NapNeko/NapCatQQ/tree/v2) 重构正在进行中,敬请关注。 +名字寓意 瞌睡猫QQ,像睡着了一样在后台低占用运行的无需GUI界面的NTQQ。 ## 如何使用 @@ -16,14 +14,14 @@ NapCat 意为「瞌睡猫」,像睡着了一样在后台低占用运行的、 **首次使用** 请务必前往 [官方文档](https://napneko.github.io/) 查看使用文档与教程 + ## 项目声明 -* 请不要在无关地方宣传 NapCatQQ,本项目只是用于学习 node 相关知识,切勿用于违法用途 +* 请不要在无关地方宣传NapCatQQ,本项目只是用于学习 node 相关知识,切勿用于违法用途 -* NapCat 不会收集用户隐私信息,但是未来可能会为了更好的利于 NapCat 的优化会收集一些设备信息,如 CPU 架构,系统版本等 +* NapCat 不会收集用户隐私信息,但是未来可能会为了更好的利于 NapCat 的优化会收集一些设备信息,如 cpu 架构,系统版本等 ## 相关链接 - [Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl) ## 鸣谢名单 diff --git a/docs/changelogs/CHANGELOG.v1.8.4.md b/docs/changelogs/CHANGELOG.v1.8.4.md new file mode 100644 index 00000000..e12a0206 --- /dev/null +++ b/docs/changelogs/CHANGELOG.v1.8.4.md @@ -0,0 +1,12 @@ +# v1.8.4 + +QQ Version: Windows 9.9.15-26702 / Linux 3.2.12-26702 + +## 启动的方式 +Way03/Way05 + +## 新增与调整 +1. 支持主动临时消息 + + +新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api) diff --git a/package.json b/package.json index 5774da9b..bd34fa80 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "1.8.3", + "version": "1.8.4", "scripts": { "watch:dev": "vite --mode development", "watch:prod": "vite --mode production", @@ -53,7 +53,6 @@ }, "dependencies": { "ajv": "^8.13.0", - "strtok3":"8.0.1", "chalk": "^5.3.0", "commander": "^12.0.0", "cors": "^2.8.5", diff --git a/script/BootWay05.bat b/script/BootWay05.bat index 95b4299e..06d2ee3b 100644 --- a/script/BootWay05.bat +++ b/script/BootWay05.bat @@ -86,5 +86,5 @@ where wt >nul 2>nul if %errorlevel% equ 0 ( wt "cmd" /c "%QQPath%" --enable-logging %* ) else ( - %QQPath%" --enable-logging %* + "%QQPath%" --enable-logging %* ) diff --git a/src/common/utils/QQBasicInfo.ts b/src/common/utils/QQBasicInfo.ts index e69c3827..527efca7 100644 --- a/src/common/utils/QQBasicInfo.ts +++ b/src/common/utils/QQBasicInfo.ts @@ -39,7 +39,7 @@ export function getAppidV2(): { appid: string, qua: string } { } } catch (e) { - log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`); + log('[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常'); } // 以下是兜底措施 log(`[QQ版本兼容性检测] ${getFullQQVesion()} 版本兼容性不佳,可能会导致一些功能无法正常使用`); diff --git a/src/core/src/apis/group.ts b/src/core/src/apis/group.ts index 1ccf1e99..6722d8bf 100644 --- a/src/core/src/apis/group.ts +++ b/src/core/src/apis/group.ts @@ -220,7 +220,7 @@ export class NTQQGroupApi { const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!; return napCatCore.session.getGroupService().uploadGroupBulletinPic(GroupCode, _Pskey, imageurl); } - static async handleGroupRequest(flag: string, operateType: GroupRequestOperateTypes, reason?: string) { + static async handleGroupRequest(flag: string , operateType: GroupRequestOperateTypes, reason?: string) { let flagitem = flag.split('|'); let groupCode = flagitem[0]; let seq = flagitem[1]; diff --git a/src/core/src/apis/msg.ts b/src/core/src/apis/msg.ts index 53c9ba88..681ac6f9 100644 --- a/src/core/src/apis/msg.ts +++ b/src/core/src/apis/msg.ts @@ -1,8 +1,8 @@ -import { GetFileListParam, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; -import { friends, groups, selfInfo } from '@/core/data'; +import { ChatType, ChatType2, GetFileListParam, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities'; +import { friends, getGroupMember, groups, selfInfo } from '@/core/data'; import { log, logWarn } from '@/common/utils/log'; import { sleep } from '@/common/utils/helper'; -import { napCatCore, NTQQUserApi } from '@/core'; +import { napCatCore, NTQQGroupApi, NTQQUserApi } from '@/core'; import { onGroupFileInfoUpdateParamType } from '@/core/listeners'; import { GeneralCallResult } from '@/core/services/common'; import { MessageUnique } from '../../../common/utils/MessageUnique'; @@ -71,6 +71,29 @@ export class NTQQMsgApi { static async FetchLongMsg(peer: Peer, msgId: string) { return napCatCore.session.getMsgService().fetchLongMsg(peer, msgId); } + static async getTempChatInfo(chatType: ChatType2, peerUid: string) { + return napCatCore.session.getMsgService().getTempChatInfo(chatType, peerUid); + } + static async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) { + //By Jadx/Ida Mlikiowa + let TempGameSession = { + nickname: "", + gameAppId: "", + selfTinyId: "", + peerRoleId: "", + peerOpenId: "", + }; + return napCatCore.session.getMsgService().prepareTempChat({ + chatType: ChatType2.KCHATTYPETEMPC2CFROMGROUP, + peerUid: toUserUid, + peerNickname: nickname, + fromGroupCode: GroupCode, + sig: "", + selfPhone: "", + selfUid: selfInfo.uid, + gameSession: TempGameSession + }); + } static async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) { //console.log(peer, msgSeq, emojiId, emojiType, count); //注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa @@ -97,7 +120,7 @@ export class NTQQMsgApi { return napCatCore.session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId); } static async ForwardMsg(peer: Peer, msgIds: string[]) { - return napCatCore.session.getMsgService().forwardMsg(msgIds, peer, [peer], new Map()); + return napCatCore.session.getMsgService().forwardMsg(msgIds, peer, [peer], []); } static async getLastestMsgByUids(peer: Peer, count: number = 20, isReverseOrder: boolean = false) { let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', { @@ -137,6 +160,16 @@ export class NTQQMsgApi { }); return ret; } + /** + * + * @deprecated 从9.9.15-26702版本开始,该接口已经废弃,请使用getMsgsEx + * @param peer + * @param seq + * @param count + * @param desc + * @param z + * @returns + */ static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) { return await napCatCore.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z); } @@ -172,6 +205,9 @@ export class NTQQMsgApi { }, msgIds); } static async sendMsgV2(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) { + if (peer.chatType === ChatType.temp) { + //await NTQQMsgApi.PrepareTempChat().then().catch(); + } function generateMsgId() { const timestamp = Math.floor(Date.now() / 1000); const random = Math.floor(Math.random() * Math.pow(2, 32)); @@ -225,7 +261,32 @@ export class NTQQMsgApi { } static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) { //唉? !我有个想法 - let msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime()); + function generateMsgId() { + const timestamp = Math.floor(Date.now() / 1000); + const random = Math.floor(Math.random() * Math.pow(2, 32)); + const buffer = Buffer.alloc(8); + buffer.writeUInt32BE(timestamp, 0); + buffer.writeUInt32BE(random, 4); + const msgId = BigInt("0x" + buffer.toString('hex')).toString(); + return msgId; + } + // 此处有采用Hack方法 利用数据返回正确得到对应消息 + // 与之前 Peer队列 MsgSeq队列 真正的MsgId并发不同 + // 谨慎采用 目前测试暂无问题 Developer.Mlikiowa + let msgId: string; + try { + msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime()); + } catch (error) { + //if (!napCatCore.session.getMsgService()['generateMsgUniqueId']) + //兜底识别策略V2 + msgId = generateMsgId(); + } + if (peer.chatType === ChatType.temp && peer.guildId && peer.guildId !== '') { + let member = await getGroupMember(peer.guildId, peer.peerUid!); + if(member){ + await NTQQMsgApi.PrepareTempChat(peer.peerUid,peer.guildId,member.nick); + } + } peer.guildId = msgId; let data = await NTEventDispatch.CallNormalEvent< (msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map) => Promise, @@ -268,7 +329,7 @@ export class NTQQMsgApi { return NTEventDispatch.CallNoListenerEvent<() => string>('NodeIKernelMsgService/getServerTime', 5000); } static async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) { - return napCatCore.session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], new Map()); + return napCatCore.session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], []); } static async multiForwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]): Promise { const msgInfos = msgIds.map(id => { diff --git a/src/core/src/data.ts b/src/core/src/data.ts index edeb662d..f0d2351e 100644 --- a/src/core/src/data.ts +++ b/src/core/src/data.ts @@ -80,9 +80,6 @@ export async function getGroupMember(groupQQ: string | number, memberUinOrUid: s } return member; } -// 考虑优化 移入QQ缓存或使用Api直接获取 -export const tempGroupCodeMap: Record = {}; // peerUid => 群号 - // 保留 需要频繁读写 export const stat = { packet_received: 0, diff --git a/src/core/src/services/NodeIKernelMsgService.ts b/src/core/src/services/NodeIKernelMsgService.ts index 61c01d7c..fdc42d44 100644 --- a/src/core/src/services/NodeIKernelMsgService.ts +++ b/src/core/src/services/NodeIKernelMsgService.ts @@ -12,6 +12,21 @@ export interface QueryMsgsParams { isReverseOrder: boolean, isIncludeCurrent: boolean } +export interface TmpChatInfoApi { + errMsg: string; + result: number; + tmpChatInfo?: TmpChatInfo; +} + +export interface TmpChatInfo { + chatType: number; + fromNick: string; + groupCode: string; + peerUid: string; + sessionType: number; + sig: string; +} + export interface NodeIKernelMsgService { generateMsgUniqueId(chatType: number, time: string): string; @@ -97,8 +112,8 @@ export interface NodeIKernelMsgService { recallMsg(...args: unknown[]): unknown; reeditRecallMsg(...args: unknown[]): unknown; - - forwardMsg(...args: unknown[]): Promise; + //调用请检查除开commentElements其余参数不能为null + forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise; forwardMsgWithComment(...args: unknown[]): unknown; @@ -156,6 +171,7 @@ export interface NodeIKernelMsgService { getAioFirstViewLatestMsgs(peer: Peer, num: number): unknown; + //deprecated 从9.9.15-26702版本开始,该接口已经废弃,请使用getMsgsEx getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise; getMsgsIncludeSelf(peer: Peer, msgId: string, count: number, queryOrder: boolean): Promise; //chattype,uid->Promise - getTempChatInfo(ChatType: number, Uid: string): unknown; + getTempChatInfo(ChatType: number, Uid: string): Promise; setContactLocalTop(...args: unknown[]): unknown; diff --git a/src/nwebui/Readme.md b/src/nwebui/Readme.md new file mode 100644 index 00000000..327e59ea --- /dev/null +++ b/src/nwebui/Readme.md @@ -0,0 +1,4 @@ +# NewWebui +基于Vue3实现的现代化轻量化NapCat管理面板 +## 进度 +画饼 \ No newline at end of file diff --git a/src/onebot11/action/extends/CreateCollection.ts b/src/onebot11/action/extends/CreateCollection.ts index df4245a6..199da51e 100644 --- a/src/onebot11/action/extends/CreateCollection.ts +++ b/src/onebot11/action/extends/CreateCollection.ts @@ -2,7 +2,6 @@ import { NTQQCollectionApi } from '@/core/apis/collection'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { selfInfo } from '@/core/data'; diff --git a/src/onebot11/action/extends/Debug.ts b/src/onebot11/action/extends/Debug.ts index 6f73ae5d..2cac40da 100644 --- a/src/onebot11/action/extends/Debug.ts +++ b/src/onebot11/action/extends/Debug.ts @@ -1,16 +1,12 @@ import BaseAction from '../BaseAction'; -// import * as ntqqApi from "../../../ntqqapi/api"; import { NTQQMsgApi, NTQQFriendApi, NTQQGroupApi, NTQQUserApi, NTQQFileApi, - // NTQQFileCacheApi, } from '@/core'; import { ActionName } from '../types'; -import { log, logDebug } from '@/common/utils/log'; - interface Payload { method: string, args: any[], @@ -20,12 +16,8 @@ export default class Debug extends BaseAction { actionName = ActionName.Debug; protected async _handle(payload: Payload): Promise { - //logDebug('debug call ntqq api', payload); - const ntqqApi = [NTQQMsgApi, NTQQFriendApi, NTQQGroupApi, NTQQUserApi, NTQQFileApi, - // NTQQFileCacheApi, - ]; + const ntqqApi = [NTQQMsgApi, NTQQFriendApi, NTQQGroupApi, NTQQUserApi, NTQQFileApi,]; for (const ntqqApiClass of ntqqApi) { - // logDebug('ntqqApiClass', ntqqApiClass); const method = (ntqqApiClass)[payload.method]; if (method) { const result = method(...payload.args); @@ -36,8 +28,5 @@ export default class Debug extends BaseAction { } } throw `${payload.method}方法 不存在`; - - // const info = await NTQQApi.getUserDetailInfo(friends[0].uid); - // return info } } diff --git a/src/onebot11/action/extends/FetchEmojioLike.ts b/src/onebot11/action/extends/FetchEmojioLike.ts index baf43dc4..48a78eee 100644 --- a/src/onebot11/action/extends/FetchEmojioLike.ts +++ b/src/onebot11/action/extends/FetchEmojioLike.ts @@ -24,9 +24,9 @@ export class FetchEmojioLike extends BaseAction { PayloadSchema = SchemaData; protected async _handle(payload: Payload) { const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); - if(!msgIdPeer) throw new Error('消息不存在'); + if (!msgIdPeer) throw new Error('消息不存在'); const msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0]; - const ret = await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer,msg.msgSeq,payload.emojiId,payload.emojiType,payload.count); + const ret = await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, payload.count); return ret; } } diff --git a/src/onebot11/action/extends/GetCollectionList.ts b/src/onebot11/action/extends/GetCollectionList.ts index b768d555..de6add8a 100644 --- a/src/onebot11/action/extends/GetCollectionList.ts +++ b/src/onebot11/action/extends/GetCollectionList.ts @@ -2,9 +2,7 @@ import { NTQQCollectionApi } from '@/core/apis/collection'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; -import { selfInfo } from '@/core/data'; const SchemaData = { type: 'object', diff --git a/src/onebot11/action/extends/GetRobotUinRange.ts b/src/onebot11/action/extends/GetRobotUinRange.ts index d5b85aba..2d67d136 100644 --- a/src/onebot11/action/extends/GetRobotUinRange.ts +++ b/src/onebot11/action/extends/GetRobotUinRange.ts @@ -5,7 +5,6 @@ export class GetRobotUinRange extends BaseAction> { actionName = ActionName.GetRobotUinRange; protected async _handle(payload: void) { - // console.log(await NTQQUserApi.getRobotUinRange()); return await NTQQUserApi.getRobotUinRange(); } } diff --git a/src/onebot11/action/extends/OCRImage.ts b/src/onebot11/action/extends/OCRImage.ts index 8128fe4e..023c254d 100644 --- a/src/onebot11/action/extends/OCRImage.ts +++ b/src/onebot11/action/extends/OCRImage.ts @@ -20,7 +20,7 @@ export class OCRImage extends BaseAction { actionName = ActionName.OCRImage; PayloadSchema = SchemaData; protected async _handle(payload: Payload) { - const { path, isLocal, errMsg,success } = (await uri2local(payload.image)); + const { path, isLocal, errMsg, success } = (await uri2local(payload.image)); if (!success) { throw `OCR ${payload.image}失败,image字段可能格式不正确`; } diff --git a/src/onebot11/action/extends/SetGroupHeader.ts b/src/onebot11/action/extends/SetGroupHeader.ts index 1998301b..312b92f1 100644 --- a/src/onebot11/action/extends/SetGroupHeader.ts +++ b/src/onebot11/action/extends/SetGroupHeader.ts @@ -1,10 +1,8 @@ import BaseAction from '../BaseAction'; import { ActionName, BaseCheckResult } from '../types'; import * as fs from 'node:fs'; -import { NTQQUserApi } from '@/core/apis/user'; import { checkFileReceived, uri2local } from '@/common/utils/file'; import { NTQQGroupApi } from '@/core'; -// import { log } from "../../../common/utils"; interface Payload { file: string, diff --git a/src/onebot11/action/extends/SetLongNick.ts b/src/onebot11/action/extends/SetLongNick.ts index 2f1f8c5d..1362996a 100644 --- a/src/onebot11/action/extends/SetLongNick.ts +++ b/src/onebot11/action/extends/SetLongNick.ts @@ -1,4 +1,3 @@ - import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { NTQQUserApi } from '@/core/apis'; diff --git a/src/onebot11/action/extends/SetOnlineStatus.ts b/src/onebot11/action/extends/SetOnlineStatus.ts index c06a2292..76253fe6 100644 --- a/src/onebot11/action/extends/SetOnlineStatus.ts +++ b/src/onebot11/action/extends/SetOnlineStatus.ts @@ -1,5 +1,5 @@ import BaseAction from '../BaseAction'; -import { ActionName, BaseCheckResult } from '../types'; +import { ActionName } from '../types'; import { NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; // 设置在线状态 @@ -20,12 +20,6 @@ export class SetOnlineStatus extends BaseAction { actionName = ActionName.SetOnlineStatus; PayloadSchema = SchemaData; protected async _handle(payload: Payload) { - // 可设置状态 - // { status: 10, extStatus: 1027, batteryStatus: 0 } - // { status: 30, extStatus: 0, batteryStatus: 0 } - // { status: 50, extStatus: 0, batteryStatus: 0 } - // { status: 60, extStatus: 0, batteryStatus: 0 } - // { status: 70, extStatus: 0, batteryStatus: 0 } const ret = await NTQQUserApi.setSelfOnlineStatus(payload.status, payload.extStatus, payload.batteryStatus); if (ret.result !== 0) { throw new Error('设置在线状态失败'); diff --git a/src/onebot11/action/extends/SetQQAvatar.ts b/src/onebot11/action/extends/SetQQAvatar.ts index f8006344..dc084a5f 100644 --- a/src/onebot11/action/extends/SetQQAvatar.ts +++ b/src/onebot11/action/extends/SetQQAvatar.ts @@ -3,7 +3,6 @@ import { ActionName, BaseCheckResult } from '../types'; import * as fs from 'node:fs'; import { NTQQUserApi } from '@/core/apis/user'; import { checkFileReceived, uri2local } from '@/common/utils/file'; -// import { log } from "../../../common/utils"; interface Payload { file: string @@ -24,7 +23,7 @@ export default class SetAvatar extends BaseAction { }; } protected async _handle(payload: Payload): Promise { - const { path, isLocal, errMsg,success } = (await uri2local(payload.file)); + const { path, isLocal, errMsg, success } = (await uri2local(payload.file)); if (!success) { throw `头像${payload.file}设置失败,file字段可能格式不正确`; } diff --git a/src/onebot11/action/extends/TestApi01.ts b/src/onebot11/action/extends/TestApi01.ts index 566d63d2..224fde82 100644 --- a/src/onebot11/action/extends/TestApi01.ts +++ b/src/onebot11/action/extends/TestApi01.ts @@ -18,9 +18,7 @@ export default class TestApi01 extends BaseAction { actionName = ActionName.TestApi01; // 用不着复杂检测 protected async check(payload: Payload): Promise { - return { - valid: true, - }; + return { valid: true }; } protected async _handle(payload: Payload): Promise { return await napCatCore.session.getMsgService().sendSsoCmdReqByContend(payload.cmd, payload.param); diff --git a/src/onebot11/action/extends/TranslateEnWordToZn.ts b/src/onebot11/action/extends/TranslateEnWordToZn.ts index 8088ab6d..4c3a5f94 100644 --- a/src/onebot11/action/extends/TranslateEnWordToZn.ts +++ b/src/onebot11/action/extends/TranslateEnWordToZn.ts @@ -1,9 +1,7 @@ import BaseAction from '../BaseAction'; -import { ActionName, BaseCheckResult } from '../types'; -import { NTQQSystemApi, NTQQUserApi } from '@/core/apis'; +import { ActionName } from '../types'; +import { NTQQSystemApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; -import Ajv from 'ajv'; -// 设置在线状态 const SchemaData = { type: 'object', diff --git a/src/onebot11/action/file/DelGroupFile.ts b/src/onebot11/action/file/DelGroupFile.ts index 498cfe13..5b7c080e 100644 --- a/src/onebot11/action/file/DelGroupFile.ts +++ b/src/onebot11/action/file/DelGroupFile.ts @@ -1,7 +1,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis'; +import { NTQQGroupApi } from '@/core/apis'; const SchemaData = { type: 'object', diff --git a/src/onebot11/action/file/GetFile.ts b/src/onebot11/action/file/GetFile.ts index 85672682..12dc23aa 100644 --- a/src/onebot11/action/file/GetFile.ts +++ b/src/onebot11/action/file/GetFile.ts @@ -2,7 +2,7 @@ import BaseAction from '../BaseAction'; import fs from 'fs/promises'; import { ob11Config } from '@/onebot11/config'; import { UUIDConverter } from '@/common/utils/helper'; -import { ActionName, BaseCheckResult } from '../types'; +import { ActionName } from '../types'; import { ChatType, ElementType, FileElement, Peer, RawMessage, VideoElement } from '@/core/entities'; import { NTQQFileApi, NTQQFriendApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; diff --git a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts index 375aefd1..52665f82 100644 --- a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts +++ b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts @@ -24,12 +24,12 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction { actionName = ActionName.GoCQHTTP_GetForwardMsg; PayloadSchema = SchemaData; protected async _handle(payload: Payload): Promise { - const msgId = payload.message_id || payload.id; - if (!msgId) { - throw Error('message_id is required'); + const msgIdMixOb11Id = payload.message_id || payload.id; + if (!msgIdMixOb11Id) { + throw Error('message_id or id is required'); } - const rootMsgId = MessageUnique.getShortIdByMsgId(msgId); - const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId || parseInt(msgId)); + const rootMsgId = MessageUnique.getShortIdByMsgId(msgIdMixOb11Id); + const rootMsg = MessageUnique.getMsgIdAndPeerByShortId(rootMsgId || parseInt(msgIdMixOb11Id)); if (!rootMsg) { throw Error('msg not found'); } @@ -40,7 +40,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction { const msgList = data.msgList; const messages = await Promise.all(msgList.map(async msg => { const resMsg = await OB11Constructor.message(msg); - resMsg.message_id = await MessageUnique.createMsg({ guildId:'',chatType:msg.chatType,peerUid:msg.peerUid },msg.msgId)!; + resMsg.message_id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId)!; return resMsg; })); messages.map(msg => { diff --git a/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts index 3ca15764..aba282a2 100644 --- a/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts +++ b/src/onebot11/action/go-cqhttp/GetFriendMsgHistory.ts @@ -50,6 +50,7 @@ export default class GetFriendMsgHistory extends BaseAction { await Promise.all(msgList.map(async msg => { msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId); })); + //转换消息 const ob11MsgList = await Promise.all(msgList.map(msg => OB11Constructor.message(msg))); return { 'messages': ob11MsgList }; diff --git a/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts b/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts index 2d84f476..07d78bf5 100644 --- a/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts +++ b/src/onebot11/action/go-cqhttp/GetGroupHonorInfo.ts @@ -6,7 +6,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { type: 'object', properties: { - group_id: { type: [ 'number' , 'string' ] }, + group_id: { type: ['number', 'string'] }, type: { enum: [WebHonorType.ALL, WebHonorType.EMOTION, WebHonorType.LEGEND, WebHonorType.PERFROMER, WebHonorType.STORONGE_NEWBI, WebHonorType.TALKACTIVE] } }, required: ['group_id'] diff --git a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts index b7f1c223..812757f7 100644 --- a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts @@ -44,7 +44,6 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction { if (PublishGroupBulletinResult.result != 0) { throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`; } - // 下面实现扬了 - //await WebApi.setGroupNotice(payload.group_id, payload.content) ; return null; } } diff --git a/src/onebot11/action/go-cqhttp/UploadGroupFile.ts b/src/onebot11/action/go-cqhttp/UploadGroupFile.ts index d00895db..5382227b 100644 --- a/src/onebot11/action/go-cqhttp/UploadGroupFile.ts +++ b/src/onebot11/action/go-cqhttp/UploadGroupFile.ts @@ -4,7 +4,7 @@ import { ActionName } from '../types'; import { SendMsgElementConstructor } from '@/core/entities/constructor'; import { ChatType, SendFileElement } from '@/core/entities'; import fs from 'fs'; -import { SendMsg, sendMsg } from '@/onebot11/action/msg/SendMsg'; +import { sendMsg } from '@/onebot11/action/msg/SendMsg'; import { uri2local } from '@/common/utils/file'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { diff --git a/src/onebot11/action/go-cqhttp/UploadPrivareFile.ts b/src/onebot11/action/go-cqhttp/UploadPrivareFile.ts index 853ca721..d4aa51ab 100644 --- a/src/onebot11/action/go-cqhttp/UploadPrivareFile.ts +++ b/src/onebot11/action/go-cqhttp/UploadPrivareFile.ts @@ -1,10 +1,9 @@ import BaseAction from '../BaseAction'; -import { getGroup } from '@/core/data'; import { ActionName } from '../types'; import { SendMsgElementConstructor } from '@/core/entities/constructor'; import { ChatType, Peer, SendFileElement } from '@/core/entities'; import fs from 'fs'; -import { SendMsg, sendMsg } from '@/onebot11/action/msg/SendMsg'; +import { sendMsg } from '@/onebot11/action/msg/SendMsg'; import { uri2local } from '@/common/utils/file'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { NTQQFriendApi, NTQQUserApi } from '@/core'; diff --git a/src/onebot11/action/group/GetGroupEssence.ts b/src/onebot11/action/group/GetGroupEssence.ts index 7e90d6fc..7393efb1 100644 --- a/src/onebot11/action/group/GetGroupEssence.ts +++ b/src/onebot11/action/group/GetGroupEssence.ts @@ -1,9 +1,5 @@ -import { getGroup } from '@/core/data'; -import { OB11Group } from '../../types'; -import { OB11Constructor } from '../../constructor'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { NTQQMsgApi } from '@/core/apis/msg'; import { GroupEssenceMsgRet, WebApi } from '@/core/apis/webapi'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; diff --git a/src/onebot11/action/group/GetGroupList.ts b/src/onebot11/action/group/GetGroupList.ts index 396649ff..d5cebb4c 100644 --- a/src/onebot11/action/group/GetGroupList.ts +++ b/src/onebot11/action/group/GetGroupList.ts @@ -5,7 +5,6 @@ import { ActionName } from '../types'; import { NTQQGroupApi } from '@/core/apis'; import { Group } from '@/core/entities'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; -// no_cache get时传字符串 const SchemaData = { type: 'object', properties: { diff --git a/src/onebot11/action/group/SetEssenceMsg.ts b/src/onebot11/action/group/SetEssenceMsg.ts index b8cb2f45..3ee19661 100644 --- a/src/onebot11/action/group/SetEssenceMsg.ts +++ b/src/onebot11/action/group/SetEssenceMsg.ts @@ -1,7 +1,7 @@ import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; -import { NTQQGroupApi, NTQQMsgApi } from '@/core'; +import { NTQQGroupApi } from '@/core'; import { MessageUnique } from '@/common/utils/MessageUnique'; const SchemaData = { @@ -18,7 +18,7 @@ export default class SetEssenceMsg extends BaseAction { actionName = ActionName.SetEssenceMsg; PayloadSchema = SchemaData; protected async _handle(payload: Payload): Promise { - const msg = await MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); + const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); if (!msg) { throw new Error('msg not found'); } diff --git a/src/onebot11/action/group/SetGroupAddRequest.ts b/src/onebot11/action/group/SetGroupAddRequest.ts index 3f079ff1..484a8090 100644 --- a/src/onebot11/action/group/SetGroupAddRequest.ts +++ b/src/onebot11/action/group/SetGroupAddRequest.ts @@ -9,7 +9,7 @@ const SchemaData = { properties: { flag: { type: 'string' }, approve: { type: ['string', 'boolean'] }, - reason: { type: 'string', nullable: true, } + reason: { type: 'string', nullable: true } }, required: ['flag'], } as const satisfies JSONSchema; @@ -24,7 +24,7 @@ export default class SetGroupAddRequest extends BaseAction { const approve = payload.approve?.toString() !== 'false'; await NTQQGroupApi.handleGroupRequest(flag, approve ? GroupRequestOperateTypes.approve : GroupRequestOperateTypes.reject, - payload.reason + payload.reason || '' ); return null; } diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index f4df4ea3..4e33eaf9 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -35,9 +35,7 @@ import SetGroupCard from './group/SetGroupCard'; import GetImage from './file/GetImage'; import GetRecord from './file/GetRecord'; import { GoCQHTTPMarkMsgAsRead, MarkAllMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead'; -import CleanCache from './system/CleanCache'; import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile'; -import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config'; import GetGroupAddRequest from '@/onebot11/action/extends/GetGroupAddRequest'; import SetQQAvatar from '@/onebot11/action/extends/SetQQAvatar'; import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile'; diff --git a/src/onebot11/action/msg/DeleteMsg.ts b/src/onebot11/action/msg/DeleteMsg.ts index f180329c..3fd3f015 100644 --- a/src/onebot11/action/msg/DeleteMsg.ts +++ b/src/onebot11/action/msg/DeleteMsg.ts @@ -28,20 +28,20 @@ class DeleteMsg extends BaseAction { protected async _handle(payload: Payload) { const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id)); if (msg) { - let ret = NTEventDispatch.RegisterListen - ( - 'NodeIKernelMsgListener/onMsgInfoListUpdate', - 1, - 5000, - (msgs) => { - if (msgs.find(m => m.msgId === msg.MsgId && m.recallTime !== '0')) { - return true; - } - return false; + const ret = NTEventDispatch.RegisterListen + ( + 'NodeIKernelMsgListener/onMsgInfoListUpdate', + 1, + 5000, + (msgs) => { + if (msgs.find(m => m.msgId === msg.MsgId && m.recallTime !== '0')) { + return true; } - ).catch(e => new Promise((resolve, reject) => { resolve(undefined) })); + return false; + } + ).catch(e => new Promise((resolve, reject) => { resolve(undefined); })); await NTQQMsgApi.recallMsg(msg.Peer, [msg.MsgId]); - let data = await ret; + const data = await ret; if (!data) { throw new Error('Recall failed'); } diff --git a/src/onebot11/action/msg/ForwardSingleMsg.ts b/src/onebot11/action/msg/ForwardSingleMsg.ts index 1c200437..1d13c0c6 100644 --- a/src/onebot11/action/msg/ForwardSingleMsg.ts +++ b/src/onebot11/action/msg/ForwardSingleMsg.ts @@ -30,7 +30,7 @@ class ForwardSingleMsg extends BaseAction { } protected async _handle(payload: Payload): Promise { - const msg = await MessageUnique.getMsgIdAndPeerByShortId(payload.message_id); + const msg = MessageUnique.getMsgIdAndPeerByShortId(payload.message_id); if (!msg) { throw new Error(`无法找到消息${payload.message_id}`); } diff --git a/src/onebot11/action/msg/GetMsg.ts b/src/onebot11/action/msg/GetMsg.ts index 29edde9e..d9c6c54b 100644 --- a/src/onebot11/action/msg/GetMsg.ts +++ b/src/onebot11/action/msg/GetMsg.ts @@ -27,8 +27,8 @@ class GetMsg extends BaseAction { if (!payload.message_id) { throw Error('参数message_id不能为空'); } - const MsgShortId = await MessageUnique.getShortIdByMsgId(payload.message_id.toString()); - const msgIdWithPeer = await MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString())); + const MsgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString()); + const msgIdWithPeer = MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString())); if (!msgIdWithPeer) { throw ('消息不存在'); } diff --git a/src/onebot11/action/msg/SendMsg/create-send-elements.ts b/src/onebot11/action/msg/SendMsg/create-send-elements.ts index e23b0356..accc3ed7 100644 --- a/src/onebot11/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot11/action/msg/SendMsg/create-send-elements.ts @@ -18,7 +18,7 @@ import { uri2local } from '@/common/utils/file'; import { ob11Config } from '@/onebot11/config'; import { RequestUtil } from '@/common/utils/request'; import { MessageUnique } from '@/common/utils/MessageUnique'; -console.log(process.pid) +console.log(process.pid); export type MessageContext = { deleteAfterSentFiles: string[], peer:Peer diff --git a/src/onebot11/action/msg/SendMsg/handle-forward-node.ts b/src/onebot11/action/msg/SendMsg/handle-forward-node.ts index c01c26e0..7aeab575 100644 --- a/src/onebot11/action/msg/SendMsg/handle-forward-node.ts +++ b/src/onebot11/action/msg/SendMsg/handle-forward-node.ts @@ -51,24 +51,24 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag } else { // 自定义的消息 try { - let OB11Data = normalize(messageNode.data.content); + const OB11Data = normalize(messageNode.data.content); //筛选node消息 - let isNodeMsg = OB11Data.filter(e => e.type === OB11MessageDataType.node).length;//找到子转发消息 + const isNodeMsg = OB11Data.filter(e => e.type === OB11MessageDataType.node).length;//找到子转发消息 if (isNodeMsg !== 0) { if (isNodeMsg !== OB11Data.length) { logError('子消息中包含非node消息 跳过不合法部分'); continue; } const nodeMsg = await handleForwardNode(selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node)); - if (nodeMsg) { nodeMsgIds.push(nodeMsg.msgId); MessageUnique.createMsg(selfPeer, nodeMsg.msgId) }; + if (nodeMsg) { nodeMsgIds.push(nodeMsg.msgId); MessageUnique.createMsg(selfPeer, nodeMsg.msgId); } //完成子卡片生成跳过后续 continue; } const { sendElements } = await createSendElements(OB11Data, destPeer); //拆分消息 - let MixElement = sendElements.filter(element => element.elementType !== ElementType.FILE && element.elementType !== ElementType.VIDEO); - let SingleElement = sendElements.filter(element => element.elementType === ElementType.FILE || element.elementType === ElementType.VIDEO).map(e => [e]); - let AllElement: SendMessageElement[][] = [MixElement, ...SingleElement].filter(e => e !== undefined && e.length !== 0); + const MixElement = sendElements.filter(element => element.elementType !== ElementType.FILE && element.elementType !== ElementType.VIDEO); + const SingleElement = sendElements.filter(element => element.elementType === ElementType.FILE || element.elementType === ElementType.VIDEO).map(e => [e]); + const AllElement: SendMessageElement[][] = [MixElement, ...SingleElement].filter(e => e !== undefined && e.length !== 0); const MsgNodeList: Promise[] = []; for (const sendElementsSplitElement of AllElement) { - MsgNodeList.push(sendMsg(selfPeer, sendElementsSplitElement, [], true).catch(e => new Promise((resolve, reject) => { resolve(undefined) }))); + MsgNodeList.push(sendMsg(selfPeer, sendElementsSplitElement, [], true).catch(e => new Promise((resolve, reject) => { resolve(undefined); }))); } (await Promise.allSettled(MsgNodeList)).map((result) => { if (result.status === 'fulfilled' && result.value) { @@ -85,7 +85,7 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag let srcPeer: Peer | undefined = undefined; let needSendSelf = false; //检测是否处于同一个Peer 不在同一个peer则全部消息由自身发送 - for (let msgId of nodeMsgIds) { + for (const msgId of nodeMsgIds) { const nodeMsgPeer = MessageUnique.getPeerByMsgId(msgId); if (!nodeMsgPeer) { logError('转发消息失败,未找到消息', msgId); diff --git a/src/onebot11/action/msg/SendMsg/index.ts b/src/onebot11/action/msg/SendMsg/index.ts index 94255d01..fdf2f600 100644 --- a/src/onebot11/action/msg/SendMsg/index.ts +++ b/src/onebot11/action/msg/SendMsg/index.ts @@ -67,7 +67,7 @@ export async function sendMsg(peer: Peer, sendElements: SendMessageElement[], de } const returnMsg = await NTQQMsgApi.sendMsg(peer, sendElements, waitComplete, timeout); try { - returnMsg!.id = await MessageUnique.createMsg({ chatType: peer.chatType, guildId: '', peerUid: peer.peerUid }, returnMsg!.msgId); + returnMsg!.id = MessageUnique.createMsg({ chatType: peer.chatType, guildId: '', peerUid: peer.peerUid }, returnMsg!.msgId); } catch (e: any) { logDebug('发送消息id获取失败', e); returnMsg!.id = 0; @@ -94,7 +94,8 @@ async function createContext(payload: OB11PostSendMsg, contextMode: ContextMode) //console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy); return { chatType: isBuddy ? ChatType.friend : ChatType.temp, - peerUid: Uid! + peerUid: Uid!, + guildId: payload.group_id || ''//临时主动发起时需要传入群号 }; } throw '请指定 group_id 或 user_id'; diff --git a/src/onebot11/action/msg/SendPrivateMsg.ts b/src/onebot11/action/msg/SendPrivateMsg.ts index 7c5cd7e3..b198b090 100644 --- a/src/onebot11/action/msg/SendPrivateMsg.ts +++ b/src/onebot11/action/msg/SendPrivateMsg.ts @@ -11,5 +11,4 @@ class SendPrivateMsg extends SendMsg { return super.check(payload); } } - export default SendPrivateMsg; diff --git a/src/onebot11/action/msg/SetMsgEmojiLike.ts b/src/onebot11/action/msg/SetMsgEmojiLike.ts index edb8edcc..f44313ab 100644 --- a/src/onebot11/action/msg/SetMsgEmojiLike.ts +++ b/src/onebot11/action/msg/SetMsgEmojiLike.ts @@ -14,7 +14,6 @@ const SchemaData = { } as const satisfies JSONSchema; type Payload = FromSchema; - export class SetMsgEmojiLike extends BaseAction { actionName = ActionName.SetMsgEmojiLike; PayloadSchema = SchemaData; diff --git a/src/onebot11/action/system/CanSendImage.ts b/src/onebot11/action/system/CanSendImage.ts index 459c3e66..683e69fb 100644 --- a/src/onebot11/action/system/CanSendImage.ts +++ b/src/onebot11/action/system/CanSendImage.ts @@ -4,7 +4,6 @@ import CanSendRecord from './CanSendRecord'; interface ReturnType { yes: boolean } - export default class CanSendImage extends CanSendRecord { actionName = ActionName.CanSendImage; } diff --git a/src/onebot11/action/system/GetLoginInfo.ts b/src/onebot11/action/system/GetLoginInfo.ts index 7d43d3b7..4b3ceca9 100644 --- a/src/onebot11/action/system/GetLoginInfo.ts +++ b/src/onebot11/action/system/GetLoginInfo.ts @@ -3,8 +3,6 @@ import { OB11User } from '../../types'; import { OB11Constructor } from '../../constructor'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { napCatCore } from '@/core'; - class GetLoginInfo extends BaseAction { actionName = ActionName.GetLoginInfo; diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index 7925a944..424a395e 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -15,8 +15,8 @@ export interface InvalidCheckResult { export enum ActionName { // 以下为扩展napcat扩展 - SharePeer = 'ArkShareGroup', - ShareGroupEx = 'ArkSharePeer', + SharePeer = 'ArkSharePeer', + ShareGroupEx = 'ArkShareGroupEx', RebootNormal = 'reboot_normal',//无快速登录重新启动 GetRobotUinRange = 'get_robot_uin_range', SetOnlineStatus = 'set_online_status', diff --git a/src/onebot11/action/user/GetFriendList.ts b/src/onebot11/action/user/GetFriendList.ts index e72eaa31..250ffa37 100644 --- a/src/onebot11/action/user/GetFriendList.ts +++ b/src/onebot11/action/user/GetFriendList.ts @@ -6,8 +6,6 @@ import { ActionName } from '../types'; import { NTQQFriendApi } from '@/core'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo'; - - // no_cache get时传字符串 const SchemaData = { type: 'object', diff --git a/src/onebot11/action/user/SendLike.ts b/src/onebot11/action/user/SendLike.ts index a3197523..545889ab 100644 --- a/src/onebot11/action/user/SendLike.ts +++ b/src/onebot11/action/user/SendLike.ts @@ -13,7 +13,6 @@ const SchemaData = { } as const satisfies JSONSchema; type Payload = FromSchema; - export default class SendLike extends BaseAction { actionName = ActionName.SendLike; PayloadSchema = SchemaData; diff --git a/src/onebot11/config.ts b/src/onebot11/config.ts index 9ff7b4e9..3a3c5480 100644 --- a/src/onebot11/config.ts +++ b/src/onebot11/config.ts @@ -1,10 +1,4 @@ -import fs from 'node:fs'; -import path from 'node:path'; -import { selfInfo } from '@/core/data'; -import { logDebug, logError } from '@/common/utils/log'; import { ConfigBase } from '@/common/utils/ConfigBase'; -import { json } from 'stream/consumers'; - export interface OB11Config { http: { enable: boolean; @@ -36,7 +30,7 @@ export interface OB11Config { Record: boolean, RecordList: Array }, - read(): OB11Config; + read(): OB11Config | null; save(config: OB11Config): void; } diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 1a2479df..263cfc9f 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -12,6 +12,7 @@ import { import { AtType, ChatType, + ChatType2, FaceIndex, Friend, FriendV2, @@ -42,7 +43,7 @@ import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent'; import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'; import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'; import { ob11Config } from '@/onebot11/config'; -import { deleteGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data'; +import { deleteGroup, getGroupMember, groupMembers, selfInfo } from '@/core/data'; import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis'; import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent'; import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'; @@ -96,11 +97,15 @@ export class OB11Constructor { //const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!); //resMsg.sender.nickname = user.info.nick; } - else if (msg.chatType == ChatType.temp) { + else if (msg.chatType as unknown as ChatType2 == ChatType2.KCHATTYPETEMPC2CFROMGROUP) { resMsg.sub_type = 'group'; - const tempGroupCode = tempGroupCodeMap[msg.peerUin]; - if (tempGroupCode) { - resMsg.group_id = parseInt(tempGroupCode); + let ret = await NTQQMsgApi.getTempChatInfo(ChatType2.KCHATTYPETEMPC2CFROMGROUP, msg.senderUid); + if (ret.result === 0) { + resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode); + resMsg.sender.nickname = ret.tmpChatInfo!.fromNick; + } else { + resMsg.group_id = 284840486;//兜底数据 + resMsg.sender.nickname = "临时会话"; } } for (const element of msg.elements) { @@ -340,17 +345,17 @@ export class OB11Constructor { msg.parentMsgIdList.push(msg.msgId); //let parentMsgId = msg.parentMsgIdList[msg.parentMsgIdList.length - 2 < 0 ? 0 : msg.parentMsgIdList.length - 2]; //加入自身MsgId - let MultiMsgs = (await NTQQMsgApi.getMultiMsg(ParentMsgPeer, msg.parentMsgIdList[0], msg.msgId))?.msgList; + const MultiMsgs = (await NTQQMsgApi.getMultiMsg(ParentMsgPeer, msg.parentMsgIdList[0], msg.msgId))?.msgList; //拉取下级消息 if (!MultiMsgs) continue; //拉取失败则跳过 message_data['data']['content'] = []; - for (let MultiMsg of MultiMsgs) { + for (const MultiMsg of MultiMsgs) { //对每条拉取的消息传递ParentMsgPeer修正Peer MultiMsg.parentMsgPeer = ParentMsgPeer; MultiMsg.parentMsgIdList = msg.parentMsgIdList; MultiMsg.id = MessageUnique.createMsg(ParentMsgPeer, MultiMsg.msgId);//该ID仅用查看 无法调用 - let msgList = await OB11Constructor.message(MultiMsg); + const msgList = await OB11Constructor.message(MultiMsg); message_data['data']['content'].push(msgList); //console.log("合并消息", msgList); } @@ -496,12 +501,10 @@ export class OB11Constructor { const senderUin = emojiLikeData.gtip.qq.jp; const msgSeq = emojiLikeData.gtip.url.msgseq; const emojiId = emojiLikeData.gtip.face.id; - const replyMsgList = (await NTQQMsgApi.getMsgsBySeqAndCount({ chatType: ChatType.group, guildId: '', peerUid: msg.peerUid }, msgSeq, 1, true, true)).msgList; if (replyMsgList.length < 1) { return; } - console.log('表情回应消息', msgSeq, " 结算ID", replyMsgList[0].msgId); const replyMsg = replyMsgList[0]; return new OB11GroupMsgEmojiLikeEvent(parseInt(msg.peerUid), parseInt(senderUin), MessageUnique.getShortIdByMsgId(replyMsg?.msgId!)!, [{ emoji_id: emojiId, diff --git a/src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts b/src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts index a968de43..1d4ef6b8 100644 --- a/src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts +++ b/src/onebot11/event/notice/OB11GroupAdminNoticeEvent.ts @@ -2,5 +2,5 @@ import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent'; export class OB11GroupAdminNoticeEvent extends OB11GroupNoticeEvent { notice_type = 'group_admin'; - sub_type: 'set' | 'unset' = "set"; // "set" | "unset" + sub_type: 'set' | 'unset' = 'set'; // "set" | "unset" } \ No newline at end of file diff --git a/src/onebot11/event/notice/OB11InputStatusEvent.ts b/src/onebot11/event/notice/OB11InputStatusEvent.ts index ba255bc3..f9caadcd 100644 --- a/src/onebot11/event/notice/OB11InputStatusEvent.ts +++ b/src/onebot11/event/notice/OB11InputStatusEvent.ts @@ -3,7 +3,7 @@ import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent'; export class OB11InputStatusEvent extends OB11BaseNoticeEvent { notice_type = 'notify'; sub_type = 'input_status'; - status_text = "对方正在输入..." + status_text = '对方正在输入...'; eventType = 1; user_id = 0; constructor(user_id: number, eventType: number, status_text: string) { diff --git a/src/onebot11/log.ts b/src/onebot11/log.ts index f95d9870..addef7af 100644 --- a/src/onebot11/log.ts +++ b/src/onebot11/log.ts @@ -26,7 +26,7 @@ export async function logMessage(ob11Message: OB11Message) { if (ob11Message.message_type === 'group') { if (ob11Message.group_id == 284840486) { group = await getGroup(ob11Message.group_id!); - prefix += `转发消息[外部来源] `; + prefix += '转发消息[外部来源] '; } else { group = await getGroup(ob11Message.group_id!); prefix += `群[${group?.groupName}(${ob11Message.group_id})] `; diff --git a/src/onebot11/main.ts b/src/onebot11/main.ts index 196d272d..4fd75b8f 100644 --- a/src/onebot11/main.ts +++ b/src/onebot11/main.ts @@ -19,7 +19,7 @@ import { OB11Config, ob11Config } from '@/onebot11/config'; import { httpHeart, ob11HTTPServer } from '@/onebot11/server/http'; import { ob11WebsocketServer } from '@/onebot11/server/ws/WebsocketServer'; import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket'; -import { getGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data'; +import { getGroup, getGroupMember, groupMembers, selfInfo } from '@/core/data'; import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners'; import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest'; import { NTQQGroupApi, NTQQUserApi, WebApi } from '@/core/apis'; @@ -104,10 +104,10 @@ export class NapCatOnebot11 { toUin: string; } ) => { - let uin = await NTQQUserApi.getUinByUid(data.fromUin); + const uin = await NTQQUserApi.getUinByUid(data.fromUin); logNotice(`[输入状态] ${uin} ${data.statusText}`); postOB11Event(new OB11InputStatusEvent(parseInt(uin), data.eventType, data.statusText)); - } + }; msgListener.onRecvSysMsg = async (protobufData: number[]) => { // function buf2hex(buffer: Buffer) { // return [...new Uint8Array(buffer)] @@ -222,12 +222,13 @@ export class NapCatOnebot11 { selfInfo.online = false; }; msgListener.onTempChatInfoUpdate = (tempChatInfo: TempOnRecvParams) => { - if (tempChatInfo.sessionType == 1 && tempChatInfo.chatType == ChatType.temp) { - tempGroupCodeMap[tempChatInfo.peerUid] = tempChatInfo.groupCode; - } + // if (tempChatInfo.sessionType == 1 && tempChatInfo.chatType == ChatType.temp) { + // tempGroupCodeMap[tempChatInfo.peerUid] = tempChatInfo.groupCode; + // } // 临时会话更新 tempGroupCodeMap uid -> source/GroupCode }; msgListener.onRecvMsg = async (msg) => { + //console.log('ob11 onRecvMsg', JSON.stringify(msg, null, 2)); // logDebug('收到消息', msg); for (const m of msg) { @@ -253,7 +254,6 @@ export class NapCatOnebot11 { // console.log(ret); new Promise((resolve) => { m.id = MessageUnique.createMsg({ chatType: m.chatType, peerUid: m.peerUid, guildId: '' }, m.msgId); - console.log("消息接收 ", "MsgID", m.msgId, " ID", m.id, " MsgSeq", m.msgSeq, " Raw", m?.elements[0]?.textElement?.content); this.postReceiveMsg([m]).then().catch(logError); }).then(); } @@ -266,7 +266,6 @@ export class NapCatOnebot11 { //完成后再post OB11Constructor.message(msg).then((_msg) => { _msg.target_id = parseInt(msg.peerUin); - console.log("自身消息接收 ", "MsgID", msg.msgId, " MsgSeq", msg.msgSeq, " Raw", msg?.elements[0]?.textElement?.content); if (ob11Config.reportSelfMessage) { msg.id = MessageUnique.createMsg({ chatType: msg.chatType, peerUid: msg.peerUid, guildId: '' }, msg.msgId); this.postReceiveMsg([msg]).then().catch(logError); diff --git a/src/onebot11/version.ts b/src/onebot11/version.ts index 875bf1ac..863d5715 100644 --- a/src/onebot11/version.ts +++ b/src/onebot11/version.ts @@ -1 +1 @@ -export const version = '1.8.3'; +export const version = '1.8.4'; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 2f3f8108..bce290f8 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V1.8.3', 'napcat-update-button', 'secondary') + SettingButton('V1.8.4', 'napcat-update-button', 'secondary') ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 6ad4e27c..3ea4bfba 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -163,7 +163,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V1.8.3", "napcat-update-button", "secondary") + SettingButton("V1.8.4", "napcat-update-button", "secondary") ) ]), SettingList([ From c771d75a000d917e9cb99518d7b33719dc0a26df Mon Sep 17 00:00:00 2001 From: canxin121 Date: Fri, 9 Aug 2024 13:12:11 +0800 Subject: [PATCH 2/7] Fix typo in eventType field name --- src/onebot11/event/notice/OB11InputStatusEvent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/onebot11/event/notice/OB11InputStatusEvent.ts b/src/onebot11/event/notice/OB11InputStatusEvent.ts index f9caadcd..4374b87b 100644 --- a/src/onebot11/event/notice/OB11InputStatusEvent.ts +++ b/src/onebot11/event/notice/OB11InputStatusEvent.ts @@ -4,12 +4,12 @@ export class OB11InputStatusEvent extends OB11BaseNoticeEvent { notice_type = 'notify'; sub_type = 'input_status'; status_text = '对方正在输入...'; - eventType = 1; + event_type = 1; user_id = 0; constructor(user_id: number, eventType: number, status_text: string) { super(); this.user_id = user_id; - this.eventType = eventType; + this.event_type = eventType; this.status_text = status_text; } } From 15e94621402571283eede5f692a9428347fb5468 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: Fri, 9 Aug 2024 19:40:35 +0800 Subject: [PATCH 3/7] LICENSE: MPL2 To BSD --- LICENSE | 397 ++++---------------------------------------------------- 1 file changed, 24 insertions(+), 373 deletions(-) diff --git a/LICENSE b/LICENSE index a612ad98..e6643a73 100644 --- a/LICENSE +++ b/LICENSE @@ -1,373 +1,24 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. +BSD 2-Clause License + +Copyright (c) 2024, NapNeko + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 7117fae2b22b1b7560be2b8682964d269a6ea7ec 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: Fri, 9 Aug 2024 19:41:40 +0800 Subject: [PATCH 4/7] chore: wait for v2 --- docs/changelogs/CHANGELOG.v1.8.4.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 docs/changelogs/CHANGELOG.v1.8.4.md diff --git a/docs/changelogs/CHANGELOG.v1.8.4.md b/docs/changelogs/CHANGELOG.v1.8.4.md deleted file mode 100644 index e12a0206..00000000 --- a/docs/changelogs/CHANGELOG.v1.8.4.md +++ /dev/null @@ -1,12 +0,0 @@ -# v1.8.4 - -QQ Version: Windows 9.9.15-26702 / Linux 3.2.12-26702 - -## 启动的方式 -Way03/Way05 - -## 新增与调整 -1. 支持主动临时消息 - - -新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api) From 827df80ec8b812215b25bbaa19bb450aa3e21a10 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: Fri, 9 Aug 2024 20:34:31 +0800 Subject: [PATCH 5/7] fix: error --- src/onebot11/constructor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 263cfc9f..a01be057 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -228,7 +228,7 @@ export class OB11Constructor { const videoElement: VideoElement = element.videoElement; //读取视频链接并兜底 let videoUrl;//Array - if (msg.peerUin = '284840486') { + if (msg.peerUin == '284840486') { //合并消息内部 应该进行特殊处理 可能需要重写peer 待测试与研究 Mlikiowa Taged TODO } try { From 717b246cb66116aa1c976fc65dcfa0373428873d 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: Fri, 9 Aug 2024 21:38:36 +0800 Subject: [PATCH 6/7] release: 1.8.5 --- package.json | 2 +- src/onebot11/constructor.ts | 12 +++++++----- src/onebot11/version.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bd34fa80..987f9d38 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "1.8.4", + "version": "1.8.5", "scripts": { "watch:dev": "vite --mode development", "watch:prod": "vite --mode production", diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index a01be057..c1b6fa43 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -228,16 +228,18 @@ export class OB11Constructor { const videoElement: VideoElement = element.videoElement; //读取视频链接并兜底 let videoUrl;//Array + let peer:Peer = { + chatType: msg.chatType, + peerUid: msg.peerUid, + guildId: '0' + }; if (msg.peerUin == '284840486') { + peer = msg.parentMsgPeer; //合并消息内部 应该进行特殊处理 可能需要重写peer 待测试与研究 Mlikiowa Taged TODO } try { - videoUrl = await NTQQFileApi.getVideoUrl({ - chatType: msg.chatType, - peerUid: msg.peerUid, - guildId: '0' - }, msg.msgId, element.elementId); + videoUrl = await NTQQFileApi.getVideoUrl(peer, msg.msgId, element.elementId); } catch (error) { videoUrl = undefined; } diff --git a/src/onebot11/version.ts b/src/onebot11/version.ts index 863d5715..4446404f 100644 --- a/src/onebot11/version.ts +++ b/src/onebot11/version.ts @@ -1 +1 @@ -export const version = '1.8.4'; +export const version = '1.8.5'; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index bce290f8..8deb9045 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V1.8.4', 'napcat-update-button', 'secondary') + SettingButton('V1.8.5', 'napcat-update-button', 'secondary') ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 3ea4bfba..f66b64a4 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -163,7 +163,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V1.8.4", "napcat-update-button", "secondary") + SettingButton("V1.8.5", "napcat-update-button", "secondary") ) ]), SettingList([ From 6f6b258f22d7563f15d84e7172c4d4cbb547f47e 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: Fri, 9 Aug 2024 21:41:56 +0800 Subject: [PATCH 7/7] release: 1.8.6 --- package.json | 2 +- src/onebot11/action/group/SetGroupBan.ts | 7 ++----- src/onebot11/action/group/SetGroupKick.ts | 7 ++----- src/onebot11/version.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 987f9d38..7b379f8a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "1.8.5", + "version": "1.8.6", "scripts": { "watch:dev": "vite --mode development", "watch:prod": "vite --mode production", diff --git a/src/onebot11/action/group/SetGroupBan.ts b/src/onebot11/action/group/SetGroupBan.ts index 27155b46..19bcec5b 100644 --- a/src/onebot11/action/group/SetGroupBan.ts +++ b/src/onebot11/action/group/SetGroupBan.ts @@ -3,6 +3,7 @@ import { getGroupMember } from '@/core/data'; import { ActionName } from '../types'; import { NTQQGroupApi } from '@/core/apis/group'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; +import { NTQQUserApi } from '@/core'; const SchemaData = { type: 'object', @@ -20,12 +21,8 @@ export default class SetGroupBan extends BaseAction { actionName = ActionName.SetGroupBan; PayloadSchema = SchemaData; protected async _handle(payload: Payload): Promise { - const member = await getGroupMember(payload.group_id, payload.user_id); - if (!member) { - throw `群成员${payload.user_id}不存在`; - } await NTQQGroupApi.banMember(payload.group_id.toString(), - [{ uid: member.uid, timeStamp: parseInt(payload.duration.toString()) }]); + [{ uid: (await NTQQUserApi.getUidByUin(payload.user_id.toString()))!, timeStamp: parseInt(payload.duration.toString()) }]); return null; } } diff --git a/src/onebot11/action/group/SetGroupKick.ts b/src/onebot11/action/group/SetGroupKick.ts index 2af20234..fa8df27b 100644 --- a/src/onebot11/action/group/SetGroupKick.ts +++ b/src/onebot11/action/group/SetGroupKick.ts @@ -3,6 +3,7 @@ import { getGroupMember } from '@/core/data'; import { ActionName } from '../types'; import { NTQQGroupApi } from '@/core/apis/group'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; +import { NTQQUserApi } from '@/core'; const SchemaData = { @@ -21,12 +22,8 @@ export default class SetGroupKick extends BaseAction { actionName = ActionName.SetGroupKick; PayloadSchema = SchemaData; protected async _handle(payload: Payload): Promise { - const member = await getGroupMember(payload.group_id, payload.user_id); - if (!member) { - throw `群成员${payload.user_id}不存在`; - } const rejectReq = payload.reject_add_request?.toString() == 'true'; - await NTQQGroupApi.kickMember(payload.group_id.toString(), [member.uid], rejectReq); + await NTQQGroupApi.kickMember(payload.group_id.toString(), [(await NTQQUserApi.getUidByUin(payload.user_id.toString()))!], rejectReq); return null; } } diff --git a/src/onebot11/version.ts b/src/onebot11/version.ts index 4446404f..d8a11cba 100644 --- a/src/onebot11/version.ts +++ b/src/onebot11/version.ts @@ -1 +1 @@ -export const version = '1.8.5'; +export const version = '1.8.6'; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 8deb9045..d4fc4e37 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V1.8.5', 'napcat-update-button', 'secondary') + SettingButton('V1.8.6', 'napcat-update-button', 'secondary') ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index f66b64a4..4f95ade3 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -163,7 +163,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V1.8.5", "napcat-update-button", "secondary") + SettingButton("V1.8.6", "napcat-update-button", "secondary") ) ]), SettingList([