diff --git a/src/common/utils/legacyLog.ts b/src/common/utils/legacyLog.ts index 217c9e8..0010d2f 100644 --- a/src/common/utils/legacyLog.ts +++ b/src/common/utils/legacyLog.ts @@ -2,24 +2,7 @@ import fs from 'fs' import path from 'node:path' import { getConfigUtil } from '../config' import { LOG_DIR } from '../globalVars' -import { Dict } from 'cosmokit' - -function truncateString(obj: Dict | null, maxLength = 500) { - if (obj !== null && typeof obj === 'object') { - Object.keys(obj).forEach((key) => { - if (typeof obj[key] === 'string') { - // 如果是字符串且超过指定长度,则截断 - if (obj[key].length > maxLength) { - obj[key] = obj[key].substring(0, maxLength) + '...' - } - } else if (typeof obj[key] === 'object') { - // 如果是对象或数组,则递归调用 - truncateString(obj[key], maxLength) - } - }) - } - return obj -} +import { inspect } from 'node:util' export const logFileName = `llonebot-${new Date().toLocaleString('zh-CN')}.log`.replace(/\//g, '-').replace(/:/g, '-') @@ -29,9 +12,8 @@ export function log(...msg: unknown[]) { } let logMsg = '' for (const msgItem of msg) { - // 判断是否是对象 if (typeof msgItem === 'object') { - logMsg += JSON.stringify(truncateString(msgItem)) + ' ' + logMsg += inspect(msgItem, { depth: 10, compact: true, breakLength: Infinity }) + ' ' continue } logMsg += msgItem + ' ' diff --git a/src/ntqqapi/api/file.ts b/src/ntqqapi/api/file.ts index d2ff5af..5ec5d8e 100644 --- a/src/ntqqapi/api/file.ts +++ b/src/ntqqapi/api/file.ts @@ -16,7 +16,6 @@ import path from 'node:path' import { existsSync } from 'node:fs' import { ReceiveCmdS } from '../hook' import { RkeyManager } from '@/ntqqapi/helper/rkey' -import { getSession } from '@/ntqqapi/wrapper' import { OnRichMediaDownloadCompleteParams, Peer } from '@/ntqqapi/types/msg' import { calculateFileMD5 } from '@/common/utils/file' import { fileTypeFromFile } from 'file-type' @@ -39,39 +38,28 @@ export class NTQQFileApi extends Service { this.rkeyManager = new RkeyManager(ctx, 'https://llob.linyuchen.net/rkey') } - async getVideoUrl(peer: Peer, msgId: string, elementId: string) { - const session = getSession() - if (session) { - return (await session.getRichMediaService().getVideoPlayUrlV2( - peer, - msgId, - elementId, - 0, - { downSourceType: 1, triggerType: 1 } - )).urlResult.domainUrl[0]?.url - } else { - const data = await invoke('nodeIKernelRichMediaService/getVideoPlayUrlV2', [{ - peer, - msgId, - elemId: elementId, - videoCodecFormat: 0, - exParams: { - downSourceType: 1, - triggerType: 1 - }, - }, null]) - if (data.result !== 0) { - this.ctx.logger.warn('getVideoUrl', data) + async getVideoUrl(peer: Peer, msgId: string, elementId: string): Promise { + const data = await invoke('nodeIKernelRichMediaService/getVideoPlayUrlV2', [{ + peer, + msgId, + elemId: elementId, + videoCodecFormat: 0, + params: { + downSourceType: 1, + triggerType: 1 } - return data.urlResult.domainUrl[0]?.url + }]) + if (data.result !== 0) { + this.ctx.logger.warn('getVideoUrl', data) } + return data.urlResult.domainUrl[0]?.url } async getFileType(filePath: string) { return fileTypeFromFile(filePath) } - // 上传文件到QQ的文件夹 + /** 上传文件到 QQ 的文件夹 */ async uploadFile(filePath: string, elementType = ElementType.Pic, elementSubType = 0) { const fileMd5 = await calculateFileMD5(filePath) let fileName = path.basename(filePath) @@ -174,8 +162,8 @@ export class NTQQFileApi extends Service { if (url) { const parsedUrl = new URL(IMAGE_HTTP_HOST + url) //临时解析拼接 const imageAppid = parsedUrl.searchParams.get('appid') - const isNewPic = imageAppid && ['1406', '1407'].includes(imageAppid) - if (isNewPic) { + const isNTPic = imageAppid && ['1406', '1407'].includes(imageAppid) + if (isNTPic) { let rkey = parsedUrl.searchParams.get('rkey') if (rkey) { return IMAGE_HTTP_HOST_NT + url diff --git a/src/ntqqapi/api/friend.ts b/src/ntqqapi/api/friend.ts index fd65f5a..3c92ae3 100644 --- a/src/ntqqapi/api/friend.ts +++ b/src/ntqqapi/api/friend.ts @@ -1,8 +1,7 @@ -import { Friend, FriendV2, SimpleInfo, CategoryFriend, BuddyListReqType } from '../types' +import { Friend, SimpleInfo, CategoryFriend } from '../types' import { ReceiveCmdS } from '../hook' import { invoke, NTMethod, NTClass } from '../ntcall' import { getSession } from '@/ntqqapi/wrapper' -import { Dict, pick } from 'cosmokit' import { Service, Context } from 'cordis' declare module 'cordis' { @@ -60,7 +59,7 @@ export class NTQQFriendApi extends Service { } } - async getBuddyV2(refresh = false): Promise { + async getBuddyV2(refresh = false): Promise { const data = await invoke<{ buddyCategory: CategoryFriend[] userSimpleInfos: Record @@ -118,12 +117,7 @@ export class NTQQFriendApi extends Service { } async isBuddy(uid: string): Promise { - const session = getSession() - if (session) { - return session.getBuddyService().isBuddy(uid) - } else { - return await invoke('nodeIKernelBuddyService/isBuddy', [{ uid }, null]) - } + return await invoke('nodeIKernelBuddyService/isBuddy', [{ uid }]) } async getBuddyRecommendContact(uin: string) { diff --git a/src/ntqqapi/api/msg.ts b/src/ntqqapi/api/msg.ts index dfae31f..4207a10 100644 --- a/src/ntqqapi/api/msg.ts +++ b/src/ntqqapi/api/msg.ts @@ -27,17 +27,12 @@ export class NTQQMsgApi extends Service { } } - async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, setEmoji: boolean = true) { + async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, setEmoji: boolean) { // nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览 // nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid // 其实以官方文档为准是最好的,https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#EmojiType - const session = getSession() const emojiType = emojiId.length > 3 ? '2' : '1' - if (session) { - return session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiType, setEmoji) - } else { - return await invoke(NTMethod.EMOJI_LIKE, [{ peer, msgSeq, emojiId, emojiType, setEmoji }, null]) - } + return await invoke(NTMethod.EMOJI_LIKE, [{ peer, msgSeq, emojiId, emojiType, setEmoji }]) } async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) { @@ -58,59 +53,41 @@ export class NTQQMsgApi extends Service { } async getAioFirstViewLatestMsgs(peer: Peer, cnt: number) { - return await invoke('nodeIKernelMsgService/getAioFirstViewLatestMsgs', [{ peer, cnt }, null]) + return await invoke('nodeIKernelMsgService/getAioFirstViewLatestMsgs', [{ peer, cnt }]) } async getMsgsByMsgId(peer: Peer, msgIds: string[]) { if (!peer) throw new Error('peer is not allowed') if (!msgIds) throw new Error('msgIds is not allowed') - const session = getSession() - if (session) { - return session.getMsgService().getMsgsByMsgId(peer, msgIds) - } else { - return await invoke('nodeIKernelMsgService/getMsgsByMsgId', [{ peer, msgIds }, null]) - } + return await invoke('nodeIKernelMsgService/getMsgsByMsgId', [{ peer, msgIds }]) } async getMsgHistory(peer: Peer, msgId: string, cnt: number, isReverseOrder: boolean = false) { - const session = getSession() // 消息时间从旧到新 - if (session) { - return session.getMsgService().getMsgsIncludeSelf(peer, msgId, cnt, isReverseOrder) - } else { - return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder: isReverseOrder }, null]) - } + return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder: isReverseOrder }]) } async recallMsg(peer: Peer, msgIds: string[]) { - const session = getSession() - if (session) { - return session.getMsgService().recallMsg(peer, msgIds) - } else { - return await invoke(NTMethod.RECALL_MSG, [{ peer, msgIds }, null]) - } + return await invoke(NTMethod.RECALL_MSG, [{ peer, msgIds }]) } async sendMsg(peer: Peer, msgElements: SendMessageElement[], timeout = 10000) { - const msgId = await this.generateMsgUniqueId(peer.chatType) - peer.guildId = msgId + const uniqueId = await this.generateMsgUniqueId(peer.chatType) + peer.guildId = uniqueId const data = await invoke<{ msgList: RawMessage[] }>( 'nodeIKernelMsgService/sendMsg', - [ - { - msgId: '0', - peer, - msgElements, - msgAttributeInfos: new Map() - }, - null - ], + [{ + msgId: '0', + peer, + msgElements, + msgAttributeInfos: new Map() + }], { cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate', afterFirstCmd: false, cmdCB: payload => { for (const msgRecord of payload.msgList) { - if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) { + if (msgRecord.guildId === uniqueId && msgRecord.sendStatus === 2) { return true } } @@ -119,22 +96,35 @@ export class NTQQMsgApi extends Service { timeout } ) - return data.msgList.find(msgRecord => msgRecord.guildId === msgId) + return data.msgList.find(msgRecord => msgRecord.guildId === uniqueId) } async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) { - const session = getSession() - if (session) { - return session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], []) - } else { - return await invoke(NTMethod.FORWARD_MSG, [{ + const uniqueId = await this.generateMsgUniqueId(destPeer.chatType) + destPeer.guildId = uniqueId + const data = await invoke<{ msgList: RawMessage[] }>( + 'nodeIKernelMsgService/forwardMsg', + [{ msgIds, srcContact: srcPeer, dstContacts: [destPeer], commentElements: [], msgAttributeInfos: new Map(), - }, null]) - } + }], + { + cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate', + afterFirstCmd: false, + cmdCB: payload => { + for (const msgRecord of payload.msgList) { + if (msgRecord.guildId === uniqueId && msgRecord.sendStatus === 2) { + return true + } + } + return false + } + } + ) + return data.msgList.filter(msgRecord => msgRecord.guildId === uniqueId) } async multiForwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]): Promise { @@ -145,27 +135,24 @@ export class NTQQMsgApi extends Service { const selfUid = selfInfo.uid const data = await invoke<{ msgList: RawMessage[] }>( 'nodeIKernelMsgService/multiForwardMsgWithComment', - [ - { - msgInfos, - srcContact: srcPeer, - dstContact: destPeer, - commentElements: [], - msgAttributeInfos: new Map(), - }, - null, - ], + [{ + msgInfos, + srcContact: srcPeer, + dstContact: destPeer, + commentElements: [], + msgAttributeInfos: new Map(), + }], { cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate', afterFirstCmd: false, cmdCB: payload => { for (const msgRecord of payload.msgList) { - if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == selfUid) { + if (msgRecord.peerUid === destPeer.peerUid && msgRecord.senderUid === selfUid) { return true } } return false - }, + } } ) for (const msg of data.msgList) { @@ -174,10 +161,10 @@ export class NTQQMsgApi extends Service { continue } const forwardData = JSON.parse(arkElement.arkElement!.bytesData) - if (forwardData.app != 'com.tencent.multimsg') { + if (forwardData.app !== 'com.tencent.multimsg') { continue } - if (msg.peerUid == destPeer.peerUid && msg.senderUid == selfUid) { + if (msg.peerUid === destPeer.peerUid && msg.senderUid === selfUid) { return msg } } @@ -240,7 +227,7 @@ export class NTQQMsgApi extends Service { isIncludeCurrent: true, pageLimit: 1, } - }, null]) + }]) } async setMsgRead(peer: Peer) { @@ -254,7 +241,7 @@ export class NTQQMsgApi extends Service { emojiId, emojiType, cnt: count - }, null]) + }]) } async fetchFavEmojiList(count: number) { @@ -267,7 +254,8 @@ export class NTQQMsgApi extends Service { } async generateMsgUniqueId(chatType: number) { - const uniqueId = await invoke('nodeIKernelMsgService/generateMsgUniqueId', [{ chatType }]) + const time = await this.getServerTime() + const uniqueId = await invoke('nodeIKernelMsgService/generateMsgUniqueId', [{ chatType, time }]) if (typeof uniqueId === 'string') { return uniqueId } else { @@ -292,10 +280,15 @@ export class NTQQMsgApi extends Service { isIncludeCurrent: true, pageLimit: 1, } - }, null]) + }]) } getMsgTimeFromId(msgId: string) { + // 小概率相差1毫秒 return String(BigInt(msgId) >> 32n) } + + async getServerTime() { + return await invoke('nodeIKernelMSFService/getServerTime', [null]) + } } diff --git a/src/ntqqapi/api/user.ts b/src/ntqqapi/api/user.ts index ccea3ca..22cce9f 100644 --- a/src/ntqqapi/api/user.ts +++ b/src/ntqqapi/api/user.ts @@ -1,9 +1,9 @@ -import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg, UserDetailSource, ProfileBizType } from '../types' +import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfo, UserDetailSource, ProfileBizType, SimpleInfo } from '../types' import { invoke } from '../ntcall' import { getBuildVersion } from '@/common/utils' import { getSession } from '@/ntqqapi/wrapper' import { RequestUtil } from '@/common/utils/request' -import { Time } from 'cosmokit' +import { isNullable, Time } from 'cosmokit' import { Service, Context } from 'cordis' import { selfInfo } from '@/common/globalVars' @@ -34,17 +34,14 @@ export class NTQQUserApi extends Service { } async fetchUserDetailInfo(uid: string) { - const result = await invoke<{ info: UserDetailInfoListenerArg }>( + const result = await invoke<{ info: UserDetailInfo }>( 'nodeIKernelProfileService/fetchUserDetailInfo', - [ - { - callFrom: 'BuddyProfileStore', - uid: [uid], - source: UserDetailSource.KSERVER, - bizList: [ProfileBizType.KALL] - }, - null - ], + [{ + callFrom: 'BuddyProfileStore', + uid: [uid], + source: UserDetailSource.KSERVER, + bizList: [ProfileBizType.KALL] + }], { cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged', afterFirstCmd: false, @@ -70,13 +67,10 @@ export class NTQQUserApi extends Service { } const result = await invoke<{ info: User }>( 'nodeIKernelProfileService/getUserDetailInfoWithBizInfo', - [ - { - uid, - bizList: [0] - }, - null, - ], + [{ + uid, + bizList: [0] + }], { cbCmd: 'nodeIKernelProfileListener/onProfileDetailInfoChanged', afterFirstCmd: false, @@ -129,9 +123,7 @@ export class NTQQUserApi extends Service { } async getUidByUinV1(uin: string) { - const session = getSession() - // 通用转换开始尝试 - let uid = (await session?.getUixConvertService().getUid([uin]))?.uidInfo.get(uin) + let uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [uin] }])).uidInfo.get(uin) if (!uid) { for (const membersList of this.ctx.ntGroupApi.groupMembers.values()) { //从群友列表转 for (const member of membersList.values()) { @@ -181,20 +173,14 @@ export class NTQQUserApi extends Service { async getUserDetailInfoByUinV2(uin: string) { return await invoke( 'nodeIKernelProfileService/getUserDetailInfoByUin', - [ - { uin }, - null, - ], + [{ uin }] ) } async getUserDetailInfoByUin(uin: string) { return await invoke( 'nodeIKernelProfileService/getUserDetailInfoByUin', - [ - { uin }, - null, - ], + [{ uin }] ) } @@ -202,31 +188,21 @@ export class NTQQUserApi extends Service { const ret = await invoke('nodeIKernelUixConvertService/getUin', [{ uids: [uid] }]) let uin = ret.uinInfo.get(uid) if (!uin) { - uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换 + uin = (await this.getUserDetailInfo(uid)).uin } return uin } async getUinByUidV2(uid: string) { - const session = getSession() - if (session) { - let uin = (await session.getGroupService().getUinByUids([uid])).uins.get(uid) - if (uin) return uin - uin = (await session.getProfileService().getUinByUid('FriendsServiceImpl', [uid])).get(uid) - if (uin) return uin - uin = (await session.getUixConvertService().getUin([uid])).uinInfo.get(uid) - if (uin) return uin - } else { - let uin = (await invoke('nodeIKernelGroupService/getUinByUids', [{ uid: [uid] }])).uins.get(uid) - if (uin) return uin - uin = (await invoke('nodeIKernelProfileService/getUinByUid', [{ callFrom: 'FriendsServiceImpl', uid: [uid] }])).get(uid) - if (uin) return uin - uin = (await invoke('nodeIKernelUixConvertService/getUin', [{ uids: [uid] }])).uinInfo.get(uid) - if (uin) return uin - } - let uin = (await this.ctx.ntFriendApi.getBuddyIdMap(true)).get(uid) + let uin = (await invoke('nodeIKernelGroupService/getUinByUids', [{ uid: [uid] }])).uins.get(uid) if (uin) return uin - uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换 + uin = (await invoke('nodeIKernelProfileService/getUinByUid', [{ callFrom: 'FriendsServiceImpl', uid: [uid] }])).get(uid) + if (uin) return uin + uin = (await invoke('nodeIKernelUixConvertService/getUin', [{ uids: [uid] }])).uinInfo.get(uid) + if (uin) return uin + uin = (await this.ctx.ntFriendApi.getBuddyIdMap(true)).get(uid) + if (uin) return uin + uin = (await this.getUserDetailInfo(uid)).uin return uin } @@ -246,13 +222,10 @@ export class NTQQUserApi extends Service { } } - async getSelfNick(refresh = false) { + async getSelfNick(refresh = true) { if ((refresh || !selfInfo.nick) && selfInfo.uid) { - const userInfo = await this.getUserDetailInfo(selfInfo.uid) - if (userInfo) { - Object.assign(selfInfo, { nick: userInfo.nick }) - return userInfo.nick - } + const { profiles } = await this.getUserSimpleInfo(selfInfo.uid) + selfInfo.nick = profiles[selfInfo.uid].coreInfo.nick } return selfInfo.nick } @@ -281,4 +254,44 @@ export class NTQQUserApi extends Service { } }, null]) } + + async getUserSimpleInfo(uid: string, force = true) { + return await invoke<{ profiles: Record }>( + 'nodeIKernelProfileService/getUserSimpleInfo', + [{ + uids: [uid], + force + }], + { + cbCmd: 'onProfileSimpleChanged', + afterFirstCmd: false, + cmdCB: payload => !isNullable(payload.profiles[uid]), + } + ) + } + + async getCoreAndBaseInfo(uids: string[]) { + return await invoke( + 'nodeIKernelProfileService/getCoreAndBaseInfo', + [{ + uids, + callFrom: 'nodeStore' + }] + ) + } + + async getRobotUinRange() { + const data = await invoke( + 'nodeIKernelRobotService/getRobotUinRange', + [{ + req: { + justFetchMsgConfig: '1', + type: 1, + version: 0, + aioKeywordVersion: 0 + } + }] + ) + return data.response.robotUinRanges + } } diff --git a/src/ntqqapi/helper/rkey.ts b/src/ntqqapi/helper/rkey.ts index afd091b..726a009 100644 --- a/src/ntqqapi/helper/rkey.ts +++ b/src/ntqqapi/helper/rkey.ts @@ -31,30 +31,18 @@ export class RkeyManager { isExpired(): boolean { const now = new Date().getTime() / 1000 - // console.log(`now: ${now}, expired_time: ${this.rkeyData.expired_time}`) return now > this.rkeyData.expired_time } async refreshRkey() { - //刷新rkey this.rkeyData = await this.fetchServerRkey() } - async fetchServerRkey() { - return new Promise((resolve, reject) => { - fetch(this.serverUrl) - .then(response => { - if (!response.ok) { - return reject(response.statusText) // 请求失败,返回错误信息 - } - return response.json() // 解析 JSON 格式的响应体 - }) - .then(data => { - resolve(data) - }) - .catch(error => { - reject(error) - }) - }) + async fetchServerRkey(): Promise { + const response = await fetch(this.serverUrl) + if (!response.ok) { + throw new Error(response.statusText) + } + return response.json() } } diff --git a/src/ntqqapi/hook.ts b/src/ntqqapi/hook.ts index f973183..9e7ddea 100644 --- a/src/ntqqapi/hook.ts +++ b/src/ntqqapi/hook.ts @@ -26,7 +26,6 @@ export enum ReceiveCmdS { SELF_STATUS = 'nodeIKernelProfileListener/onSelfStatusChanged', CACHE_SCAN_FINISH = 'nodeIKernelStorageCleanListener/onFinishScan', MEDIA_UPLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaUploadComplete', - SKEY_UPDATE = 'onSkeyUpdate', } type NTReturnData = [ @@ -96,7 +95,7 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) { const isLogger = args[3]?.[0]?.eventName?.startsWith('ns-LoggerApi') if (!isLogger) { try { - logHook && log('call NTQQ api', thisArg, args) + logHook && log('call NTQQ api', args) } catch (e) { } if (!onlyLog) { try { diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts index 5ed6ad3..c7197e7 100644 --- a/src/ntqqapi/ntcall.ts +++ b/src/ntqqapi/ntcall.ts @@ -13,7 +13,8 @@ import { NodeIKernelUixConvertService, NodeIKernelRichMediaService, NodeIKernelTicketService, - NodeIKernelTipOffService + NodeIKernelTipOffService, + NodeIKernelRobotService } from './services' export enum NTClass { @@ -39,7 +40,6 @@ export enum NTMethod { MEDIA_FILE_PATH = 'nodeIKernelMsgService/getRichMediaFilePathForGuild', RECALL_MSG = 'nodeIKernelMsgService/recallMsg', EMOJI_LIKE = 'nodeIKernelMsgService/setMsgEmojiLikes', - FORWARD_MSG = 'nodeIKernelMsgService/forwardMsgWithComment', SELF_INFO = 'fetchAuthData', FILE_TYPE = 'getFileType', @@ -93,6 +93,7 @@ interface NTService { nodeIKernelRichMediaService: NodeIKernelRichMediaService nodeIKernelTicketService: NodeIKernelTicketService nodeIKernelTipOffService: NodeIKernelTipOffService + nodeIKernelRobotService: NodeIKernelRobotService } interface InvokeOptions { diff --git a/src/ntqqapi/services/NodeIKernelMsgService.ts b/src/ntqqapi/services/NodeIKernelMsgService.ts index 449b8e1..af6276a 100644 --- a/src/ntqqapi/services/NodeIKernelMsgService.ts +++ b/src/ntqqapi/services/NodeIKernelMsgService.ts @@ -10,7 +10,9 @@ export interface NodeIKernelMsgService { setStatus(args: { status: number, extStatus: number, batteryStatus: number }): Promise - forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise + forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise + }> forwardMsgWithComment(...args: unknown[]): Promise @@ -71,7 +73,7 @@ export interface NodeIKernelMsgService { downloadRichMedia(...args: unknown[]): unknown - setMsgEmojiLikes(...args: unknown[]): unknown + setMsgEmojiLikes(...args: unknown[]): Promise getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, cookie: string, bForward: boolean, number: number): Promise<{ result: number diff --git a/src/ntqqapi/services/NodeIKernelRobotService.ts b/src/ntqqapi/services/NodeIKernelRobotService.ts new file mode 100644 index 0000000..4dca0a3 --- /dev/null +++ b/src/ntqqapi/services/NodeIKernelRobotService.ts @@ -0,0 +1,13 @@ +import { GeneralCallResult } from './common' + +export interface NodeIKernelRobotService { + getRobotUinRange(req: unknown): Promise +} diff --git a/src/ntqqapi/services/index.ts b/src/ntqqapi/services/index.ts index 2ce5f5a..f233136 100644 --- a/src/ntqqapi/services/index.ts +++ b/src/ntqqapi/services/index.ts @@ -9,3 +9,4 @@ export * from './NodeIKernelUixConvertService' export * from './NodeIKernelRichMediaService' export * from './NodeIKernelTicketService' export * from './NodeIKernelTipOffService' +export * from './NodeIKernelRobotService' diff --git a/src/ntqqapi/types/user.ts b/src/ntqqapi/types/user.ts index 09054d7..99f8d8d 100644 --- a/src/ntqqapi/types/user.ts +++ b/src/ntqqapi/types/user.ts @@ -221,11 +221,6 @@ interface RelationFlags { isHidePrivilegeIcon: number } -export interface FriendV2 extends SimpleInfo { - categoryId?: number - categroyName?: string -} - interface CommonExt { constellation: number shengXiao: number @@ -255,7 +250,7 @@ interface PhotoWall { picList: Pic[] } -export interface UserDetailInfoListenerArg { +export interface UserDetailInfo { uid: string uin: string simpleInfo: SimpleInfo diff --git a/src/onebot11/action/msg/ForwardSingleMsg.ts b/src/onebot11/action/msg/ForwardSingleMsg.ts index 18098c3..b11d1e0 100644 --- a/src/onebot11/action/msg/ForwardSingleMsg.ts +++ b/src/onebot11/action/msg/ForwardSingleMsg.ts @@ -19,8 +19,8 @@ abstract class ForwardSingleMsg extends BaseAction { } const peer = await createPeer(this.ctx, payload) const ret = await this.ctx.ntMsgApi.forwardMsg(msg.peer, peer, [msg.msgId]) - if (ret.result !== 0) { - throw new Error(`转发消息失败 ${ret.errMsg}`) + if (ret.length === 0) { + throw new Error(`转发消息失败`) } return null } diff --git a/src/onebot11/action/msg/GetMsg.ts b/src/onebot11/action/msg/GetMsg.ts index 6c742e2..27de7ca 100644 --- a/src/onebot11/action/msg/GetMsg.ts +++ b/src/onebot11/action/msg/GetMsg.ts @@ -30,9 +30,6 @@ class GetMsg extends BaseAction { if (!retMsg) { throw new Error('消息为空') } - retMsg.message_id = this.ctx.store.createMsgShortId(peer, msg.msgId) - retMsg.message_seq = retMsg.message_id - retMsg.real_id = retMsg.message_id return retMsg } } diff --git a/src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts b/src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts index 9173aa0..b33d045 100644 --- a/src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts +++ b/src/onebot11/event/notice/OB11MsgEmojiLikeEvent.ts @@ -8,17 +8,15 @@ export interface MsgEmojiLike { export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent { notice_type = 'group_msg_emoji_like' message_id: number - sub_type?: 'ban' | 'lift_ban' likes: MsgEmojiLike[] group_id: number user_id: number - constructor(groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[], sub_type?: 'ban' | 'lift_ban') { + constructor(groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[]) { super() this.group_id = groupId this.user_id = userId // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空 this.message_id = messageId this.likes = likes - this.sub_type = sub_type } }