mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
|||||||
CacheFileListItem,
|
CacheFileListItem,
|
||||||
CacheFileType,
|
CacheFileType,
|
||||||
CacheScanResult,
|
CacheScanResult,
|
||||||
ChatCacheList,
|
|
||||||
ChatCacheListItemBasic,
|
ChatCacheListItemBasic,
|
||||||
ChatType,
|
ChatType,
|
||||||
ElementType,
|
ElementType,
|
||||||
@@ -54,33 +53,16 @@ export class NTQQFileApi extends Service {
|
|||||||
{ downSourceType: 1, triggerType: 1 }
|
{ downSourceType: 1, triggerType: 1 }
|
||||||
)).urlResult.domainUrl[0]?.url
|
)).urlResult.domainUrl[0]?.url
|
||||||
} else {
|
} else {
|
||||||
const data = await invoke<GeneralCallResult & {
|
const data = await invoke('nodeIKernelRichMediaService/getVideoPlayUrlV2', [{
|
||||||
urlResult: {
|
peer,
|
||||||
v4IpUrl: []
|
msgId,
|
||||||
v6IpUrl: []
|
elemId: elementId,
|
||||||
domainUrl: {
|
videoCodecFormat: 0,
|
||||||
url: string
|
exParams: {
|
||||||
isHttps: boolean
|
downSourceType: 1,
|
||||||
httpsDomain: string
|
triggerType: 1
|
||||||
}[]
|
},
|
||||||
videoCodecFormat: number
|
}, null])
|
||||||
}
|
|
||||||
}>({
|
|
||||||
methodName: 'nodeIKernelRichMediaService/getVideoPlayUrlV2',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgId,
|
|
||||||
elemId: elementId,
|
|
||||||
videoCodecFormat: 0,
|
|
||||||
exParams: {
|
|
||||||
downSourceType: 1,
|
|
||||||
triggerType: 1
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
if (data.result !== 0) {
|
if (data.result !== 0) {
|
||||||
this.ctx.logger.warn('getVideoUrl', data)
|
this.ctx.logger.warn('getVideoUrl', data)
|
||||||
}
|
}
|
||||||
@@ -117,23 +99,18 @@ export class NTQQFileApi extends Service {
|
|||||||
file_uuid: ''
|
file_uuid: ''
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
mediaPath = await invoke<string>({
|
mediaPath = await invoke(NTMethod.MEDIA_FILE_PATH, [{
|
||||||
methodName: NTMethod.MEDIA_FILE_PATH,
|
path_info: {
|
||||||
args: [
|
md5HexStr: fileMd5,
|
||||||
{
|
fileName: fileName,
|
||||||
path_info: {
|
elementType: elementType,
|
||||||
md5HexStr: fileMd5,
|
elementSubType,
|
||||||
fileName: fileName,
|
thumbSize: 0,
|
||||||
elementType: elementType,
|
needCreate: true,
|
||||||
elementSubType,
|
downloadType: 1,
|
||||||
thumbSize: 0,
|
file_uuid: '',
|
||||||
needCreate: true,
|
},
|
||||||
downloadType: 1,
|
}])
|
||||||
file_uuid: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
await fsPromise.copyFile(filePath, mediaPath)
|
await fsPromise.copyFile(filePath, mediaPath)
|
||||||
const fileSize = (await fsPromise.stat(filePath)).size
|
const fileSize = (await fsPromise.stat(filePath)).size
|
||||||
@@ -209,9 +186,9 @@ export class NTQQFileApi extends Service {
|
|||||||
)
|
)
|
||||||
filePath = data[1].filePath
|
filePath = data[1].filePath
|
||||||
} else {
|
} else {
|
||||||
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>({
|
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
||||||
methodName: NTMethod.DOWNLOAD_MEDIA,
|
NTMethod.DOWNLOAD_MEDIA,
|
||||||
args: [
|
[
|
||||||
{
|
{
|
||||||
getReq: {
|
getReq: {
|
||||||
fileModelId: '0',
|
fileModelId: '0',
|
||||||
@@ -228,10 +205,12 @@ export class NTQQFileApi extends Service {
|
|||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
{
|
||||||
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
||||||
timeout
|
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
||||||
})
|
timeout
|
||||||
|
}
|
||||||
|
)
|
||||||
filePath = data.notifyInfo.filePath
|
filePath = data.notifyInfo.filePath
|
||||||
}
|
}
|
||||||
if (filePath.startsWith('\\')) {
|
if (filePath.startsWith('\\')) {
|
||||||
@@ -243,11 +222,13 @@ export class NTQQFileApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getImageSize(filePath: string) {
|
async getImageSize(filePath: string) {
|
||||||
return await invoke<{ width: number; height: number }>({
|
return await invoke<{ width: number; height: number }>(
|
||||||
className: NTClass.FS_API,
|
NTMethod.IMAGE_SIZE,
|
||||||
methodName: NTMethod.IMAGE_SIZE,
|
[filePath],
|
||||||
args: [filePath],
|
{
|
||||||
})
|
className: NTClass.FS_API,
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getImageUrl(element: PicElement) {
|
async getImageUrl(element: PicElement) {
|
||||||
@@ -289,15 +270,7 @@ export class NTQQFileCacheApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setCacheSilentScan(isSilent: boolean = true) {
|
async setCacheSilentScan(isSilent: boolean = true) {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke<GeneralCallResult>(NTMethod.CACHE_SET_SILENCE, [{ isSilent }, null])
|
||||||
methodName: NTMethod.CACHE_SET_SILENCE,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
isSilent,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCacheSessionPathList() {
|
getCacheSessionPathList() {
|
||||||
@@ -306,110 +279,38 @@ export class NTQQFileCacheApi extends Service {
|
|||||||
key: string
|
key: string
|
||||||
value: string
|
value: string
|
||||||
}[]
|
}[]
|
||||||
>({
|
>(NTMethod.CACHE_PATH_SESSION, [], { className: NTClass.OS_API })
|
||||||
className: NTClass.OS_API,
|
|
||||||
methodName: NTMethod.CACHE_PATH_SESSION,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCache(cacheKeys: Array<string> = ['tmp', 'hotUpdate']) {
|
|
||||||
return invoke<any>({
|
|
||||||
// TODO: 目前还不知道真正的返回值是什么
|
|
||||||
methodName: NTMethod.CACHE_CLEAR,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
keys: cacheKeys,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
addCacheScannedPaths(pathMap: object = {}) {
|
|
||||||
return invoke<GeneralCallResult>({
|
|
||||||
methodName: NTMethod.CACHE_ADD_SCANNED_PATH,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
pathMap: { ...pathMap },
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanCache() {
|
scanCache() {
|
||||||
invoke<GeneralCallResult>({
|
invoke<GeneralCallResult>(ReceiveCmdS.CACHE_SCAN_FINISH, [], { classNameIsRegister: true })
|
||||||
methodName: ReceiveCmdS.CACHE_SCAN_FINISH,
|
return invoke<CacheScanResult>(NTMethod.CACHE_SCAN, [null, null], { timeout: 300 * Time.second })
|
||||||
classNameIsRegister: true,
|
|
||||||
}).then()
|
|
||||||
return invoke<CacheScanResult>({
|
|
||||||
methodName: NTMethod.CACHE_SCAN,
|
|
||||||
args: [null, null],
|
|
||||||
timeout: 300 * Time.second,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getHotUpdateCachePath() {
|
getHotUpdateCachePath() {
|
||||||
return invoke<string>({
|
return invoke<string>(NTMethod.CACHE_PATH_HOT_UPDATE, [], { className: NTClass.HOTUPDATE_API })
|
||||||
className: NTClass.HOTUPDATE_API,
|
|
||||||
methodName: NTMethod.CACHE_PATH_HOT_UPDATE,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDesktopTmpPath() {
|
getDesktopTmpPath() {
|
||||||
return invoke<string>({
|
return invoke<string>(NTMethod.CACHE_PATH_DESKTOP_TEMP, [], { className: NTClass.BUSINESS_API })
|
||||||
className: NTClass.BUSINESS_API,
|
|
||||||
methodName: NTMethod.CACHE_PATH_DESKTOP_TEMP,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) {
|
|
||||||
return new Promise<ChatCacheList>((res, rej) => {
|
|
||||||
invoke<ChatCacheList>({
|
|
||||||
methodName: NTMethod.CACHE_CHAT_GET,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
chatType: type,
|
|
||||||
pageSize,
|
|
||||||
order: 1,
|
|
||||||
pageIndex,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
.then((list) => res(list))
|
|
||||||
.catch((e) => rej(e))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) {
|
getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) {
|
||||||
const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }
|
const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }
|
||||||
|
|
||||||
return invoke<CacheFileList>({
|
return invoke<CacheFileList>(NTMethod.CACHE_FILE_GET, [{
|
||||||
methodName: NTMethod.CACHE_FILE_GET,
|
fileType: fileType,
|
||||||
args: [
|
restart: true,
|
||||||
{
|
pageSize: pageSize,
|
||||||
fileType: fileType,
|
order: 1,
|
||||||
restart: true,
|
lastRecord: _lastRecord,
|
||||||
pageSize: pageSize,
|
}, null])
|
||||||
order: 1,
|
|
||||||
lastRecord: _lastRecord,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke<GeneralCallResult>(NTMethod.CACHE_CHAT_CLEAR, [{
|
||||||
methodName: NTMethod.CACHE_CHAT_CLEAR,
|
chats,
|
||||||
args: [
|
fileKeys,
|
||||||
{
|
}, null])
|
||||||
chats,
|
|
||||||
fileKeys,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,12 +28,15 @@ export class NTQQFriendApi extends Service {
|
|||||||
categroyMbCount: number
|
categroyMbCount: number
|
||||||
buddyList: Friend[]
|
buddyList: Friend[]
|
||||||
}[]
|
}[]
|
||||||
}>({
|
}>(
|
||||||
className: NTClass.NODE_STORE_API,
|
'getBuddyList',
|
||||||
methodName: 'getBuddyList',
|
[],
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
{
|
||||||
afterFirstCmd: false,
|
className: NTClass.NODE_STORE_API,
|
||||||
})
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
const _friends: Friend[] = []
|
const _friends: Friend[] = []
|
||||||
for (const item of data.data) {
|
for (const item of data.data) {
|
||||||
_friends.push(...item.buddyList)
|
_friends.push(...item.buddyList)
|
||||||
@@ -56,18 +59,13 @@ export class NTQQFriendApi extends Service {
|
|||||||
accept
|
accept
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.HANDLE_FRIEND_REQUEST, [{
|
||||||
methodName: NTMethod.HANDLE_FRIEND_REQUEST,
|
approvalInfo: {
|
||||||
args: [
|
friendUid,
|
||||||
{
|
reqTime,
|
||||||
approvalInfo: {
|
accept,
|
||||||
friendUid,
|
},
|
||||||
reqTime,
|
}])
|
||||||
accept,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,13 +84,15 @@ export class NTQQFriendApi extends Service {
|
|||||||
const data = await invoke<{
|
const data = await invoke<{
|
||||||
buddyCategory: CategoryFriend[]
|
buddyCategory: CategoryFriend[]
|
||||||
userSimpleInfos: Record<string, SimpleInfo>
|
userSimpleInfos: Record<string, SimpleInfo>
|
||||||
}>({
|
}>(
|
||||||
className: NTClass.NODE_STORE_API,
|
'getBuddyList',
|
||||||
methodName: 'getBuddyList',
|
[refresh],
|
||||||
args: [refresh],
|
{
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
className: NTClass.NODE_STORE_API,
|
||||||
afterFirstCmd: false,
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
})
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
const categoryUids: Map<number, string[]> = new Map()
|
const categoryUids: Map<number, string[]> = new Map()
|
||||||
for (const item of data.buddyCategory) {
|
for (const item of data.buddyCategory) {
|
||||||
categoryUids.set(item.categoryId, item.buddyUids)
|
categoryUids.set(item.categoryId, item.buddyUids)
|
||||||
@@ -119,13 +119,15 @@ export class NTQQFriendApi extends Service {
|
|||||||
const data = await invoke<{
|
const data = await invoke<{
|
||||||
buddyCategory: CategoryFriend[]
|
buddyCategory: CategoryFriend[]
|
||||||
userSimpleInfos: Record<string, SimpleInfo>
|
userSimpleInfos: Record<string, SimpleInfo>
|
||||||
}>({
|
}>(
|
||||||
className: NTClass.NODE_STORE_API,
|
'getBuddyList',
|
||||||
methodName: 'getBuddyList',
|
[refresh],
|
||||||
args: [refresh],
|
{
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
className: NTClass.NODE_STORE_API,
|
||||||
afterFirstCmd: false,
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
})
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
for (const item of Object.values(data.userSimpleInfos)) {
|
for (const item of Object.values(data.userSimpleInfos)) {
|
||||||
retMap.set(item.uin!, item.uid!)
|
retMap.set(item.uin!, item.uid!)
|
||||||
}
|
}
|
||||||
@@ -158,13 +160,15 @@ export class NTQQFriendApi extends Service {
|
|||||||
const data = await invoke<{
|
const data = await invoke<{
|
||||||
buddyCategory: CategoryFriend[]
|
buddyCategory: CategoryFriend[]
|
||||||
userSimpleInfos: Record<string, SimpleInfo>
|
userSimpleInfos: Record<string, SimpleInfo>
|
||||||
}>({
|
}>(
|
||||||
className: NTClass.NODE_STORE_API,
|
'getBuddyList',
|
||||||
methodName: 'getBuddyList',
|
[refresh],
|
||||||
args: [refresh],
|
{
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
className: NTClass.NODE_STORE_API,
|
||||||
afterFirstCmd: false,
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
})
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
const category: Map<number, Pick<CategoryFriend, 'buddyUids' | 'categroyName'>> = new Map()
|
const category: Map<number, Pick<CategoryFriend, 'buddyUids' | 'categroyName'>> = new Map()
|
||||||
for (const item of data.buddyCategory) {
|
for (const item of data.buddyCategory) {
|
||||||
category.set(item.categoryId, pick(item, ['buddyUids', 'categroyName']))
|
category.set(item.categoryId, pick(item, ['buddyUids', 'categroyName']))
|
||||||
@@ -186,13 +190,7 @@ export class NTQQFriendApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getBuddyService().isBuddy(uid)
|
return session.getBuddyService().isBuddy(uid)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<boolean>({
|
return await invoke('nodeIKernelBuddyService/isBuddy', [{ uid }, null])
|
||||||
methodName: 'nodeIKernelBuddyService/isBuddy',
|
|
||||||
args: [
|
|
||||||
{ uid },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQGroupApi extends Service {
|
export class NTQQGroupApi extends Service {
|
||||||
|
static inject = ['ntWindowApi']
|
||||||
|
|
||||||
private groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
private groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
@@ -41,45 +43,29 @@ export class NTQQGroupApi extends Service {
|
|||||||
const result = await invoke<{
|
const result = await invoke<{
|
||||||
updateType: number
|
updateType: number
|
||||||
groupList: Group[]
|
groupList: Group[]
|
||||||
}>({
|
}>(
|
||||||
className: NTClass.NODE_STORE_API,
|
'getGroupList',
|
||||||
methodName: 'getGroupList',
|
[],
|
||||||
cbCmd: ReceiveCmdS.GROUPS_STORE,
|
{
|
||||||
afterFirstCmd: false,
|
className: NTClass.NODE_STORE_API,
|
||||||
})
|
cbCmd: ReceiveCmdS.GROUPS_STORE,
|
||||||
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
return result.groupList
|
return result.groupList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembers(groupCode: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
let result: Awaited<ReturnType<NodeIKernelGroupService['getNextMemberList']>>
|
let result: Awaited<ReturnType<NodeIKernelGroupService['getNextMemberList']>>
|
||||||
if (session) {
|
if (session) {
|
||||||
const groupService = session.getGroupService()
|
const groupService = session.getGroupService()
|
||||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow')
|
const sceneId = groupService.createMemberListScene(groupCode, 'groupMemberList_MainWindow')
|
||||||
result = await groupService.getNextMemberList(sceneId, undefined, num)
|
result = await groupService.getNextMemberList(sceneId, undefined, num)
|
||||||
} else {
|
} else {
|
||||||
const sceneId = await invoke<string>({
|
const sceneId = await invoke(NTMethod.GROUP_MEMBER_SCENE, [{ groupCode, scene: 'groupMemberList_MainWindow' }])
|
||||||
methodName: NTMethod.GROUP_MEMBER_SCENE,
|
result = await invoke(NTMethod.GROUP_MEMBERS, [{ sceneId, num }, null])
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
scene: 'groupMemberList_MainWindow',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
result = await invoke<
|
|
||||||
ReturnType<NodeIKernelGroupService['getNextMemberList']>
|
|
||||||
>({
|
|
||||||
methodName: NTMethod.GROUP_MEMBERS,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
sceneId,
|
|
||||||
num,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
if (result.errCode !== 0) {
|
if (result.errCode !== 0) {
|
||||||
throw ('获取群成员列表出错,' + result.errMsg)
|
throw ('获取群成员列表出错,' + result.errMsg)
|
||||||
@@ -144,16 +130,16 @@ export class NTQQGroupApi extends Service {
|
|||||||
)
|
)
|
||||||
return notifies
|
return notifies
|
||||||
} else {
|
} else {
|
||||||
invoke({
|
invoke(ReceiveCmdS.GROUP_NOTIFY, [], { classNameIsRegister: true })
|
||||||
methodName: ReceiveCmdS.GROUP_NOTIFY,
|
return (await invoke<GroupNotifies>(
|
||||||
classNameIsRegister: true,
|
NTMethod.GET_GROUP_NOTICE,
|
||||||
})
|
[{ doubt: false, startSeq: '', number: num }, null],
|
||||||
return (await invoke<GroupNotifies>({
|
{
|
||||||
methodName: NTMethod.GET_GROUP_NOTICE,
|
|
||||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
args: [{ doubt: false, startSeq: '', number: num }, null],
|
}
|
||||||
})).notifies
|
)).notifies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,152 +162,87 @@ export class NTQQGroupApi extends Service {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.HANDLE_GROUP_REQUEST, [{
|
||||||
methodName: NTMethod.HANDLE_GROUP_REQUEST,
|
doubt: false,
|
||||||
args: [
|
operateMsg: {
|
||||||
{
|
operateType,
|
||||||
doubt: false,
|
targetMsg: {
|
||||||
operateMsg: {
|
seq,
|
||||||
operateType,
|
type,
|
||||||
targetMsg: {
|
groupCode,
|
||||||
seq,
|
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
||||||
type,
|
|
||||||
groupCode,
|
|
||||||
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
null,
|
},
|
||||||
],
|
}, null])
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async quitGroup(groupQQ: string) {
|
async quitGroup(groupCode: string) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().quitGroup(groupQQ)
|
return session.getGroupService().quitGroup(groupCode)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.QUIT_GROUP, [{ groupCode }, null])
|
||||||
methodName: NTMethod.QUIT_GROUP,
|
|
||||||
args: [{ groupCode: groupQQ }, null],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async kickMember(
|
async kickMember(
|
||||||
groupQQ: string,
|
groupCode: string,
|
||||||
kickUids: string[],
|
kickUids: string[],
|
||||||
refuseForever = false,
|
refuseForever = false,
|
||||||
kickReason = '',
|
kickReason = '',
|
||||||
) {
|
) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().kickMember(groupQQ, kickUids, refuseForever, kickReason)
|
return session.getGroupService().kickMember(groupCode, kickUids, refuseForever, kickReason)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.KICK_MEMBER, [{ groupCode, kickUids, refuseForever, kickReason }])
|
||||||
methodName: NTMethod.KICK_MEMBER,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
kickUids,
|
|
||||||
refuseForever,
|
|
||||||
kickReason,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async banMember(groupQQ: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
async banMember(groupCode: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
||||||
// timeStamp为秒数, 0为解除禁言
|
// timeStamp为秒数, 0为解除禁言
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().setMemberShutUp(groupQQ, memList)
|
return session.getGroupService().setMemberShutUp(groupCode, memList)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.MUTE_MEMBER, [{ groupCode, memList }])
|
||||||
methodName: NTMethod.MUTE_MEMBER,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
memList,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async banGroup(groupQQ: string, shutUp: boolean) {
|
async banGroup(groupCode: string, shutUp: boolean) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().setGroupShutUp(groupQQ, shutUp)
|
return session.getGroupService().setGroupShutUp(groupCode, shutUp)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.MUTE_GROUP, [{ groupCode, shutUp }, null])
|
||||||
methodName: NTMethod.MUTE_GROUP,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
shutUp,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMemberCard(groupQQ: string, memberUid: string, cardName: string) {
|
async setMemberCard(groupCode: string, memberUid: string, cardName: string) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().modifyMemberCardName(groupQQ, memberUid, cardName)
|
return session.getGroupService().modifyMemberCardName(groupCode, memberUid, cardName)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.SET_MEMBER_CARD, [{ groupCode, uid: memberUid, cardName }, null])
|
||||||
methodName: NTMethod.SET_MEMBER_CARD,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
uid: memberUid,
|
|
||||||
cardName,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMemberRole(groupQQ: string, memberUid: string, role: GroupMemberRole) {
|
async setMemberRole(groupCode: string, memberUid: string, role: GroupMemberRole) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().modifyMemberRole(groupQQ, memberUid, role)
|
return session.getGroupService().modifyMemberRole(groupCode, memberUid, role)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.SET_MEMBER_ROLE, [{ groupCode, uid: memberUid, role }, null])
|
||||||
methodName: NTMethod.SET_MEMBER_ROLE,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
uid: memberUid,
|
|
||||||
role,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupName(groupQQ: string, groupName: string) {
|
async setGroupName(groupCode: string, groupName: string) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().modifyGroupName(groupQQ, groupName, false)
|
return session.getGroupService().modifyGroupName(groupCode, groupName, false)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.SET_GROUP_NAME, [{ groupCode, groupName }, null])
|
||||||
methodName: NTMethod.SET_GROUP_NAME,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode: groupQQ,
|
|
||||||
groupName,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,15 +257,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
canNotAtAllMsg: ''
|
canNotAtAllMsg: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>({
|
>(NTMethod.GROUP_AT_ALL_REMAIN_COUNT, [{ groupCode }, null])
|
||||||
methodName: NTMethod.GROUP_AT_ALL_REMAIN_COUNT,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupCode,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 27187 TODO */
|
/** 27187 TODO */
|
||||||
@@ -378,42 +291,14 @@ export class NTQQGroupApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createGroupFileFolder(groupId: string, folderName: string) {
|
async createGroupFileFolder(groupId: string, folderName: string) {
|
||||||
return await invoke({
|
return await invoke('nodeIKernelRichMediaService/createGroupFolder', [{ groupId, folderName }, null])
|
||||||
methodName: 'nodeIKernelRichMediaService/createGroupFolder',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupId,
|
|
||||||
folderName
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroupFileFolder(groupId: string, folderId: string) {
|
async deleteGroupFileFolder(groupId: string, folderId: string) {
|
||||||
return await invoke({
|
return await invoke('nodeIKernelRichMediaService/deleteGroupFolder', [{ groupId, folderId }, null])
|
||||||
methodName: 'nodeIKernelRichMediaService/deleteGroupFolder',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupId,
|
|
||||||
folderId
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroupFile(groupId: string, fileIdList: string[]) {
|
async deleteGroupFile(groupId: string, fileIdList: string[]) {
|
||||||
return await invoke({
|
return await invoke('nodeIKernelRichMediaService/deleteGroupFile', [{ groupId, busIdList: [102], fileIdList }, null])
|
||||||
methodName: 'nodeIKernelRichMediaService/deleteGroupFile',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
groupId,
|
|
||||||
busIdList: [102],
|
|
||||||
fileIdList
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { invoke, NTMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult, TmpChatInfoApi } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||||
@@ -23,6 +23,8 @@ function generateMsgId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQMsgApi extends Service {
|
export class NTQQMsgApi extends Service {
|
||||||
|
static inject = ['ntUserApi']
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntMsgApi', true)
|
super(ctx, 'ntMsgApi', true)
|
||||||
}
|
}
|
||||||
@@ -32,41 +34,20 @@ export class NTQQMsgApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().getTempChatInfo(chatType, peerUid)
|
return session.getMsgService().getTempChatInfo(chatType, peerUid)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<TmpChatInfoApi>({
|
return await invoke('nodeIKernelMsgService/getTempChatInfo', [{ chatType, peerUid }, null])
|
||||||
methodName: 'nodeIKernelMsgService/getTempChatInfo',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
chatType,
|
|
||||||
peerUid,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) {
|
async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, setEmoji: boolean = true) {
|
||||||
// nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览
|
// 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
|
// 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
|
// 其实以官方文档为准是最好的,https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#EmojiType
|
||||||
emojiId = emojiId.toString()
|
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
|
const emojiType = emojiId.length > 3 ? '2' : '1'
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiId.length > 3 ? '2' : '1', set)
|
return session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiType, setEmoji)
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.EMOJI_LIKE, [{ peer, msgSeq, emojiId, emojiType, setEmoji }, null])
|
||||||
methodName: NTMethod.EMOJI_LIKE,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgSeq,
|
|
||||||
emojiId,
|
|
||||||
emojiType: emojiId.length > 3 ? '2' : '1',
|
|
||||||
setEmoji: set,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,33 +56,16 @@ export class NTQQMsgApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId)
|
return session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & { msgList: RawMessage[] }>({
|
return await invoke(NTMethod.GET_MULTI_MSG, [{ peer, rootMsgId, parentMsgId }, null])
|
||||||
methodName: NTMethod.GET_MULTI_MSG,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
rootMsgId,
|
|
||||||
parentMsgId,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateChat(peer: Peer) {
|
async activateChat(peer: Peer) {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_PREVIEW, [{ peer, cnt: 20 }, null])
|
||||||
methodName: NTMethod.ACTIVE_CHAT_PREVIEW,
|
|
||||||
args: [{ peer, cnt: 20 }, null],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateChatAndGetHistory(peer: Peer) {
|
async activateChatAndGetHistory(peer: Peer) {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_HISTORY, [{ peer, cnt: 20 }, null])
|
||||||
methodName: NTMethod.ACTIVE_CHAT_HISTORY,
|
|
||||||
// 参数似乎不是这样
|
|
||||||
args: [{ peer, cnt: 20 }, null],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgsByMsgId(peer: Peer | undefined, msgIds: string[] | undefined) {
|
async getMsgsByMsgId(peer: Peer | undefined, msgIds: string[] | undefined) {
|
||||||
@@ -111,60 +75,26 @@ export class NTQQMsgApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().getMsgsByMsgId(peer, msgIds)
|
return session.getMsgService().getMsgsByMsgId(peer, msgIds)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & {
|
return await invoke('nodeIKernelMsgService/getMsgsByMsgId', [{ peer, msgIds }, null])
|
||||||
msgList: RawMessage[]
|
|
||||||
}>({
|
|
||||||
methodName: 'nodeIKernelMsgService/getMsgsByMsgId',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgIds,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgHistory(peer: Peer, msgId: string, count: number, isReverseOrder: boolean = false) {
|
async getMsgHistory(peer: Peer, msgId: string, cnt: number, isReverseOrder: boolean = false) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
// 消息时间从旧到新
|
// 消息时间从旧到新
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().getMsgsIncludeSelf(peer, msgId, count, isReverseOrder)
|
return session.getMsgService().getMsgsIncludeSelf(peer, msgId, cnt, isReverseOrder)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & { msgList: RawMessage[] }>({
|
return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder: isReverseOrder }, null])
|
||||||
methodName: NTMethod.HISTORY_MSG,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgId,
|
|
||||||
cnt: count,
|
|
||||||
queryOrder: isReverseOrder,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async recallMsg(peer: Peer, msgIds: string[]) {
|
async recallMsg(peer: Peer, msgIds: string[]) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().recallMsg({
|
return session.getMsgService().recallMsg(peer, msgIds)
|
||||||
chatType: peer.chatType,
|
|
||||||
peerUid: peer.peerUid
|
|
||||||
}, msgIds)
|
|
||||||
} else {
|
} else {
|
||||||
return await invoke({
|
return await invoke(NTMethod.RECALL_MSG, [{ peer, msgIds }, null])
|
||||||
methodName: NTMethod.RECALL_MSG,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgIds,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,19 +126,9 @@ export class NTQQMsgApi extends Service {
|
|||||||
)
|
)
|
||||||
msgList = data[1]
|
msgList = data[1]
|
||||||
} else {
|
} else {
|
||||||
const data = await invoke<{ msgList: RawMessage[] }>({
|
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||||
methodName: 'nodeIKernelMsgService/sendMsg',
|
'nodeIKernelMsgService/sendMsg',
|
||||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
[
|
||||||
afterFirstCmd: false,
|
|
||||||
cmdCB: payload => {
|
|
||||||
for (const msgRecord of payload.msgList) {
|
|
||||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
args: [
|
|
||||||
{
|
{
|
||||||
msgId: '0',
|
msgId: '0',
|
||||||
peer,
|
peer,
|
||||||
@@ -217,8 +137,20 @@ export class NTQQMsgApi extends Service {
|
|||||||
},
|
},
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
timeout
|
{
|
||||||
})
|
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
|
afterFirstCmd: false,
|
||||||
|
cmdCB: payload => {
|
||||||
|
for (const msgRecord of payload.msgList) {
|
||||||
|
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
timeout
|
||||||
|
}
|
||||||
|
)
|
||||||
msgList = data.msgList
|
msgList = data.msgList
|
||||||
}
|
}
|
||||||
const retMsg = msgList.find(msgRecord => {
|
const retMsg = msgList.find(msgRecord => {
|
||||||
@@ -234,19 +166,13 @@ export class NTQQMsgApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], [])
|
return session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], [])
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke<GeneralCallResult>(NTMethod.FORWARD_MSG, [{
|
||||||
methodName: NTMethod.FORWARD_MSG,
|
msgIds,
|
||||||
args: [
|
srcContact: srcPeer,
|
||||||
{
|
dstContacts: [destPeer],
|
||||||
msgIds: msgIds,
|
commentElements: [],
|
||||||
srcContact: srcPeer,
|
msgAttributeInfos: new Map(),
|
||||||
dstContacts: [destPeer],
|
}, null])
|
||||||
commentElements: [],
|
|
||||||
msgAttributeInfos: new Map(),
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,19 +208,9 @@ export class NTQQMsgApi extends Service {
|
|||||||
)
|
)
|
||||||
msgList = data[1]
|
msgList = data[1]
|
||||||
} else {
|
} else {
|
||||||
const data = await invoke<{ msgList: RawMessage[] }>({
|
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||||
methodName: 'nodeIKernelMsgService/multiForwardMsgWithComment',
|
'nodeIKernelMsgService/multiForwardMsgWithComment',
|
||||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
[
|
||||||
afterFirstCmd: false,
|
|
||||||
cmdCB: payload => {
|
|
||||||
for (const msgRecord of payload.msgList) {
|
|
||||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == selfUid) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
args: [
|
|
||||||
{
|
{
|
||||||
msgInfos,
|
msgInfos,
|
||||||
srcContact: srcPeer,
|
srcContact: srcPeer,
|
||||||
@@ -304,7 +220,19 @@ export class NTQQMsgApi extends Service {
|
|||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
})
|
{
|
||||||
|
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
|
afterFirstCmd: false,
|
||||||
|
cmdCB: payload => {
|
||||||
|
for (const msgRecord of payload.msgList) {
|
||||||
|
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == selfUid) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
msgList = data.msgList
|
msgList = data.msgList
|
||||||
}
|
}
|
||||||
for (const msg of msgList) {
|
for (const msg of msgList) {
|
||||||
@@ -323,25 +251,17 @@ export class NTQQMsgApi extends Service {
|
|||||||
throw new Error('转发消息超时')
|
throw new Error('转发消息超时')
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
async getMsgsBySeqAndCount(peer: Peer, msgSeq: string, count: number, desc: boolean, z: boolean) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return await session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z)
|
return await session.getMsgService().getMsgsBySeqAndCount(peer, msgSeq, count, desc, z)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & {
|
return await invoke('nodeIKernelMsgService/getMsgsBySeqAndCount', [{
|
||||||
msgList: RawMessage[]
|
peer,
|
||||||
}>({
|
cnt: count,
|
||||||
methodName: 'nodeIKernelMsgService/getMsgsBySeqAndCount',
|
msgSeq,
|
||||||
args: [
|
queryOrder: desc
|
||||||
{
|
}, null])
|
||||||
peer,
|
|
||||||
cnt: count,
|
|
||||||
msgSeq: seq,
|
|
||||||
queryOrder: desc
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,23 +281,12 @@ export class NTQQMsgApi extends Service {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSingleMsg(peer: Peer, seq: string) {
|
async getSingleMsg(peer: Peer, msgSeq: string) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
return await session.getMsgService().getSingleMsg(peer, seq)
|
return await session.getMsgService().getSingleMsg(peer, msgSeq)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & {
|
return await invoke('nodeIKernelMsgService/getSingleMsg', [{ peer, msgSeq }, null])
|
||||||
msgList: RawMessage[]
|
|
||||||
}>({
|
|
||||||
methodName: 'nodeIKernelMsgService/getSingleMsg',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
peer,
|
|
||||||
msgSeq: seq,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { invoke, NTMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult } from '../services'
|
|
||||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
@@ -18,21 +17,23 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQUserApi extends Service {
|
export class NTQQUserApi extends Service {
|
||||||
|
static inject = ['ntFriendApi']
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntUserApi', true)
|
super(ctx, 'ntUserApi', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setQQAvatar(filePath: string) {
|
async setQQAvatar(path: string) {
|
||||||
return await invoke<GeneralCallResult>({
|
return await invoke(
|
||||||
methodName: NTMethod.SET_QQ_AVATAR,
|
NTMethod.SET_QQ_AVATAR,
|
||||||
args: [
|
[
|
||||||
{
|
{ path },
|
||||||
path: filePath,
|
|
||||||
},
|
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
timeout: 10 * Time.second, // 10秒不一定够
|
{
|
||||||
})
|
timeout: 10 * Time.second, // 10秒不一定够
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchUserDetailInfo(uid: string) {
|
async fetchUserDetailInfo(uid: string) {
|
||||||
@@ -55,12 +56,9 @@ export class NTQQUserApi extends Service {
|
|||||||
)
|
)
|
||||||
info = profile
|
info = profile
|
||||||
} else {
|
} else {
|
||||||
const result = await invoke<{ info: UserDetailInfoListenerArg }>({
|
const result = await invoke<{ info: UserDetailInfoListenerArg }>(
|
||||||
methodName: 'nodeIKernelProfileService/fetchUserDetailInfo',
|
'nodeIKernelProfileService/fetchUserDetailInfo',
|
||||||
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
[
|
||||||
afterFirstCmd: false,
|
|
||||||
cmdCB: payload => payload.info.uid === uid,
|
|
||||||
args: [
|
|
||||||
{
|
{
|
||||||
callFrom: 'BuddyProfileStore',
|
callFrom: 'BuddyProfileStore',
|
||||||
uid: [uid],
|
uid: [uid],
|
||||||
@@ -69,7 +67,12 @@ export class NTQQUserApi extends Service {
|
|||||||
},
|
},
|
||||||
null
|
null
|
||||||
],
|
],
|
||||||
})
|
{
|
||||||
|
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||||
|
afterFirstCmd: false,
|
||||||
|
cmdCB: payload => payload.info.uid === uid,
|
||||||
|
}
|
||||||
|
)
|
||||||
info = result.info
|
info = result.info
|
||||||
}
|
}
|
||||||
const ret: User = {
|
const ret: User = {
|
||||||
@@ -104,19 +107,21 @@ export class NTQQUserApi extends Service {
|
|||||||
)
|
)
|
||||||
return profile
|
return profile
|
||||||
} else {
|
} else {
|
||||||
const result = await invoke<{ info: User }>({
|
const result = await invoke<{ info: User }>(
|
||||||
methodName: 'nodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
'nodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
||||||
cbCmd: 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
[
|
||||||
afterFirstCmd: false,
|
|
||||||
cmdCB: (payload) => payload.info.uid === uid,
|
|
||||||
args: [
|
|
||||||
{
|
{
|
||||||
uid,
|
uid,
|
||||||
bizList: [0]
|
bizList: [0]
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
})
|
{
|
||||||
|
cbCmd: 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
||||||
|
afterFirstCmd: false,
|
||||||
|
cmdCB: (payload) => payload.info.uid === uid,
|
||||||
|
}
|
||||||
|
)
|
||||||
return result.info
|
return result.info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,9 +170,9 @@ export class NTQQUserApi extends Service {
|
|||||||
doLikeTollCount: 0
|
doLikeTollCount: 0
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return await invoke<GeneralCallResult & { succCounts: number }>({
|
return await invoke(
|
||||||
methodName: 'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
||||||
args: [
|
[
|
||||||
{
|
{
|
||||||
doLikeUserInfo: {
|
doLikeUserInfo: {
|
||||||
friendUid: uid,
|
friendUid: uid,
|
||||||
@@ -178,7 +183,7 @@ export class NTQQUserApi extends Service {
|
|||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,32 +210,11 @@ export class NTQQUserApi extends Service {
|
|||||||
uid = (await session.getUixConvertService().getUid([uin])).uidInfo.get(uin)
|
uid = (await session.getUixConvertService().getUid([uin])).uidInfo.get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
} else {
|
} else {
|
||||||
let uid = (await invoke<{ uids: Map<string, string> }>({
|
let uid = (await invoke('nodeIKernelGroupService/getUidByUins', [{ uin: [uin] }, null])).uids.get(uin)
|
||||||
methodName: 'nodeIKernelGroupService/getUidByUins',
|
|
||||||
args: [
|
|
||||||
{ uin: [uin] },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).uids.get(uin)
|
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await invoke<Map<string, string>>({
|
uid = (await invoke('nodeIKernelProfileService/getUidByUin', [{ callFrom: 'FriendsServiceImpl', uin: [uin] }, null])).get(uin)
|
||||||
methodName: 'nodeIKernelProfileService/getUidByUin',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
callFrom: 'FriendsServiceImpl',
|
|
||||||
uin: [uin],
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).get(uin)
|
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await invoke<{ uidInfo: Map<string, string> }>({
|
uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uin: [uin] }, null])).uidInfo.get(uin)
|
||||||
methodName: 'nodeIKernelUixConvertService/getUid',
|
|
||||||
args: [
|
|
||||||
{ uin: [uin] },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).uidInfo.get(uin)
|
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
}
|
}
|
||||||
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid //从QQ Native 特殊转换
|
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid //从QQ Native 特殊转换
|
||||||
@@ -253,13 +237,13 @@ export class NTQQUserApi extends Service {
|
|||||||
uin
|
uin
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return await invoke<UserDetailInfoByUinV2>({
|
return await invoke<UserDetailInfoByUinV2>(
|
||||||
methodName: 'nodeIKernelProfileService/getUserDetailInfoByUin',
|
'nodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
args: [
|
[
|
||||||
{ uin },
|
{ uin },
|
||||||
null,
|
null,
|
||||||
],
|
],
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,39 +279,18 @@ export class NTQQUserApi extends Service {
|
|||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
uin = (await session.getUixConvertService().getUin([uid])).uinInfo.get(uid)
|
uin = (await session.getUixConvertService().getUin([uid])).uinInfo.get(uid)
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
return uin
|
|
||||||
} else {
|
} else {
|
||||||
let uin = (await invoke<{ uins: Map<string, string> }>({
|
let uin = (await invoke('nodeIKernelGroupService/getUinByUids', [{ uid: [uid] }, null])).uins.get(uid)
|
||||||
methodName: 'nodeIKernelGroupService/getUinByUids',
|
|
||||||
args: [
|
|
||||||
{ uid: [uid] },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).uins.get(uid)
|
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
uin = (await invoke<Map<string, string>>({
|
uin = (await invoke('nodeIKernelProfileService/getUinByUid', [{ callFrom: 'FriendsServiceImpl', uid: [uid] }, null])).get(uid)
|
||||||
methodName: 'nodeIKernelProfileService/getUinByUid',
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
callFrom: 'FriendsServiceImpl',
|
|
||||||
uid: [uid],
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).get(uid)
|
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
uin = (await invoke<{ uinInfo: Map<string, string> }>({
|
uin = (await invoke('nodeIKernelUixConvertService/getUin', [{ uid: [uid] }, null])).uinInfo.get(uid)
|
||||||
methodName: 'nodeIKernelUixConvertService/getUin',
|
|
||||||
args: [
|
|
||||||
{ uid: [uid] },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
})).uinInfo.get(uid)
|
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
}
|
}
|
||||||
let uin = (await this.ctx.ntFriendApi.getBuddyIdMap(true)).getKey(uid)
|
let uin = (await this.ctx.ntFriendApi.getBuddyIdMap(true)).getKey(uid)
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换
|
uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换
|
||||||
|
return uin
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUinByUid(Uid: string) {
|
async getUinByUid(Uid: string) {
|
||||||
@@ -342,12 +305,7 @@ export class NTQQUserApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return await session.getTicketService().forceFetchClientKey('')
|
return await session.getTicketService().forceFetchClientKey('')
|
||||||
} else {
|
} else {
|
||||||
return await invoke<forceFetchClientKeyRetType>({
|
return await invoke('nodeIKernelTicketService/forceFetchClientKey', [{ domain: '' }, null])
|
||||||
methodName: 'nodeIKernelTicketService/forceFetchClientKey',
|
|
||||||
args: [{
|
|
||||||
domain: ''
|
|
||||||
}, null],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,6 +125,8 @@ export interface GroupEssenceMsgRet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQWebApi extends Service {
|
export class NTQQWebApi extends Service {
|
||||||
|
static inject = ['ntUserApi']
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntWebApi', true)
|
super(ctx, 'ntWebApi', true)
|
||||||
}
|
}
|
||||||
|
@@ -42,13 +42,15 @@ export class NTQQWindowApi extends Service {
|
|||||||
cbCmd: ReceiveCmd | undefined,
|
cbCmd: ReceiveCmd | undefined,
|
||||||
autoCloseSeconds: number = 2,
|
autoCloseSeconds: number = 2,
|
||||||
) {
|
) {
|
||||||
const result = await invoke<R>({
|
const result = await invoke<R>(
|
||||||
className: NTClass.WINDOW_API,
|
NTMethod.OPEN_EXTRA_WINDOW,
|
||||||
methodName: NTMethod.OPEN_EXTRA_WINDOW,
|
[ntQQWindow.windowName, ...args],
|
||||||
cbCmd,
|
{
|
||||||
afterFirstCmd: false,
|
className: NTClass.WINDOW_API,
|
||||||
args: [ntQQWindow.windowName, ...args],
|
cbCmd,
|
||||||
})
|
afterFirstCmd: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
for (const w of BrowserWindow.getAllWindows()) {
|
for (const w of BrowserWindow.getAllWindows()) {
|
||||||
// log("close window", w.webContents.getURL())
|
// log("close window", w.webContents.getURL())
|
||||||
|
@@ -2,7 +2,20 @@ import { ipcMain } from 'electron'
|
|||||||
import { hookApiCallbacks, registerReceiveHook, removeReceiveHook } from './hook'
|
import { hookApiCallbacks, registerReceiveHook, removeReceiveHook } from './hook'
|
||||||
import { log } from '../common/utils/legacyLog'
|
import { log } from '../common/utils/legacyLog'
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
import { GeneralCallResult } from './services'
|
import {
|
||||||
|
GeneralCallResult,
|
||||||
|
NodeIKernelBuddyService,
|
||||||
|
NodeIKernelProfileService,
|
||||||
|
NodeIKernelGroupService,
|
||||||
|
NodeIKernelProfileLikeService,
|
||||||
|
NodeIKernelMsgService,
|
||||||
|
NodeIKernelMSFService,
|
||||||
|
NodeIKernelUixConvertService,
|
||||||
|
NodeIKernelRichMediaService,
|
||||||
|
NodeIKernelTicketService,
|
||||||
|
NodeIKernelTipOffService,
|
||||||
|
NodeIKernelSearchService,
|
||||||
|
} from './services'
|
||||||
|
|
||||||
export enum NTClass {
|
export enum NTClass {
|
||||||
NT_API = 'ns-ntApi',
|
NT_API = 'ns-ntApi',
|
||||||
@@ -95,35 +108,52 @@ export enum NTChannel {
|
|||||||
IPC_UP_4 = 'IPC_UP_4'
|
IPC_UP_4 = 'IPC_UP_4'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InvokeParams<ReturnType> {
|
interface NTService {
|
||||||
methodName: string
|
nodeIKernelBuddyService: NodeIKernelBuddyService
|
||||||
|
nodeIKernelProfileService: NodeIKernelProfileService
|
||||||
|
nodeIKernelGroupService: NodeIKernelGroupService
|
||||||
|
nodeIKernelProfileLikeService: NodeIKernelProfileLikeService
|
||||||
|
nodeIKernelMsgService: NodeIKernelMsgService
|
||||||
|
nodeIKernelMSFService: NodeIKernelMSFService
|
||||||
|
nodeIKernelUixConvertService: NodeIKernelUixConvertService
|
||||||
|
nodeIKernelRichMediaService: NodeIKernelRichMediaService
|
||||||
|
nodeIKernelTicketService: NodeIKernelTicketService
|
||||||
|
nodeIKernelTipOffService: NodeIKernelTipOffService
|
||||||
|
nodeIKernelSearchService: NodeIKernelSearchService
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InvokeOptions<ReturnType> {
|
||||||
className?: NTClass
|
className?: NTClass
|
||||||
channel?: NTChannel
|
channel?: NTChannel
|
||||||
classNameIsRegister?: boolean
|
classNameIsRegister?: boolean
|
||||||
args?: unknown[]
|
|
||||||
cbCmd?: string | string[]
|
cbCmd?: string | string[]
|
||||||
cmdCB?: (payload: ReturnType) => boolean
|
cmdCB?: (payload: ReturnType) => boolean
|
||||||
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
||||||
timeout?: number
|
timeout?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function invoke<ReturnType>(params: InvokeParams<ReturnType>) {
|
export function invoke<
|
||||||
const className = params.className ?? NTClass.NT_API
|
R extends Awaited<ReturnType<NTService[S][M] extends (...args: any) => any ? NTService[S][M] : any>>,
|
||||||
const channel = params.channel ?? NTChannel.IPC_UP_2
|
S extends keyof NTService = any,
|
||||||
const timeout = params.timeout ?? 5000
|
M extends keyof NTService[S] & string = any,
|
||||||
const afterFirstCmd = params.afterFirstCmd ?? true
|
O = string
|
||||||
|
>(method: `${O extends `${S}/${M}` ? `${S}/${M}` : string}`, args?: unknown[], options?: InvokeOptions<R>) {
|
||||||
|
const className = options?.className ?? NTClass.NT_API
|
||||||
|
const channel = options?.channel ?? NTChannel.IPC_UP_2
|
||||||
|
const timeout = options?.timeout ?? 5000
|
||||||
|
const afterFirstCmd = options?.afterFirstCmd ?? true
|
||||||
const uuid = randomUUID()
|
const uuid = randomUUID()
|
||||||
let eventName = className + '-' + channel[channel.length - 1]
|
let eventName = className + '-' + channel[channel.length - 1]
|
||||||
if (params.classNameIsRegister) {
|
if (options?.classNameIsRegister) {
|
||||||
eventName += '-register'
|
eventName += '-register'
|
||||||
}
|
}
|
||||||
const apiArgs = [params.methodName, ...(params.args ?? [])]
|
const apiArgs = [method, ...(args ?? [])]
|
||||||
//log('callNTQQApi', channel, eventName, apiArgs, uuid)
|
//log('callNTQQApi', channel, eventName, apiArgs, uuid)
|
||||||
return new Promise((resolve: (data: ReturnType) => void, reject) => {
|
return new Promise((resolve: (data: R) => void, reject) => {
|
||||||
let success = false
|
let success = false
|
||||||
if (!params.cbCmd) {
|
if (!options?.cbCmd) {
|
||||||
// QQ后端会返回结果,并且可以根据uuid识别
|
// QQ后端会返回结果,并且可以根据uuid识别
|
||||||
hookApiCallbacks[uuid] = (r: ReturnType) => {
|
hookApiCallbacks[uuid] = (r: R) => {
|
||||||
success = true
|
success = true
|
||||||
resolve(r)
|
resolve(r)
|
||||||
}
|
}
|
||||||
@@ -131,10 +161,10 @@ export function invoke<ReturnType>(params: InvokeParams<ReturnType>) {
|
|||||||
else {
|
else {
|
||||||
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
||||||
const secondCallback = () => {
|
const secondCallback = () => {
|
||||||
const hookId = registerReceiveHook<ReturnType>(params.cbCmd!, (payload) => {
|
const hookId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
|
||||||
// log(methodName, "second callback", cbCmd, payload, cmdCB);
|
// log(methodName, "second callback", cbCmd, payload, cmdCB);
|
||||||
if (!!params.cmdCB) {
|
if (!!options.cmdCB) {
|
||||||
if (params.cmdCB(payload)) {
|
if (options.cmdCB(payload)) {
|
||||||
removeReceiveHook(hookId)
|
removeReceiveHook(hookId)
|
||||||
success = true
|
success = true
|
||||||
resolve(payload)
|
resolve(payload)
|
||||||
@@ -154,15 +184,15 @@ export function invoke<ReturnType>(params: InvokeParams<ReturnType>) {
|
|||||||
afterFirstCmd && secondCallback()
|
afterFirstCmd && secondCallback()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log('ntqq api call failed,', params.methodName, result)
|
log('ntqq api call failed,', method, result)
|
||||||
reject(`ntqq api call failed, ${params.methodName}, ${result.errMsg}`)
|
reject(`ntqq api call failed, ${method}, ${result.errMsg}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
log(`ntqq api timeout ${channel}, ${eventName}, ${params.methodName}`, apiArgs)
|
log(`ntqq api timeout ${channel}, ${eventName}, ${method}`, apiArgs)
|
||||||
reject(`ntqq api timeout ${channel}, ${eventName}, ${params.methodName}, ${apiArgs}`)
|
reject(`ntqq api timeout ${channel}, ${eventName}, ${method}, ${apiArgs}`)
|
||||||
}
|
}
|
||||||
}, timeout)
|
}, timeout)
|
||||||
|
|
||||||
|
@@ -110,8 +110,6 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
resendMsg(...args: unknown[]): unknown
|
resendMsg(...args: unknown[]): unknown
|
||||||
|
|
||||||
recallMsg(...args: unknown[]): unknown
|
|
||||||
|
|
||||||
reeditRecallMsg(...args: unknown[]): unknown
|
reeditRecallMsg(...args: unknown[]): unknown
|
||||||
//调用请检查除开commentElements其余参数不能为null
|
//调用请检查除开commentElements其余参数不能为null
|
||||||
forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise<GeneralCallResult>
|
forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise<GeneralCallResult>
|
||||||
|
@@ -74,7 +74,7 @@ export interface NodeIKernelProfileService {
|
|||||||
|
|
||||||
setGander(...args: unknown[]): Promise<unknown>
|
setGander(...args: unknown[]): Promise<unknown>
|
||||||
|
|
||||||
setHeader(arg: string): Promise<unknown>
|
setHeader(arg: string): Promise<GeneralCallResult>
|
||||||
|
|
||||||
setRecommendImgFlag(...args: unknown[]): Promise<unknown>
|
setRecommendImgFlag(...args: unknown[]): Promise<unknown>
|
||||||
|
|
||||||
|
@@ -173,8 +173,6 @@ export interface NodeIKernelRichMediaService {
|
|||||||
|
|
||||||
downloadFile(commonFile: CommonFileInfo, arg2: unknown, arg3: unknown, savePath: string): unknown
|
downloadFile(commonFile: CommonFileInfo, arg2: unknown, arg3: unknown, savePath: string): unknown
|
||||||
|
|
||||||
createGroupFolder(arg1: unknown, arg2: unknown): unknown
|
|
||||||
|
|
||||||
downloadGroupFolder(arg1: unknown, arg2: unknown, arg3: unknown): unknown
|
downloadGroupFolder(arg1: unknown, arg2: unknown, arg3: unknown): unknown
|
||||||
|
|
||||||
renameGroupFolder(arg1: unknown, arg2: unknown, arg3: unknown): unknown
|
renameGroupFolder(arg1: unknown, arg2: unknown, arg3: unknown): unknown
|
||||||
|
Reference in New Issue
Block a user