mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
parent
4d816b498a
commit
8c0cc8beba
@ -18,16 +18,19 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@minatojs/driver-sqlite": "^4.6.0",
|
"@minatojs/driver-sqlite": "^4.6.0",
|
||||||
|
"@satorijs/element": "^3.1.7",
|
||||||
|
"@satorijs/protocol": "^1.4.2",
|
||||||
|
"compare-versions": "^6.1.1",
|
||||||
"cordis": "^3.18.1",
|
"cordis": "^3.18.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cosmokit": "^1.6.2",
|
"cosmokit": "^1.6.3",
|
||||||
"express": "^5.0.0",
|
"express": "^5.0.0",
|
||||||
"fast-xml-parser": "^4.5.0",
|
"fast-xml-parser": "^4.5.0",
|
||||||
"file-type": "^19.5.0",
|
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
"fluent-ffmpeg": "^2.1.3",
|
||||||
"minato": "^3.6.0",
|
"minato": "^3.6.0",
|
||||||
"protobufjs": "^7.4.0",
|
"protobufjs": "^7.4.0",
|
||||||
"silk-wasm": "^3.6.1",
|
"silk-wasm": "^3.6.1",
|
||||||
|
"ts-case-convert": "^2.1.0",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -4,7 +4,7 @@ import path from 'node:path'
|
|||||||
import { TEMP_DIR } from '../globalVars'
|
import { TEMP_DIR } from '../globalVars'
|
||||||
import { randomUUID, createHash } from 'node:crypto'
|
import { randomUUID, createHash } from 'node:crypto'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { fileTypeFromFile } from 'file-type'
|
import { Context } from 'cordis'
|
||||||
|
|
||||||
// 定义一个异步函数来检查文件是否存在
|
// 定义一个异步函数来检查文件是否存在
|
||||||
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
|
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
|
||||||
@ -118,7 +118,7 @@ type Uri2LocalRes = {
|
|||||||
isLocal: boolean
|
isLocal: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uri2local(uri: string, filename?: string, needExt?: boolean): Promise<Uri2LocalRes> {
|
export async function uri2local(ctx: Context, uri: string, needExt?: boolean): Promise<Uri2LocalRes> {
|
||||||
const { type } = checkUriType(uri)
|
const { type } = checkUriType(uri)
|
||||||
|
|
||||||
if (type === FileUriType.FileURL) {
|
if (type === FileUriType.FileURL) {
|
||||||
@ -136,15 +136,16 @@ export async function uri2local(uri: string, filename?: string, needExt?: boolea
|
|||||||
try {
|
try {
|
||||||
const res = await fetchFile(uri)
|
const res = await fetchFile(uri)
|
||||||
const match = res.url.match(/.+\/([^/?]*)(?=\?)?/)
|
const match = res.url.match(/.+\/([^/?]*)(?=\?)?/)
|
||||||
|
let filename: string
|
||||||
if (match?.[1]) {
|
if (match?.[1]) {
|
||||||
filename ??= match[1].replace(/[/\\:*?"<>|]/g, '_')
|
filename = match[1].replace(/[/\\:*?"<>|]/g, '_')
|
||||||
} else {
|
} else {
|
||||||
filename ??= randomUUID()
|
filename = randomUUID()
|
||||||
}
|
}
|
||||||
let filePath = path.join(TEMP_DIR, filename)
|
let filePath = path.join(TEMP_DIR, filename)
|
||||||
await fsPromise.writeFile(filePath, res.data)
|
await fsPromise.writeFile(filePath, res.data)
|
||||||
if (needExt && !path.extname(filePath)) {
|
if (needExt && !path.extname(filePath)) {
|
||||||
const ext = (await fileTypeFromFile(filePath))?.ext
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
|
||||||
filename += `.${ext}`
|
filename += `.${ext}`
|
||||||
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
filePath = `${filePath}.${ext}`
|
filePath = `${filePath}.${ext}`
|
||||||
@ -157,12 +158,12 @@ export async function uri2local(uri: string, filename?: string, needExt?: boolea
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === FileUriType.OneBotBase64) {
|
if (type === FileUriType.OneBotBase64) {
|
||||||
filename ??= randomUUID()
|
let filename = randomUUID()
|
||||||
let filePath = path.join(TEMP_DIR, filename)
|
let filePath = path.join(TEMP_DIR, filename)
|
||||||
const base64 = uri.replace(/^base64:\/\//, '')
|
const base64 = uri.replace(/^base64:\/\//, '')
|
||||||
await fsPromise.writeFile(filePath, base64, 'base64')
|
await fsPromise.writeFile(filePath, base64, 'base64')
|
||||||
if (needExt) {
|
if (needExt) {
|
||||||
const ext = (await fileTypeFromFile(filePath))?.ext
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
|
||||||
filename += `.${ext}`
|
filename += `.${ext}`
|
||||||
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
filePath = `${filePath}.${ext}`
|
filePath = `${filePath}.${ext}`
|
||||||
@ -174,12 +175,12 @@ export async function uri2local(uri: string, filename?: string, needExt?: boolea
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
||||||
const capture = /^data:([\w/.+-]+);base64,(.*)$/.exec(uri)
|
const capture = /^data:([\w/.+-]+);base64,(.*)$/.exec(uri)
|
||||||
if (capture) {
|
if (capture) {
|
||||||
filename ??= randomUUID()
|
let filename = randomUUID()
|
||||||
const [, _type, base64] = capture
|
const [, _type, base64] = capture
|
||||||
let filePath = path.join(TEMP_DIR, filename)
|
let filePath = path.join(TEMP_DIR, filename)
|
||||||
await fsPromise.writeFile(filePath, base64, 'base64')
|
await fsPromise.writeFile(filePath, base64, 'base64')
|
||||||
if (needExt) {
|
if (needExt) {
|
||||||
const ext = (await fileTypeFromFile(filePath))?.ext
|
const ext = (await ctx.ntFileApi.getFileType(filePath)).ext
|
||||||
filename += `.${ext}`
|
filename += `.${ext}`
|
||||||
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
filePath = `${filePath}.${ext}`
|
filePath = `${filePath}.${ext}`
|
||||||
|
@ -13,11 +13,16 @@ export function log(...msg: unknown[]) {
|
|||||||
let logMsg = ''
|
let logMsg = ''
|
||||||
for (const msgItem of msg) {
|
for (const msgItem of msg) {
|
||||||
if (typeof msgItem === 'object') {
|
if (typeof msgItem === 'object') {
|
||||||
logMsg += inspect(msgItem, { depth: 10, compact: true, breakLength: Infinity }) + ' '
|
logMsg += inspect(msgItem, {
|
||||||
continue
|
depth: 10,
|
||||||
}
|
compact: true,
|
||||||
|
breakLength: Infinity,
|
||||||
|
maxArrayLength: 220
|
||||||
|
}) + ' '
|
||||||
|
} else {
|
||||||
logMsg += msgItem + ' '
|
logMsg += msgItem + ' '
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const currentDateTime = new Date().toLocaleString()
|
const currentDateTime = new Date().toLocaleString()
|
||||||
logMsg = `${currentDateTime} ${logMsg}\n\n`
|
logMsg = `${currentDateTime} ${logMsg}\n\n`
|
||||||
fs.appendFile(path.join(LOG_DIR, logFileName), logMsg, () => { })
|
fs.appendFile(path.join(LOG_DIR, logFileName), logMsg, () => { })
|
||||||
|
@ -3,25 +3,19 @@ import { writeFile } from 'node:fs/promises'
|
|||||||
import { version } from '../../version'
|
import { version } from '../../version'
|
||||||
import { log, fetchFile } from '.'
|
import { log, fetchFile } from '.'
|
||||||
import { TEMP_DIR } from '../globalVars'
|
import { TEMP_DIR } from '../globalVars'
|
||||||
|
import { compare } from 'compare-versions'
|
||||||
|
|
||||||
const downloadMirrorHosts = ['https://ghp.ci/']
|
const downloadMirrorHosts = ['https://ghp.ci/']
|
||||||
const releasesMirrorHosts = ['https://kkgithub.com']
|
const releasesMirrorHosts = ['https://kkgithub.com']
|
||||||
|
|
||||||
export async function checkNewVersion() {
|
export async function checkNewVersion() {
|
||||||
const latestVersionText = await getRemoteVersion()
|
const latestVersion = await getRemoteVersion()
|
||||||
const latestVersion = latestVersionText.split('.')
|
|
||||||
log('LLOneBot latest version', latestVersion)
|
log('LLOneBot latest version', latestVersion)
|
||||||
const currentVersion = version.split('.')
|
if (latestVersion === '') {
|
||||||
//log('llonebot current version', currentVersion)
|
return { result: false, version: latestVersion }
|
||||||
for (const k of [0, 1, 2]) {
|
|
||||||
const latest = parseInt(latestVersion[k])
|
|
||||||
const current = parseInt(currentVersion[k])
|
|
||||||
if (latest > current) {
|
|
||||||
log('')
|
|
||||||
return { result: true, version: latestVersionText }
|
|
||||||
} else if (latest < current) {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
if (compare(latestVersion, version, '>')) {
|
||||||
|
return { result: true, version: latestVersion }
|
||||||
}
|
}
|
||||||
return { result: false, version: version }
|
return { result: false, version: version }
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import { ReceiveCmdS } from '../hook'
|
|||||||
import { RkeyManager } from '@/ntqqapi/helper/rkey'
|
import { RkeyManager } from '@/ntqqapi/helper/rkey'
|
||||||
import { OnRichMediaDownloadCompleteParams, Peer } from '@/ntqqapi/types/msg'
|
import { OnRichMediaDownloadCompleteParams, Peer } from '@/ntqqapi/types/msg'
|
||||||
import { calculateFileMD5 } from '@/common/utils/file'
|
import { calculateFileMD5 } from '@/common/utils/file'
|
||||||
import { fileTypeFromFile } from 'file-type'
|
|
||||||
import { copyFile, stat, unlink } from 'node:fs/promises'
|
import { copyFile, stat, unlink } from 'node:fs/promises'
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
@ -56,7 +55,12 @@ export class NTQQFileApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getFileType(filePath: string) {
|
async getFileType(filePath: string) {
|
||||||
return fileTypeFromFile(filePath)
|
return await invoke<{
|
||||||
|
ext: string
|
||||||
|
mime: string
|
||||||
|
}>(NTMethod.FILE_TYPE, [filePath], {
|
||||||
|
className: NTClass.FS_API
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上传文件到 QQ 的文件夹 */
|
/** 上传文件到 QQ 的文件夹 */
|
||||||
@ -111,8 +115,7 @@ export class NTQQFileApi extends Service {
|
|||||||
}
|
}
|
||||||
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
||||||
'nodeIKernelMsgService/downloadRichMedia',
|
'nodeIKernelMsgService/downloadRichMedia',
|
||||||
[
|
[{
|
||||||
{
|
|
||||||
getReq: {
|
getReq: {
|
||||||
fileModelId: '0',
|
fileModelId: '0',
|
||||||
downloadSourceType: 0,
|
downloadSourceType: 0,
|
||||||
@ -125,9 +128,7 @@ export class NTQQFileApi extends Service {
|
|||||||
downloadType: 1,
|
downloadType: 1,
|
||||||
filePath: thumbPath,
|
filePath: thumbPath,
|
||||||
},
|
},
|
||||||
},
|
}],
|
||||||
null,
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
||||||
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
||||||
@ -186,14 +187,11 @@ export class NTQQFileApi extends Service {
|
|||||||
async downloadFileForModelId(peer: Peer, fileModelId: string, timeout = 2 * Time.minute) {
|
async downloadFileForModelId(peer: Peer, fileModelId: string, timeout = 2 * Time.minute) {
|
||||||
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
||||||
'nodeIKernelRichMediaService/downloadFileForModelId',
|
'nodeIKernelRichMediaService/downloadFileForModelId',
|
||||||
[
|
[{
|
||||||
{
|
|
||||||
peer,
|
peer,
|
||||||
fileModelIdList: [fileModelId],
|
fileModelIdList: [fileModelId],
|
||||||
save_path: ''
|
save_path: ''
|
||||||
},
|
}],
|
||||||
null,
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
||||||
cmdCB: payload => payload.notifyInfo.fileModelId === fileModelId,
|
cmdCB: payload => payload.notifyInfo.fileModelId === fileModelId,
|
||||||
@ -211,7 +209,7 @@ export class NTQQFileCacheApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setCacheSilentScan(isSilent: boolean = true) {
|
async setCacheSilentScan(isSilent: boolean = true) {
|
||||||
return await invoke<GeneralCallResult>(NTMethod.CACHE_SET_SILENCE, [{ isSilent }, null])
|
return await invoke<GeneralCallResult>(NTMethod.CACHE_SET_SILENCE, [{ isSilent }])
|
||||||
}
|
}
|
||||||
|
|
||||||
getCacheSessionPathList() {
|
getCacheSessionPathList() {
|
||||||
@ -225,7 +223,7 @@ export class NTQQFileCacheApi extends Service {
|
|||||||
|
|
||||||
scanCache() {
|
scanCache() {
|
||||||
invoke<GeneralCallResult>(ReceiveCmdS.CACHE_SCAN_FINISH, [], { registerEvent: true })
|
invoke<GeneralCallResult>(ReceiveCmdS.CACHE_SCAN_FINISH, [], { registerEvent: true })
|
||||||
return invoke<CacheScanResult>(NTMethod.CACHE_SCAN, [null, null], { timeout: 300 * Time.second })
|
return invoke<CacheScanResult>(NTMethod.CACHE_SCAN, [], { timeout: 300 * Time.second })
|
||||||
}
|
}
|
||||||
|
|
||||||
getHotUpdateCachePath() {
|
getHotUpdateCachePath() {
|
||||||
@ -245,13 +243,13 @@ export class NTQQFileCacheApi extends Service {
|
|||||||
pageSize: pageSize,
|
pageSize: pageSize,
|
||||||
order: 1,
|
order: 1,
|
||||||
lastRecord: _lastRecord,
|
lastRecord: _lastRecord,
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
||||||
return await invoke<GeneralCallResult>(NTMethod.CACHE_CHAT_CLEAR, [{
|
return await invoke<GeneralCallResult>(NTMethod.CACHE_CHAT_CLEAR, [{
|
||||||
chats,
|
chats,
|
||||||
fileKeys,
|
fileKeys,
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,11 @@ export class NTQQFriendApi extends Service {
|
|||||||
categroyMbCount: number
|
categroyMbCount: number
|
||||||
buddyList: Friend[]
|
buddyList: Friend[]
|
||||||
}[]
|
}[]
|
||||||
}>(
|
}>('getBuddyList', [], {
|
||||||
'getBuddyList',
|
|
||||||
[],
|
|
||||||
{
|
|
||||||
className: NTClass.NODE_STORE_API,
|
className: NTClass.NODE_STORE_API,
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
afterFirstCmd: false,
|
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)
|
||||||
@ -121,13 +117,13 @@ export class NTQQFriendApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyRecommendContact(uin: string) {
|
async getBuddyRecommendContact(uin: string) {
|
||||||
const ret = await invoke('nodeIKernelBuddyService/getBuddyRecommendContactArkJson', [{ uin }, null])
|
const ret = await invoke('nodeIKernelBuddyService/getBuddyRecommendContactArkJson', [{ uin }])
|
||||||
return ret.arkMsg
|
return ret.arkMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
async setBuddyRemark(uid: string, remark: string) {
|
async setBuddyRemark(uid: string, remark: string) {
|
||||||
return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{
|
return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{
|
||||||
remarkParams: { uid, remark }
|
remarkParams: { uid, remark }
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,7 @@ import { invoke, NTClass, NTMethod } from '../ntcall'
|
|||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { NTQQWindows } from './window'
|
import { NTQQWindows } from './window'
|
||||||
import { getSession } from '../wrapper'
|
import { getSession } from '../wrapper'
|
||||||
import { NodeIKernelGroupService } from '../services'
|
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { isNumeric } from '@/common/utils/misc'
|
|
||||||
|
|
||||||
declare module 'cordis' {
|
declare module 'cordis' {
|
||||||
interface Context {
|
interface Context {
|
||||||
@ -28,8 +26,6 @@ declare module 'cordis' {
|
|||||||
export class NTQQGroupApi extends Service {
|
export class NTQQGroupApi extends Service {
|
||||||
static inject = ['ntWindowApi']
|
static inject = ['ntWindowApi']
|
||||||
|
|
||||||
public groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntGroupApi', true)
|
super(ctx, 'ntGroupApi', true)
|
||||||
}
|
}
|
||||||
@ -51,49 +47,37 @@ export class NTQQGroupApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMembers(groupCode: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembers(groupCode: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const session = getSession()
|
|
||||||
let result: Awaited<ReturnType<NodeIKernelGroupService['getNextMemberList']>>
|
|
||||||
if (session) {
|
|
||||||
const groupService = session.getGroupService()
|
|
||||||
const sceneId = groupService.createMemberListScene(groupCode, 'groupMemberList_MainWindow')
|
|
||||||
result = await groupService.getNextMemberList(sceneId, undefined, num)
|
|
||||||
} else {
|
|
||||||
const sceneId = await invoke(NTMethod.GROUP_MEMBER_SCENE, [{ groupCode, scene: 'groupMemberList_MainWindow' }])
|
const sceneId = await invoke(NTMethod.GROUP_MEMBER_SCENE, [{ groupCode, scene: 'groupMemberList_MainWindow' }])
|
||||||
result = await invoke(NTMethod.GROUP_MEMBERS, [{ sceneId, num }, null])
|
const data = await invoke(NTMethod.GROUP_MEMBERS, [{ sceneId, num }])
|
||||||
|
if (data.errCode !== 0) {
|
||||||
|
throw new Error('获取群成员列表出错,' + data.errMsg)
|
||||||
}
|
}
|
||||||
if (result.errCode !== 0) {
|
return data.result.infos
|
||||||
throw ('获取群成员列表出错,' + result.errMsg)
|
|
||||||
}
|
|
||||||
return result.result.infos
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMember(groupCode: string, memberUinOrUid: string) {
|
async getGroupMember(groupCode: string, uid: string, forceUpdate = false) {
|
||||||
if (!this.groupMembers.has(groupCode)) {
|
invoke('nodeIKernelGroupListener/onMemberInfoChange', [], {
|
||||||
try {
|
registerEvent: true
|
||||||
// 更新群成员列表
|
})
|
||||||
this.groupMembers.set(groupCode, await this.getGroupMembers(groupCode))
|
|
||||||
|
const data = await invoke<{
|
||||||
|
groupCode: string
|
||||||
|
members: Map<string, GroupMember>
|
||||||
|
}>(
|
||||||
|
'nodeIKernelGroupService/getMemberInfo',
|
||||||
|
[{
|
||||||
|
groupCode,
|
||||||
|
uids: [uid],
|
||||||
|
forceUpdate
|
||||||
|
}],
|
||||||
|
{
|
||||||
|
cbCmd: 'nodeIKernelGroupListener/onMemberInfoChange',
|
||||||
|
afterFirstCmd: false,
|
||||||
|
cmdCB: payload => payload.members.has(uid),
|
||||||
|
timeout: 2000
|
||||||
}
|
}
|
||||||
catch (e) {
|
)
|
||||||
return
|
return data.members.get(uid)!
|
||||||
}
|
|
||||||
}
|
|
||||||
let members = this.groupMembers.get(groupCode)!
|
|
||||||
const getMember = () => {
|
|
||||||
let member: GroupMember | undefined = undefined
|
|
||||||
if (isNumeric(memberUinOrUid)) {
|
|
||||||
member = Array.from(members.values()).find(member => member.uin === memberUinOrUid)
|
|
||||||
} else {
|
|
||||||
member = members.get(memberUinOrUid)
|
|
||||||
}
|
|
||||||
return member
|
|
||||||
}
|
|
||||||
let member = getMember()
|
|
||||||
if (!member) {
|
|
||||||
this.groupMembers.set(groupCode, await this.getGroupMembers(groupCode))
|
|
||||||
members = this.groupMembers.get(groupCode)!
|
|
||||||
member = getMember()
|
|
||||||
}
|
|
||||||
return member
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupIgnoreNotifies() {
|
async getGroupIgnoreNotifies() {
|
||||||
@ -105,11 +89,12 @@ export class NTQQGroupApi extends Service {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSingleScreenNotifies(num: number) {
|
async getSingleScreenNotifies(number: number, startSeq = '') {
|
||||||
invoke(ReceiveCmdS.GROUP_NOTIFY, [], { registerEvent: true })
|
invoke(ReceiveCmdS.GROUP_NOTIFY, [], { registerEvent: true })
|
||||||
|
|
||||||
return (await invoke<GroupNotifies>(
|
return (await invoke<GroupNotifies>(
|
||||||
'nodeIKernelGroupService/getSingleScreenNotifies',
|
'nodeIKernelGroupService/getSingleScreenNotifies',
|
||||||
[{ doubt: false, startSeq: '', number: num }, null],
|
[{ doubt: false, startSeq, number }],
|
||||||
{
|
{
|
||||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
@ -122,18 +107,6 @@ export class NTQQGroupApi extends Service {
|
|||||||
const groupCode = flagitem[0]
|
const groupCode = flagitem[0]
|
||||||
const seq = flagitem[1]
|
const seq = flagitem[1]
|
||||||
const type = parseInt(flagitem[2])
|
const type = parseInt(flagitem[2])
|
||||||
const session = getSession()
|
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().operateSysNotify(false, {
|
|
||||||
operateType, // 2 拒绝
|
|
||||||
targetMsg: {
|
|
||||||
seq, // 通知序列号
|
|
||||||
type,
|
|
||||||
groupCode,
|
|
||||||
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.HANDLE_GROUP_REQUEST, [{
|
return await invoke(NTMethod.HANDLE_GROUP_REQUEST, [{
|
||||||
doubt: false,
|
doubt: false,
|
||||||
operateMsg: {
|
operateMsg: {
|
||||||
@ -145,45 +118,24 @@ export class NTQQGroupApi extends Service {
|
|||||||
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
postscript: reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, null])
|
}])
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async quitGroup(groupCode: string) {
|
async quitGroup(groupCode: string) {
|
||||||
const session = getSession()
|
return await invoke(NTMethod.QUIT_GROUP, [{ groupCode }])
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().quitGroup(groupCode)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.QUIT_GROUP, [{ groupCode }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async kickMember(groupCode: string, kickUids: string[], refuseForever = false, kickReason = '') {
|
async kickMember(groupCode: string, kickUids: string[], refuseForever = false, kickReason = '') {
|
||||||
const session = getSession()
|
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().kickMember(groupCode, kickUids, refuseForever, kickReason)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.KICK_MEMBER, [{ groupCode, kickUids, refuseForever, kickReason }])
|
return await invoke(NTMethod.KICK_MEMBER, [{ groupCode, kickUids, refuseForever, kickReason }])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/** timeStamp为秒数, 0为解除禁言 */
|
||||||
async banMember(groupCode: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
async banMember(groupCode: string, memList: Array<{ uid: string, timeStamp: number }>) {
|
||||||
// timeStamp为秒数, 0为解除禁言
|
|
||||||
const session = getSession()
|
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().setMemberShutUp(groupCode, memList)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.MUTE_MEMBER, [{ groupCode, memList }])
|
return await invoke(NTMethod.MUTE_MEMBER, [{ groupCode, memList }])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async banGroup(groupCode: string, shutUp: boolean) {
|
async banGroup(groupCode: string, shutUp: boolean) {
|
||||||
const session = getSession()
|
return await invoke(NTMethod.MUTE_GROUP, [{ groupCode, shutUp }])
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().setGroupShutUp(groupCode, shutUp)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.MUTE_GROUP, [{ groupCode, shutUp }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMemberCard(groupCode: string, memberUid: string, cardName: string) {
|
async setMemberCard(groupCode: string, memberUid: string, cardName: string) {
|
||||||
@ -191,7 +143,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().modifyMemberCardName(groupCode, memberUid, cardName)
|
return session.getGroupService().modifyMemberCardName(groupCode, memberUid, cardName)
|
||||||
} else {
|
} else {
|
||||||
return await invoke(NTMethod.SET_MEMBER_CARD, [{ groupCode, uid: memberUid, cardName }, null])
|
return await invoke(NTMethod.SET_MEMBER_CARD, [{ groupCode, uid: memberUid, cardName }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,21 +152,16 @@ export class NTQQGroupApi extends Service {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getGroupService().modifyMemberRole(groupCode, memberUid, role)
|
return session.getGroupService().modifyMemberRole(groupCode, memberUid, role)
|
||||||
} else {
|
} else {
|
||||||
return await invoke(NTMethod.SET_MEMBER_ROLE, [{ groupCode, uid: memberUid, role }, null])
|
return await invoke(NTMethod.SET_MEMBER_ROLE, [{ groupCode, uid: memberUid, role }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupName(groupCode: string, groupName: string) {
|
async setGroupName(groupCode: string, groupName: string) {
|
||||||
const session = getSession()
|
return await invoke(NTMethod.SET_GROUP_NAME, [{ groupCode, groupName }])
|
||||||
if (session) {
|
|
||||||
return session.getGroupService().modifyGroupName(groupCode, groupName, false)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.SET_GROUP_NAME, [{ groupCode, groupName }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupRemainAtTimes(groupCode: string) {
|
async getGroupRemainAtTimes(groupCode: string) {
|
||||||
return await invoke(NTMethod.GROUP_AT_ALL_REMAIN_COUNT, [{ groupCode }, null])
|
return await invoke(NTMethod.GROUP_AT_ALL_REMAIN_COUNT, [{ groupCode }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeGroupEssence(groupCode: string, msgId: string) {
|
async removeGroupEssence(groupCode: string, msgId: string) {
|
||||||
@ -235,7 +182,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
msgRandom: Number(data?.msgList[0].msgRandom),
|
msgRandom: Number(data?.msgList[0].msgRandom),
|
||||||
msgSeq: Number(data?.msgList[0].msgSeq)
|
msgSeq: Number(data?.msgList[0].msgSeq)
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,33 +204,30 @@ export class NTQQGroupApi extends Service {
|
|||||||
msgRandom: Number(data?.msgList[0].msgRandom),
|
msgRandom: Number(data?.msgList[0].msgRandom),
|
||||||
msgSeq: Number(data?.msgList[0].msgSeq)
|
msgSeq: Number(data?.msgList[0].msgSeq)
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createGroupFileFolder(groupId: string, folderName: string) {
|
async createGroupFileFolder(groupId: string, folderName: string) {
|
||||||
return await invoke('nodeIKernelRichMediaService/createGroupFolder', [{ groupId, folderName }, null])
|
return await invoke('nodeIKernelRichMediaService/createGroupFolder', [{ groupId, folderName }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroupFileFolder(groupId: string, folderId: string) {
|
async deleteGroupFileFolder(groupId: string, folderId: string) {
|
||||||
return await invoke('nodeIKernelRichMediaService/deleteGroupFolder', [{ groupId, folderId }, null])
|
return await invoke('nodeIKernelRichMediaService/deleteGroupFolder', [{ groupId, folderId }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroupFile(groupId: string, fileIdList: string[], busIdList: number[]) {
|
async deleteGroupFile(groupId: string, fileIdList: string[], busIdList: number[]) {
|
||||||
return await invoke('nodeIKernelRichMediaService/deleteGroupFile', [{ groupId, busIdList, fileIdList }, null])
|
return await invoke('nodeIKernelRichMediaService/deleteGroupFile', [{ groupId, busIdList, fileIdList }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupFileList(groupId: string, fileListForm: GetFileListParam) {
|
async getGroupFileList(groupId: string, fileListForm: GetFileListParam) {
|
||||||
invoke('nodeIKernelMsgListener/onGroupFileInfoUpdate', [], { registerEvent: true })
|
invoke('nodeIKernelMsgListener/onGroupFileInfoUpdate', [], { registerEvent: true })
|
||||||
const data = await invoke<{ fileInfo: GroupFileInfo }>(
|
const data = await invoke<{ fileInfo: GroupFileInfo }>(
|
||||||
'nodeIKernelRichMediaService/getGroupFileList',
|
'nodeIKernelRichMediaService/getGroupFileList',
|
||||||
[
|
[{
|
||||||
{
|
|
||||||
groupId,
|
groupId,
|
||||||
fileListForm
|
fileListForm
|
||||||
},
|
}],
|
||||||
null,
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
cbCmd: 'nodeIKernelMsgListener/onGroupFileInfoUpdate',
|
cbCmd: 'nodeIKernelMsgListener/onGroupFileInfoUpdate',
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
@ -296,17 +240,17 @@ export class NTQQGroupApi extends Service {
|
|||||||
async publishGroupBulletin(groupCode: string, req: PublishGroupBulletinReq) {
|
async publishGroupBulletin(groupCode: string, req: PublishGroupBulletinReq) {
|
||||||
const ntUserApi = this.ctx.get('ntUserApi')!
|
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||||
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||||
return await invoke('nodeIKernelGroupService/publishGroupBulletin', [{ groupCode, psKey, req }, null])
|
return await invoke('nodeIKernelGroupService/publishGroupBulletin', [{ groupCode, psKey, req }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadGroupBulletinPic(groupCode: string, path: string) {
|
async uploadGroupBulletinPic(groupCode: string, path: string) {
|
||||||
const ntUserApi = this.ctx.get('ntUserApi')!
|
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||||
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||||
return await invoke('nodeIKernelGroupService/uploadGroupBulletinPic', [{ groupCode, psKey, path }, null])
|
return await invoke('nodeIKernelGroupService/uploadGroupBulletinPic', [{ groupCode, psKey, path }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupRecommendContact(groupCode: string) {
|
async getGroupRecommendContact(groupCode: string) {
|
||||||
const ret = await invoke('nodeIKernelGroupService/getGroupRecommendContactArkJson', [{ groupCode }, null])
|
const ret = await invoke('nodeIKernelGroupService/getGroupRecommendContactArkJson', [{ groupCode }])
|
||||||
return ret.arkJson
|
return ret.arkJson
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +261,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
msgSeq: +msgSeq,
|
msgSeq: +msgSeq,
|
||||||
msgRandom: +msgRandom
|
msgRandom: +msgRandom
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupHonorList(groupCode: string) {
|
async getGroupHonorList(groupCode: string) {
|
||||||
@ -326,31 +270,33 @@ export class NTQQGroupApi extends Service {
|
|||||||
req: {
|
req: {
|
||||||
groupCode: [+groupCode]
|
groupCode: [+groupCode]
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupAllInfo(groupCode: string, timeout = 1000) {
|
async getGroupAllInfo(groupCode: string) {
|
||||||
invoke('nodeIKernelGroupListener/onGroupAllInfoChange', [], { registerEvent: true })
|
invoke('nodeIKernelGroupListener/onGroupAllInfoChange', [], {
|
||||||
|
registerEvent: true
|
||||||
|
})
|
||||||
|
|
||||||
return await invoke<{ groupAll: GroupAllInfo }>(
|
return await invoke<{ groupAll: GroupAllInfo }>(
|
||||||
'nodeIKernelGroupService/getGroupAllInfo',
|
'nodeIKernelGroupService/getGroupAllInfo',
|
||||||
[
|
[{
|
||||||
{
|
|
||||||
groupCode,
|
groupCode,
|
||||||
source: 4
|
source: 4
|
||||||
},
|
}],
|
||||||
null
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
cbCmd: 'nodeIKernelGroupListener/onGroupAllInfoChange',
|
cbCmd: 'nodeIKernelGroupListener/onGroupAllInfoChange',
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
cmdCB: payload => payload.groupAll.groupCode === groupCode,
|
cmdCB: payload => payload.groupAll.groupCode === groupCode
|
||||||
timeout
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupBulletinList(groupCode: string) {
|
async getGroupBulletinList(groupCode: string) {
|
||||||
invoke('nodeIKernelGroupListener/onGetGroupBulletinListResult', [], { registerEvent: true })
|
invoke('nodeIKernelGroupListener/onGetGroupBulletinListResult', [], {
|
||||||
|
registerEvent: true
|
||||||
|
})
|
||||||
|
|
||||||
const ntUserApi = this.ctx.get('ntUserApi')!
|
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||||
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||||
return await invoke<{
|
return await invoke<{
|
||||||
@ -377,4 +323,8 @@ export class NTQQGroupApi extends Service {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setGroupAvatar(groupCode: string, path: string) {
|
||||||
|
return await invoke('nodeIKernelGroupService/setHeader', [{ path, groupCode }])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { invoke, NTMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult } from '../services'
|
|
||||||
import { RawMessage, SendMessageElement, Peer, ChatType } from '../types'
|
import { RawMessage, SendMessageElement, Peer, ChatType } from '../types'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { selfInfo } from '@/common/globalVars'
|
import { selfInfo } from '@/common/globalVars'
|
||||||
|
|
||||||
@ -19,37 +17,27 @@ export class NTQQMsgApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getTempChatInfo(chatType: ChatType, peerUid: string) {
|
async getTempChatInfo(chatType: ChatType, peerUid: string) {
|
||||||
const session = getSession()
|
return await invoke('nodeIKernelMsgService/getTempChatInfo', [{ chatType, peerUid }])
|
||||||
if (session) {
|
|
||||||
return session.getMsgService().getTempChatInfo(chatType, peerUid)
|
|
||||||
} else {
|
|
||||||
return await invoke('nodeIKernelMsgService/getTempChatInfo', [{ chatType, peerUid }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, setEmoji: boolean) {
|
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/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
|
||||||
const emojiType = emojiId.length > 3 ? '2' : '1'
|
const emojiType = emojiId.length > 3 ? '2' : '1'
|
||||||
return await invoke(NTMethod.EMOJI_LIKE, [{ peer, msgSeq, emojiId, emojiType, setEmoji }])
|
return await invoke(NTMethod.EMOJI_LIKE, [{ peer, msgSeq, emojiId, emojiType, setEmoji }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string) {
|
||||||
const session = getSession()
|
return await invoke(NTMethod.GET_MULTI_MSG, [{ peer, rootMsgId, parentMsgId }])
|
||||||
if (session) {
|
|
||||||
return session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId)
|
|
||||||
} else {
|
|
||||||
return await invoke(NTMethod.GET_MULTI_MSG, [{ peer, rootMsgId, parentMsgId }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateChat(peer: Peer) {
|
async activateChat(peer: Peer) {
|
||||||
return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_PREVIEW, [{ peer, cnt: 1 }, null])
|
return await invoke(NTMethod.ACTIVE_CHAT_PREVIEW, [{ peer, cnt: 1 }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateChatAndGetHistory(peer: Peer) {
|
async activateChatAndGetHistory(peer: Peer, cnt: number) {
|
||||||
return await invoke<GeneralCallResult>(NTMethod.ACTIVE_CHAT_HISTORY, [{ peer, cnt: 20 }, null])
|
return await invoke(NTMethod.ACTIVE_CHAT_HISTORY, [{ peer, cnt, msgId: '0', queryOrder: true }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAioFirstViewLatestMsgs(peer: Peer, cnt: number) {
|
async getAioFirstViewLatestMsgs(peer: Peer, cnt: number) {
|
||||||
@ -62,9 +50,9 @@ export class NTQQMsgApi extends Service {
|
|||||||
return await invoke('nodeIKernelMsgService/getMsgsByMsgId', [{ peer, msgIds }])
|
return await invoke('nodeIKernelMsgService/getMsgsByMsgId', [{ peer, msgIds }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgHistory(peer: Peer, msgId: string, cnt: number, isReverseOrder: boolean = false) {
|
async getMsgHistory(peer: Peer, msgId: string, cnt: number, queryOrder = false) {
|
||||||
// 消息时间从旧到新
|
// 默认情况下消息时间从旧到新
|
||||||
return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder: isReverseOrder }])
|
return await invoke(NTMethod.HISTORY_MSG, [{ peer, msgId, cnt, queryOrder }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async recallMsg(peer: Peer, msgIds: string[]) {
|
async recallMsg(peer: Peer, msgIds: string[]) {
|
||||||
@ -96,6 +84,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
timeout
|
timeout
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
delete peer.guildId
|
||||||
return data.msgList.find(msgRecord => msgRecord.guildId === uniqueId)
|
return data.msgList.find(msgRecord => msgRecord.guildId === uniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +113,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
delete destPeer.guildId
|
||||||
return data.msgList.filter(msgRecord => msgRecord.guildId === uniqueId)
|
return data.msgList.filter(msgRecord => msgRecord.guildId === uniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,27 +161,8 @@ export class NTQQMsgApi extends Service {
|
|||||||
throw new Error('转发消息超时')
|
throw new Error('转发消息超时')
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgsBySeqAndCount(peer: Peer, msgSeq: string, count: number, desc: boolean, z: boolean) {
|
|
||||||
const session = getSession()
|
|
||||||
if (session) {
|
|
||||||
return await session.getMsgService().getMsgsBySeqAndCount(peer, msgSeq, count, desc, z)
|
|
||||||
} else {
|
|
||||||
return await invoke('nodeIKernelMsgService/getMsgsBySeqAndCount', [{
|
|
||||||
peer,
|
|
||||||
cnt: count,
|
|
||||||
msgSeq,
|
|
||||||
queryOrder: desc
|
|
||||||
}, null])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getSingleMsg(peer: Peer, msgSeq: string) {
|
async getSingleMsg(peer: Peer, msgSeq: string) {
|
||||||
const session = getSession()
|
return await invoke('nodeIKernelMsgService/getSingleMsg', [{ peer, msgSeq }])
|
||||||
if (session) {
|
|
||||||
return await session.getMsgService().getSingleMsg(peer, msgSeq)
|
|
||||||
} else {
|
|
||||||
return await invoke('nodeIKernelMsgService/getSingleMsg', [{ peer, msgSeq }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryFirstMsgBySeq(peer: Peer, msgSeq: string) {
|
async queryFirstMsgBySeq(peer: Peer, msgSeq: string) {
|
||||||
@ -209,7 +180,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
isIncludeCurrent: true,
|
isIncludeCurrent: true,
|
||||||
pageLimit: 1,
|
pageLimit: 1,
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryMsgsWithFilterExBySeq(peer: Peer, msgSeq: string, filterMsgTime: string, filterSendersUid: string[] = []) {
|
async queryMsgsWithFilterExBySeq(peer: Peer, msgSeq: string, filterMsgTime: string, filterSendersUid: string[] = []) {
|
||||||
@ -231,7 +202,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setMsgRead(peer: Peer) {
|
async setMsgRead(peer: Peer) {
|
||||||
return await invoke('nodeIKernelMsgService/setMsgRead', [{ peer }, null])
|
return await invoke('nodeIKernelMsgService/setMsgRead', [{ peer }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number) {
|
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number) {
|
||||||
@ -250,7 +221,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
count,
|
count,
|
||||||
backwardFetch: true,
|
backwardFetch: true,
|
||||||
forceRefresh: true
|
forceRefresh: true
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateMsgUniqueId(chatType: number) {
|
async generateMsgUniqueId(chatType: number) {
|
||||||
@ -289,6 +260,6 @@ export class NTQQMsgApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getServerTime() {
|
async getServerTime() {
|
||||||
return await invoke('nodeIKernelMSFService/getServerTime', [null])
|
return await invoke('nodeIKernelMSFService/getServerTime', [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfo, UserDetailSource, ProfileBizType, SimpleInfo } from '../types'
|
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfo, UserDetailSource, ProfileBizType, SimpleInfo } from '../types'
|
||||||
import { invoke } from '../ntcall'
|
import { invoke } from '../ntcall'
|
||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { isNullable, Time } from 'cosmokit'
|
import { isNullable, Time } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
@ -20,15 +19,12 @@ export class NTQQUserApi extends Service {
|
|||||||
super(ctx, 'ntUserApi', true)
|
super(ctx, 'ntUserApi', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setQQAvatar(path: string) {
|
async setSelfAvatar(path: string) {
|
||||||
return await invoke(
|
return await invoke(
|
||||||
'nodeIKernelProfileService/setHeader',
|
'nodeIKernelProfileService/setHeader',
|
||||||
[
|
[{ path }],
|
||||||
{ path },
|
|
||||||
null,
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
timeout: 10 * Time.second, // 10秒不一定够
|
timeout: 10 * Time.second // 10秒不一定够
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -92,49 +88,25 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPSkey(domains: string[]) {
|
async getPSkey(domains: string[]) {
|
||||||
return await invoke('nodeIKernelTipOffService/getPskey', [{ domains, isForNewPCQQ: true }, null])
|
return await invoke('nodeIKernelTipOffService/getPskey', [{ domains, isForNewPCQQ: true }])
|
||||||
}
|
}
|
||||||
|
|
||||||
async like(uid: string, count = 1) {
|
async like(uid: string, count = 1) {
|
||||||
const session = getSession()
|
|
||||||
if (session) {
|
|
||||||
return session.getProfileLikeService().setBuddyProfileLike({
|
|
||||||
friendUid: uid,
|
|
||||||
sourceId: 71,
|
|
||||||
doLikeCount: count,
|
|
||||||
doLikeTollCount: 0
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return await invoke(
|
return await invoke(
|
||||||
'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
'nodeIKernelProfileLikeService/setBuddyProfileLike',
|
||||||
[
|
[{
|
||||||
{
|
|
||||||
doLikeUserInfo: {
|
doLikeUserInfo: {
|
||||||
friendUid: uid,
|
friendUid: uid,
|
||||||
sourceId: 71,
|
sourceId: 71,
|
||||||
doLikeCount: count,
|
doLikeCount: count,
|
||||||
doLikeTollCount: 0
|
doLikeTollCount: 0
|
||||||
}
|
}
|
||||||
},
|
}]
|
||||||
null,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async getUidByUinV1(uin: string) {
|
async getUidByUinV1(uin: string, groupCode?: string) {
|
||||||
let uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [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()) {
|
|
||||||
if (member.uin === uin) {
|
|
||||||
uid = member.uid
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (uid) break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
const unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid //特殊转换
|
const unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid //特殊转换
|
||||||
if (unveifyUid.indexOf('*') === -1) {
|
if (unveifyUid.indexOf('*') === -1) {
|
||||||
@ -145,29 +117,30 @@ export class NTQQUserApi extends Service {
|
|||||||
const friends = await this.ctx.ntFriendApi.getFriends() //从好友列表转
|
const friends = await this.ctx.ntFriendApi.getFriends() //从好友列表转
|
||||||
uid = friends.find(item => item.uin === uin)?.uid
|
uid = friends.find(item => item.uin === uin)?.uid
|
||||||
}
|
}
|
||||||
|
if (!uid && groupCode) {
|
||||||
|
const members = await this.ctx.ntGroupApi.getGroupMembers(groupCode)
|
||||||
|
uid = Array.from(members.values()).find(e => e.uin === uin)?.uid
|
||||||
|
}
|
||||||
return uid
|
return uid
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUinV2(uin: string, groupCode?: string) {
|
async getUidByUinV2(uin: string) {
|
||||||
let uid = (await invoke('nodeIKernelGroupService/getUidByUins', [{ uin: [uin] }])).uids.get(uin)
|
let uid = (await invoke('nodeIKernelGroupService/getUidByUins', [{ uinList: [uin] }])).uids.get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await invoke('nodeIKernelProfileService/getUidByUin', [{ callFrom: 'FriendsServiceImpl', uin: [uin] }])).get(uin)
|
uid = (await invoke('nodeIKernelProfileService/getUidByUin', [{ callFrom: 'FriendsServiceImpl', uin: [uin] }])).get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [uin] }])).uidInfo.get(uin)
|
uid = (await invoke('nodeIKernelUixConvertService/getUid', [{ uins: [uin] }])).uidInfo.get(uin)
|
||||||
if (uid) return uid
|
if (uid) return uid
|
||||||
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid
|
const unveifyUid = (await this.getUserDetailInfoByUinV2(uin)).detail.uid
|
||||||
if (!unveifyUid.includes('*')) return unveifyUid
|
//if (!unveifyUid.includes('*')) return unveifyUid
|
||||||
if (groupCode) {
|
return unveifyUid
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(groupCode, uin)
|
|
||||||
return member?.uid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUin(uin: string, groupCode?: string) {
|
async getUidByUin(uin: string, groupCode?: string) {
|
||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return this.getUidByUinV2(uin, groupCode)
|
return this.getUidByUinV2(uin)
|
||||||
}
|
}
|
||||||
return this.getUidByUinV1(uin)
|
return this.getUidByUinV1(uin, groupCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfoByUinV2(uin: string) {
|
async getUserDetailInfoByUinV2(uin: string) {
|
||||||
@ -194,7 +167,7 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getUinByUidV2(uid: string) {
|
async getUinByUidV2(uid: string) {
|
||||||
let uin = (await invoke('nodeIKernelGroupService/getUinByUids', [{ uid: [uid] }])).uins.get(uid)
|
let uin = (await invoke('nodeIKernelGroupService/getUinByUids', [{ uidList: [uid] }])).uins.get(uid)
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
uin = (await invoke('nodeIKernelProfileService/getUinByUid', [{ callFrom: 'FriendsServiceImpl', uid: [uid] }])).get(uid)
|
uin = (await invoke('nodeIKernelProfileService/getUinByUid', [{ callFrom: 'FriendsServiceImpl', uid: [uid] }])).get(uid)
|
||||||
if (uin) return uin
|
if (uin) return uin
|
||||||
@ -214,18 +187,13 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async forceFetchClientKey() {
|
async forceFetchClientKey() {
|
||||||
const session = getSession()
|
return await invoke('nodeIKernelTicketService/forceFetchClientKey', [{ url: '' }])
|
||||||
if (session) {
|
|
||||||
return await session.getTicketService().forceFetchClientKey('')
|
|
||||||
} else {
|
|
||||||
return await invoke('nodeIKernelTicketService/forceFetchClientKey', [{ url: '' }, null])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSelfNick(refresh = true) {
|
async getSelfNick(refresh = true) {
|
||||||
if ((refresh || !selfInfo.nick) && selfInfo.uid) {
|
if ((refresh || !selfInfo.nick) && selfInfo.uid) {
|
||||||
const { profiles } = await this.getUserSimpleInfo(selfInfo.uid)
|
const data = await this.getUserSimpleInfo(selfInfo.uid)
|
||||||
selfInfo.nick = profiles[selfInfo.uid].coreInfo.nick
|
selfInfo.nick = data.coreInfo.nick
|
||||||
}
|
}
|
||||||
return selfInfo.nick
|
return selfInfo.nick
|
||||||
}
|
}
|
||||||
@ -237,7 +205,7 @@ export class NTQQUserApi extends Service {
|
|||||||
extStatus,
|
extStatus,
|
||||||
batteryStatus,
|
batteryStatus,
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProfileLike(uid: string) {
|
async getProfileLike(uid: string) {
|
||||||
@ -252,11 +220,11 @@ export class NTQQUserApi extends Service {
|
|||||||
start: 0,
|
start: 0,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
}
|
}
|
||||||
}, null])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserSimpleInfo(uid: string, force = true) {
|
async getUserSimpleInfo(uid: string, force = true) {
|
||||||
return await invoke<{ profiles: Record<string, SimpleInfo> }>(
|
const data = await invoke<{ profiles: Record<string, SimpleInfo> }>(
|
||||||
'nodeIKernelProfileService/getUserSimpleInfo',
|
'nodeIKernelProfileService/getUserSimpleInfo',
|
||||||
[{
|
[{
|
||||||
uids: [uid],
|
uids: [uid],
|
||||||
@ -268,6 +236,7 @@ export class NTQQUserApi extends Service {
|
|||||||
cmdCB: payload => !isNullable(payload.profiles[uid]),
|
cmdCB: payload => !isNullable(payload.profiles[uid]),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return data.profiles[uid]
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCoreAndBaseInfo(uids: string[]) {
|
async getCoreAndBaseInfo(uids: string[]) {
|
||||||
|
@ -35,7 +35,7 @@ export class NTQQWindowApi extends Service {
|
|||||||
super(ctx, 'ntWindowApi', true)
|
super(ctx, 'ntWindowApi', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开窗口并获取对应的下发事件
|
/** 打开窗口并获取对应的下发事件 */
|
||||||
async openWindow<R = GeneralCallResult>(
|
async openWindow<R = GeneralCallResult>(
|
||||||
ntQQWindow: NTQQWindow,
|
ntQQWindow: NTQQWindow,
|
||||||
args: unknown[],
|
args: unknown[],
|
||||||
@ -53,7 +53,6 @@ export class NTQQWindowApi extends Service {
|
|||||||
)
|
)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
for (const w of BrowserWindow.getAllWindows()) {
|
for (const w of BrowserWindow.getAllWindows()) {
|
||||||
// log("close window", w.webContents.getURL())
|
|
||||||
if (w.webContents.getURL().indexOf(ntQQWindow.windowUrlHash) != -1) {
|
if (w.webContents.getURL().indexOf(ntQQWindow.windowUrlHash) != -1) {
|
||||||
w.close()
|
w.close()
|
||||||
}
|
}
|
||||||
|
@ -52,15 +52,15 @@ export namespace SendElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reply(msgSeq: string, msgId: string, senderUin: string, senderUinStr: string): SendReplyElement {
|
export function reply(msgSeq: string, msgId: string, senderUin: string): SendReplyElement {
|
||||||
return {
|
return {
|
||||||
elementType: ElementType.Reply,
|
elementType: ElementType.Reply,
|
||||||
elementId: '',
|
elementId: '',
|
||||||
replyElement: {
|
replyElement: {
|
||||||
replayMsgSeq: msgSeq, // raw.msgSeq
|
replayMsgSeq: msgSeq,
|
||||||
replayMsgId: msgId, // raw.msgId
|
replayMsgId: msgId,
|
||||||
senderUin: senderUin,
|
senderUin: senderUin,
|
||||||
senderUinStr: senderUinStr,
|
senderUinStr: senderUin,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,19 +251,19 @@ export namespace SendElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function face(faceId: number): SendFaceElement {
|
export function face(faceId: number, faceType?: number): SendFaceElement {
|
||||||
// 从face_config.json中获取表情名称
|
// 从face_config.json中获取表情名称
|
||||||
const sysFaces = faceConfig.sysface
|
const sysFaces = faceConfig.sysface
|
||||||
const emojiFaces = faceConfig.emoji
|
const face = sysFaces.find(face => face.QSid === String(faceId))
|
||||||
const face = sysFaces.find((face) => face.QSid === faceId.toString())
|
if (!faceType) {
|
||||||
faceId = parseInt(faceId.toString())
|
if (faceId < 222) {
|
||||||
// let faceType = parseInt(faceId.toString().substring(0, 1));
|
faceType = 1
|
||||||
let faceType = 1
|
} else {
|
||||||
if (faceId >= 222) {
|
|
||||||
faceType = 2
|
faceType = 2
|
||||||
}
|
}
|
||||||
if (face?.AniStickerType) {
|
if (face?.AniStickerType) {
|
||||||
faceType = 3;
|
faceType = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
elementType: ElementType.Face,
|
elementType: ElementType.Face,
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
{
|
{
|
||||||
"sysface": [
|
"sysface": [
|
||||||
|
{
|
||||||
|
"QSid": "419",
|
||||||
|
"QDes": "/火车",
|
||||||
|
"IQLid": "419",
|
||||||
|
"AQLid": "419",
|
||||||
|
"EMCode": "10419",
|
||||||
|
"AniStickerType": 3,
|
||||||
|
"AniStickerPackId": "1",
|
||||||
|
"AniStickerId": "47"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"QSid": "392",
|
"QSid": "392",
|
||||||
"QDes": "/龙年快乐",
|
"QDes": "/龙年快乐",
|
||||||
|
@ -123,4 +123,6 @@ export interface NodeIKernelGroupService {
|
|||||||
addGroupEssence(param: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
addGroupEssence(param: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
|
||||||
removeGroupEssence(param: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
removeGroupEssence(param: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
|
||||||
|
setHeader(args: unknown[]): Promise<GeneralCallResult>
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,10 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getAioFirstViewLatestMsgs(peer: Peer, num: number): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
getAioFirstViewLatestMsgs(peer: Peer, num: number): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
||||||
|
|
||||||
|
getAioFirstViewLatestMsgsAndAddActiveChat(...args: unknown[]): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
||||||
|
|
||||||
|
getMsgsIncludeSelfAndAddActiveChat(...args: unknown[]): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
||||||
|
|
||||||
getMsgsIncludeSelf(peer: Peer, msgId: string, count: number, queryOrder: boolean): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
getMsgsIncludeSelf(peer: Peer, msgId: string, count: number, queryOrder: boolean): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
||||||
|
|
||||||
getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, unknownArg: boolean): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, unknownArg: boolean): Promise<GeneralCallResult & { msgList: RawMessage[] }>
|
||||||
|
@ -3,7 +3,7 @@ import { GeneralCallResult } from './common'
|
|||||||
import { Dict } from 'cosmokit'
|
import { Dict } from 'cosmokit'
|
||||||
|
|
||||||
export interface NodeIKernelProfileLikeService {
|
export interface NodeIKernelProfileLikeService {
|
||||||
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number }
|
setBuddyProfileLike(...args: unknown[]): GeneralCallResult & { succCounts: number }
|
||||||
|
|
||||||
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
||||||
info: {
|
info: {
|
||||||
|
@ -197,6 +197,60 @@ export interface PicElement {
|
|||||||
md5HexStr?: string
|
md5HexStr?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TipAioOpGrayTipElement {
|
||||||
|
operateType: number
|
||||||
|
peerUid: string
|
||||||
|
fromGrpCodeOfTmpChat: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TipGroupElementType {
|
||||||
|
MemberIncrease = 1,
|
||||||
|
Kicked = 3, // 被移出群
|
||||||
|
Ban = 8,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TipGroupElement {
|
||||||
|
type: TipGroupElementType // 1是表示有人加入群, 自己加入群也会收到这个
|
||||||
|
role: number
|
||||||
|
groupName: string // 暂时获取不到
|
||||||
|
memberUid: string
|
||||||
|
memberNick: string
|
||||||
|
memberRemark: string
|
||||||
|
adminUid: string
|
||||||
|
adminNick: string
|
||||||
|
adminRemark: string
|
||||||
|
createGroup: null
|
||||||
|
memberAdd?: {
|
||||||
|
showType: number
|
||||||
|
otherAdd?: {
|
||||||
|
uid: string
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
otherAddByOtherQRCode?: unknown
|
||||||
|
otherAddByYourQRCode?: unknown
|
||||||
|
youAddByOtherQRCode?: unknown
|
||||||
|
otherInviteOther?: unknown
|
||||||
|
otherInviteYou?: unknown
|
||||||
|
youInviteOther?: unknown
|
||||||
|
}
|
||||||
|
shutUp?: {
|
||||||
|
curTime: string
|
||||||
|
duration: string // 禁言时间,秒
|
||||||
|
admin: {
|
||||||
|
uid: string
|
||||||
|
card: string
|
||||||
|
name: string
|
||||||
|
role: GroupMemberRole
|
||||||
|
}
|
||||||
|
member: {
|
||||||
|
uid: string
|
||||||
|
card: string
|
||||||
|
name: string
|
||||||
|
role: GroupMemberRole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export enum GrayTipElementSubType {
|
export enum GrayTipElementSubType {
|
||||||
Revoke = 1,
|
Revoke = 1,
|
||||||
Proclamation = 2,
|
Proclamation = 2,
|
||||||
@ -234,6 +288,8 @@ export interface GrayTipElement {
|
|||||||
xmlElement?: {
|
xmlElement?: {
|
||||||
templId: string
|
templId: string
|
||||||
content: string
|
content: string
|
||||||
|
templParam: Map<string, string>
|
||||||
|
members: Map<string, string> // uid -> remark
|
||||||
}
|
}
|
||||||
jsonGrayTipElement?: {
|
jsonGrayTipElement?: {
|
||||||
busiId: string
|
busiId: string
|
||||||
@ -241,7 +297,6 @@ export interface GrayTipElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export enum FaceIndex {
|
export enum FaceIndex {
|
||||||
Dice = 358,
|
Dice = 358,
|
||||||
RPS = 359, // 石头剪刀布
|
RPS = 359, // 石头剪刀布
|
||||||
@ -268,6 +323,10 @@ export interface MarketFaceElement {
|
|||||||
key: string
|
key: string
|
||||||
imageWidth?: number
|
imageWidth?: number
|
||||||
imageHeight?: number
|
imageHeight?: number
|
||||||
|
supportSize?: {
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VideoElement {
|
export interface VideoElement {
|
||||||
@ -326,58 +385,6 @@ export interface InlineKeyboardElement {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TipAioOpGrayTipElement {
|
|
||||||
// 这是什么提示来着?
|
|
||||||
operateType: number
|
|
||||||
peerUid: string
|
|
||||||
fromGrpCodeOfTmpChat: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum TipGroupElementType {
|
|
||||||
MemberIncrease = 1,
|
|
||||||
Kicked = 3, // 被移出群
|
|
||||||
Ban = 8,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TipGroupElement {
|
|
||||||
type: TipGroupElementType // 1是表示有人加入群, 自己加入群也会收到这个
|
|
||||||
role: 0 // 暂时不知
|
|
||||||
groupName: string // 暂时获取不到
|
|
||||||
memberUid: string
|
|
||||||
memberNick: string
|
|
||||||
memberRemark: string
|
|
||||||
adminUid: string
|
|
||||||
adminNick: string
|
|
||||||
adminRemark: string
|
|
||||||
createGroup: null
|
|
||||||
memberAdd?: {
|
|
||||||
showType: 1
|
|
||||||
otherAdd: null
|
|
||||||
otherAddByOtherQRCode: null
|
|
||||||
otherAddByYourQRCode: null
|
|
||||||
youAddByOtherQRCode: null
|
|
||||||
otherInviteOther: null
|
|
||||||
otherInviteYou: null
|
|
||||||
youInviteOther: null
|
|
||||||
}
|
|
||||||
shutUp?: {
|
|
||||||
curTime: string
|
|
||||||
duration: string // 禁言时间,秒
|
|
||||||
admin: {
|
|
||||||
uid: string
|
|
||||||
card: string
|
|
||||||
name: string
|
|
||||||
role: GroupMemberRole
|
|
||||||
}
|
|
||||||
member: {
|
|
||||||
uid: string
|
|
||||||
card: string
|
|
||||||
name: string
|
|
||||||
role: GroupMemberRole
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StructLongMsgElement {
|
export interface StructLongMsgElement {
|
||||||
xmlContent: string
|
xmlContent: string
|
||||||
resId: string
|
resId: string
|
||||||
@ -409,11 +416,25 @@ export interface RawMessage {
|
|||||||
guildId: string
|
guildId: string
|
||||||
sendNickName: string
|
sendNickName: string
|
||||||
sendMemberName?: string // 发送者群名片
|
sendMemberName?: string // 发送者群名片
|
||||||
|
sendRemarkName?: string // 发送者好友备注
|
||||||
chatType: ChatType
|
chatType: ChatType
|
||||||
sendStatus?: number // 消息状态,别人发的2是已撤回,自己发的2是已发送
|
sendStatus?: number // 消息状态,别人发的2是已撤回,自己发的2是已发送
|
||||||
recallTime: string // 撤回时间, "0"是没有撤回
|
recallTime: string // 撤回时间, "0"是没有撤回
|
||||||
records: RawMessage[]
|
records: RawMessage[]
|
||||||
elements: MessageElement[]
|
elements: MessageElement[]
|
||||||
|
peerName: string
|
||||||
|
multiTransInfo?: {
|
||||||
|
status: number
|
||||||
|
msgId: number
|
||||||
|
friendFlag: number
|
||||||
|
fromFaceUrl: string
|
||||||
|
}
|
||||||
|
emojiLikesList: {
|
||||||
|
emojiId: string
|
||||||
|
emojiType: string
|
||||||
|
likesCnt: string
|
||||||
|
isClicked: boolean
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Peer {
|
export interface Peer {
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
export enum GroupNotifyType {
|
export enum GroupNotifyType {
|
||||||
INVITED_BY_MEMBER = 1,
|
InvitedByMember = 1,
|
||||||
REFUSE_INVITED,
|
RefuseInvited,
|
||||||
REFUSED_BY_ADMINI_STRATOR,
|
RefusedByAdminiStrator,
|
||||||
AGREED_TOJOIN_DIRECT, // 有人接受了邀请入群
|
AgreedTojoinDirect, // 有人接受了邀请入群
|
||||||
INVITED_NEED_ADMINI_STRATOR_PASS, // 有人邀请了别人入群
|
InvitedNeedAdminiStratorPass, // 有人邀请了别人入群
|
||||||
AGREED_TO_JOIN_BY_ADMINI_STRATOR,
|
AgreedToJoinByAdminiStrator,
|
||||||
REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS,
|
RequestJoinNeedAdminiStratorPass,
|
||||||
SET_ADMIN,
|
SetAdmin,
|
||||||
KICK_MEMBER_NOTIFY_ADMIN,
|
KickMemberNotifyAdmin,
|
||||||
KICK_MEMBER_NOTIFY_KICKED,
|
KickMemberNotifyKicked,
|
||||||
MEMBER_LEAVE_NOTIFY_ADMIN, // 主动退出
|
MemberLeaveNotifyAdmin, // 主动退出
|
||||||
CANCEL_ADMIN_NOTIFY_CANCELED, // 我被取消管理员
|
CancelAdminNotifyCanceled, // 我被取消管理员
|
||||||
CANCEL_ADMIN_NOTIFY_ADMIN, // 其他人取消管理员
|
CancelAdminNotifyAdmin, // 其他人取消管理员
|
||||||
TRANSFER_GROUP_NOTIFY_OLDOWNER,
|
TransferGroupNotifyOldowner,
|
||||||
TRANSFER_GROUP_NOTIFY_ADMIN
|
TransferGroupNotifyAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupNotifies {
|
export interface GroupNotifies {
|
||||||
@ -23,11 +23,11 @@ export interface GroupNotifies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum GroupNotifyStatus {
|
export enum GroupNotifyStatus {
|
||||||
KINIT, // 初始化
|
Init, // 初始化
|
||||||
KUNHANDLE, // 未处理
|
Unhandle, // 未处理
|
||||||
KAGREED, // 同意
|
Agreed, // 同意
|
||||||
KREFUSED, // 拒绝
|
Refused, // 拒绝
|
||||||
KIGNORED // 忽略
|
Ignored // 忽略
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupNotify {
|
export interface GroupNotify {
|
||||||
@ -79,41 +79,3 @@ export interface FriendRequestNotify {
|
|||||||
buddyReqs: FriendRequest[]
|
buddyReqs: FriendRequest[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MemberExtSourceType {
|
|
||||||
DEFAULTTYPE = 0,
|
|
||||||
TITLETYPE = 1,
|
|
||||||
NEWGROUPTYPE = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GroupExtParam {
|
|
||||||
groupCode: string
|
|
||||||
seq: string
|
|
||||||
beginUin: string
|
|
||||||
dataTime: string
|
|
||||||
uinList: Array<string>
|
|
||||||
uinNum: string
|
|
||||||
groupType: string
|
|
||||||
richCardNameVer: string
|
|
||||||
sourceType: MemberExtSourceType
|
|
||||||
memberExtFilter: {
|
|
||||||
memberLevelInfoUin: number
|
|
||||||
memberLevelInfoPoint: number
|
|
||||||
memberLevelInfoActiveDay: number
|
|
||||||
memberLevelInfoLevel: number
|
|
||||||
memberLevelInfoName: number
|
|
||||||
levelName: number
|
|
||||||
dataTime: number
|
|
||||||
userShowFlag: number
|
|
||||||
sysShowFlag: number
|
|
||||||
timeToUpdate: number
|
|
||||||
nickName: number
|
|
||||||
specialTitle: number
|
|
||||||
levelNameNew: number
|
|
||||||
userShowFlagNew: number
|
|
||||||
msgNeedField: number
|
|
||||||
cmdUinFlagExt3Grocery: number
|
|
||||||
memberIcon: number
|
|
||||||
memberInfoSeq: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -50,7 +50,7 @@ export class GetGroupFileUrl extends BaseAction<Payload, Response> {
|
|||||||
private async search(groupId: string, fileId: string, folderId?: string) {
|
private async search(groupId: string, fileId: string, folderId?: string) {
|
||||||
let modelId: string | undefined
|
let modelId: string | undefined
|
||||||
let nextIndex: number | undefined
|
let nextIndex: number | undefined
|
||||||
let folders: GroupFileInfo['item'] = []
|
const folders: GroupFileInfo['item'] = []
|
||||||
while (nextIndex !== 0) {
|
while (nextIndex !== 0) {
|
||||||
const res = await this.ctx.ntGroupApi.getGroupFileList(groupId, {
|
const res = await this.ctx.ntGroupApi.getGroupFileList(groupId, {
|
||||||
sortType: 1,
|
sortType: 1,
|
||||||
|
@ -38,7 +38,7 @@ export class GetGroupSystemMsg extends BaseAction<void, Response> {
|
|||||||
invitor_nick: notify.user1.nickName,
|
invitor_nick: notify.user1.nickName,
|
||||||
group_id: +notify.group.groupCode,
|
group_id: +notify.group.groupCode,
|
||||||
group_name: notify.group.groupName,
|
group_name: notify.group.groupName,
|
||||||
checked: notify.status !== GroupNotifyStatus.KUNHANDLE,
|
checked: notify.status !== GroupNotifyStatus.Unhandle,
|
||||||
actor: notify.user2?.uid ? Number(await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)) : 0
|
actor: notify.user2?.uid ? Number(await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)) : 0
|
||||||
})
|
})
|
||||||
} else if (notify.type == 7) {
|
} else if (notify.type == 7) {
|
||||||
@ -49,7 +49,7 @@ export class GetGroupSystemMsg extends BaseAction<void, Response> {
|
|||||||
message: notify.postscript,
|
message: notify.postscript,
|
||||||
group_id: +notify.group.groupCode,
|
group_id: +notify.group.groupCode,
|
||||||
group_name: notify.group.groupName,
|
group_name: notify.group.groupName,
|
||||||
checked: notify.status !== GroupNotifyStatus.KUNHANDLE,
|
checked: notify.status !== GroupNotifyStatus.Unhandle,
|
||||||
actor: notify.user2?.uid ? Number(await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)) : 0
|
actor: notify.user2?.uid ? Number(await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)) : 0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
|
|
||||||
let picInfo: { id: string, width: number, height: number } | undefined
|
let picInfo: { id: string, width: number, height: number } | undefined
|
||||||
if (payload.image) {
|
if (payload.image) {
|
||||||
const { path, isLocal, success, errMsg } = await uri2local(payload.image, undefined, true)
|
const { path, isLocal, success, errMsg } = await uri2local(this.ctx, payload.image, true)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error(`设置群公告失败, 错误信息: uri2local: ${errMsg}`)
|
throw new Error(`设置群公告失败, 错误信息: uri2local: ${errMsg}`)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export class UploadGroupFile extends BaseAction<Payload, null> {
|
|||||||
})
|
})
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const { success, errMsg, path, fileName } = await uri2local(payload.file)
|
const { success, errMsg, path, fileName } = await uri2local(this.ctx, payload.file)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error(errMsg)
|
throw new Error(errMsg)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ export class UploadPrivateFile extends BaseAction<UploadPrivateFilePayload, null
|
|||||||
})
|
})
|
||||||
|
|
||||||
protected async _handle(payload: UploadPrivateFilePayload): Promise<null> {
|
protected async _handle(payload: UploadPrivateFilePayload): Promise<null> {
|
||||||
const { success, errMsg, path, fileName } = await uri2local(payload.file)
|
const { success, errMsg, path, fileName } = await uri2local(this.ctx, payload.file)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error(errMsg)
|
throw new Error(errMsg)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
const groupCode = payload.group_id.toString()
|
const groupCode = payload.group_id.toString()
|
||||||
const member = await this.ctx.ntGroupApi.getGroupMember(groupCode, payload.user_id.toString())
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||||
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
|
const member = await this.ctx.ntGroupApi.getGroupMember(groupCode, uid)
|
||||||
if (member) {
|
if (member) {
|
||||||
if (isNullable(member.sex)) {
|
if (isNullable(member.sex)) {
|
||||||
const info = await this.ctx.ntUserApi.getUserDetailInfo(member.uid)
|
const info = await this.ctx.ntUserApi.getUserDetailInfo(member.uid)
|
||||||
|
@ -16,10 +16,8 @@ export default class Debug extends BaseAction<Payload, unknown> {
|
|||||||
for (const ntqqApiClass of ntqqApi) {
|
for (const ntqqApiClass of ntqqApi) {
|
||||||
const method = ntqqApiClass[payload.method as keyof typeof ntqqApiClass]
|
const method = ntqqApiClass[payload.method as keyof typeof ntqqApiClass]
|
||||||
if (method && method instanceof Function) {
|
if (method && method instanceof Function) {
|
||||||
const result = method.apply(ntqqApiClass, payload.args)
|
const result = await method.apply(ntqqApiClass, payload.args)
|
||||||
if (method.constructor.name === 'AsyncFunction') {
|
this.ctx.logger.info('debug', result)
|
||||||
return await result
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export default class GetGroupAddRequest extends BaseAction<null, OB11GroupReques
|
|||||||
|
|
||||||
protected async _handle(): Promise<OB11GroupRequestNotify[]> {
|
protected async _handle(): Promise<OB11GroupRequestNotify[]> {
|
||||||
const data = await this.ctx.ntGroupApi.getGroupIgnoreNotifies()
|
const data = await this.ctx.ntGroupApi.getGroupIgnoreNotifies()
|
||||||
const notifies = data.notifies.filter(notify => notify.status === GroupNotifyStatus.KUNHANDLE)
|
const notifies = data.notifies.filter(notify => notify.status === GroupNotifyStatus.Unhandle)
|
||||||
const returnData: OB11GroupRequestNotify[] = []
|
const returnData: OB11GroupRequestNotify[] = []
|
||||||
for (const notify of notifies) {
|
for (const notify of notifies) {
|
||||||
const uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
const uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||||
|
@ -11,13 +11,13 @@ export default class SetAvatar extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.SetQQAvatar
|
actionName = ActionName.SetQQAvatar
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const { path, isLocal, errMsg } = await uri2local(payload.file)
|
const { path, isLocal, errMsg } = await uri2local(this.ctx, payload.file)
|
||||||
if (errMsg) {
|
if (errMsg) {
|
||||||
throw new Error(errMsg)
|
throw new Error(errMsg)
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
await checkFileReceived(path, 5000) // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(path, 5000) // 文件不存在QQ会崩溃,需要提前判断
|
||||||
const ret = await this.ctx.ntUserApi.setQQAvatar(path)
|
const ret = await this.ctx.ntUserApi.setSelfAvatar(path)
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
unlink(path)
|
unlink(path)
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,7 @@ import {
|
|||||||
GroupNotify,
|
GroupNotify,
|
||||||
GroupNotifyType,
|
GroupNotifyType,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
BuddyReqType,
|
|
||||||
FriendRequest,
|
FriendRequest,
|
||||||
GroupMember,
|
|
||||||
GroupMemberRole,
|
|
||||||
GroupNotifyStatus
|
GroupNotifyStatus
|
||||||
} from '../ntqqapi/types'
|
} from '../ntqqapi/types'
|
||||||
import { OB11GroupRequestEvent } from './event/request/OB11GroupRequest'
|
import { OB11GroupRequestEvent } from './event/request/OB11GroupRequest'
|
||||||
@ -23,7 +20,6 @@ import { OB11BaseMetaEvent } from './event/meta/OB11BaseMetaEvent'
|
|||||||
import { postHttpEvent } from './helper/eventForHttp'
|
import { postHttpEvent } from './helper/eventForHttp'
|
||||||
import { initActionMap } from './action'
|
import { initActionMap } from './action'
|
||||||
import { llonebotError } from '../common/globalVars'
|
import { llonebotError } from '../common/globalVars'
|
||||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'
|
|
||||||
import { OB11GroupAdminNoticeEvent } from './event/notice/OB11GroupAdminNoticeEvent'
|
import { OB11GroupAdminNoticeEvent } from './event/notice/OB11GroupAdminNoticeEvent'
|
||||||
import { OB11ProfileLikeEvent } from './event/notice/OB11ProfileLikeEvent'
|
import { OB11ProfileLikeEvent } from './event/notice/OB11ProfileLikeEvent'
|
||||||
import { SysMsg } from '@/ntqqapi/proto/compiled'
|
import { SysMsg } from '@/ntqqapi/proto/compiled'
|
||||||
@ -35,8 +31,10 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OneBot11Adapter extends Service {
|
class OneBot11Adapter extends Service {
|
||||||
static inject = ['ntMsgApi', 'ntFileApi', 'ntFileCacheApi', 'ntFriendApi', 'ntGroupApi', 'ntUserApi', 'ntWindowApi', 'ntWebApi', 'store']
|
static inject = [
|
||||||
|
'ntMsgApi', 'ntFileApi', 'ntFileCacheApi', 'ntFriendApi',
|
||||||
|
'ntGroupApi', 'ntUserApi', 'ntWindowApi', 'ntWebApi', 'store'
|
||||||
|
]
|
||||||
private ob11WebSocket: OB11WebSocket
|
private ob11WebSocket: OB11WebSocket
|
||||||
private ob11WebSocketReverseManager: OB11WebSocketReverseManager
|
private ob11WebSocketReverseManager: OB11WebSocketReverseManager
|
||||||
private ob11Http: OB11Http
|
private ob11Http: OB11Http
|
||||||
@ -91,7 +89,7 @@ class OneBot11Adapter extends Service {
|
|||||||
private async handleGroupNotify(notify: GroupNotify) {
|
private async handleGroupNotify(notify: GroupNotify) {
|
||||||
try {
|
try {
|
||||||
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
|
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
|
||||||
if ([GroupNotifyType.MEMBER_LEAVE_NOTIFY_ADMIN, GroupNotifyType.KICK_MEMBER_NOTIFY_ADMIN].includes(notify.type)) {
|
if ([GroupNotifyType.MemberLeaveNotifyAdmin, GroupNotifyType.KickMemberNotifyAdmin].includes(notify.type)) {
|
||||||
this.ctx.logger.info('有成员退出通知', notify)
|
this.ctx.logger.info('有成员退出通知', notify)
|
||||||
const member1Uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
const member1Uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||||
let operatorId = member1Uin
|
let operatorId = member1Uin
|
||||||
@ -112,7 +110,7 @@ class OneBot11Adapter extends Service {
|
|||||||
)
|
)
|
||||||
this.dispatch(event)
|
this.dispatch(event)
|
||||||
}
|
}
|
||||||
else if (notify.type === GroupNotifyType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS && notify.status === GroupNotifyStatus.KUNHANDLE) {
|
else if (notify.type === GroupNotifyType.RequestJoinNeedAdminiStratorPass && notify.status === GroupNotifyStatus.Unhandle) {
|
||||||
this.ctx.logger.info('有加群请求')
|
this.ctx.logger.info('有加群请求')
|
||||||
const requestUin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
const requestUin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||||
const event = new OB11GroupRequestEvent(
|
const event = new OB11GroupRequestEvent(
|
||||||
@ -123,7 +121,7 @@ class OneBot11Adapter extends Service {
|
|||||||
)
|
)
|
||||||
this.dispatch(event)
|
this.dispatch(event)
|
||||||
}
|
}
|
||||||
else if (notify.type === GroupNotifyType.INVITED_BY_MEMBER && notify.status === GroupNotifyStatus.KUNHANDLE) {
|
else if (notify.type === GroupNotifyType.InvitedByMember && notify.status === GroupNotifyStatus.Unhandle) {
|
||||||
this.ctx.logger.info('收到邀请我加群通知')
|
this.ctx.logger.info('收到邀请我加群通知')
|
||||||
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)
|
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)
|
||||||
const event = new OB11GroupRequestEvent(
|
const event = new OB11GroupRequestEvent(
|
||||||
@ -136,7 +134,7 @@ class OneBot11Adapter extends Service {
|
|||||||
)
|
)
|
||||||
this.dispatch(event)
|
this.dispatch(event)
|
||||||
}
|
}
|
||||||
else if (notify.type === GroupNotifyType.INVITED_NEED_ADMINI_STRATOR_PASS && notify.status === GroupNotifyStatus.KUNHANDLE) {
|
else if (notify.type === GroupNotifyType.InvitedNeedAdminiStratorPass && notify.status === GroupNotifyStatus.Unhandle) {
|
||||||
this.ctx.logger.info('收到群员邀请加群通知')
|
this.ctx.logger.info('收到群员邀请加群通知')
|
||||||
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||||
const event = new OB11GroupRequestEvent(
|
const event = new OB11GroupRequestEvent(
|
||||||
@ -147,6 +145,20 @@ class OneBot11Adapter extends Service {
|
|||||||
)
|
)
|
||||||
this.dispatch(event)
|
this.dispatch(event)
|
||||||
}
|
}
|
||||||
|
else if ([
|
||||||
|
GroupNotifyType.SetAdmin,
|
||||||
|
GroupNotifyType.CancelAdminNotifyCanceled,
|
||||||
|
GroupNotifyType.CancelAdminNotifyAdmin
|
||||||
|
].includes(notify.type)) {
|
||||||
|
this.ctx.logger.info('收到管理员变动通知')
|
||||||
|
const uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||||
|
const event = new OB11GroupAdminNoticeEvent(
|
||||||
|
notify.type === GroupNotifyType.SetAdmin ? 'set' : 'unset',
|
||||||
|
parseInt(notify.group.groupCode),
|
||||||
|
parseInt(uin),
|
||||||
|
)
|
||||||
|
this.dispatch(event)
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.ctx.logger.error('解析群通知失败', (e as Error).stack)
|
this.ctx.logger.error('解析群通知失败', (e as Error).stack)
|
||||||
}
|
}
|
||||||
@ -306,29 +318,6 @@ class OneBot11Adapter extends Service {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleGroupMemberInfoUpdated(groupCode: string, members: GroupMember[]) {
|
|
||||||
for (const member of members) {
|
|
||||||
const existMember = await this.ctx.ntGroupApi.getGroupMember(groupCode, member.uin)
|
|
||||||
if (existMember) {
|
|
||||||
if (member.cardName !== existMember.cardName) {
|
|
||||||
this.ctx.logger.info('群成员名片变动', `${groupCode}: ${existMember.uin}`, existMember.cardName, '->', member.cardName)
|
|
||||||
this.dispatch(
|
|
||||||
new OB11GroupCardEvent(parseInt(groupCode), parseInt(member.uin), member.cardName, existMember.cardName),
|
|
||||||
)
|
|
||||||
} else if (member.role !== existMember.role) {
|
|
||||||
this.ctx.logger.info('有管理员变动通知')
|
|
||||||
const groupAdminNoticeEvent = new OB11GroupAdminNoticeEvent(
|
|
||||||
member.role == GroupMemberRole.admin ? 'set' : 'unset',
|
|
||||||
parseInt(groupCode),
|
|
||||||
parseInt(member.uin)
|
|
||||||
)
|
|
||||||
this.dispatch(groupAdminNoticeEvent)
|
|
||||||
}
|
|
||||||
Object.assign(existMember, member)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public start() {
|
public start() {
|
||||||
if (this.config.enableWs) {
|
if (this.config.enableWs) {
|
||||||
this.ob11WebSocket.start()
|
this.ob11WebSocket.start()
|
||||||
@ -360,9 +349,6 @@ class OneBot11Adapter extends Service {
|
|||||||
this.ctx.on('nt/friend-request', input => {
|
this.ctx.on('nt/friend-request', input => {
|
||||||
this.handleFriendRequest(input)
|
this.handleFriendRequest(input)
|
||||||
})
|
})
|
||||||
this.ctx.on('nt/group-member-info-updated', input => {
|
|
||||||
this.handleGroupMemberInfoUpdated(input.groupCode, input.members)
|
|
||||||
})
|
|
||||||
this.ctx.on('nt/system-message-created', input => {
|
this.ctx.on('nt/system-message-created', input => {
|
||||||
const sysMsg = SysMsg.SystemMessage.decode(input)
|
const sysMsg = SysMsg.SystemMessage.decode(input)
|
||||||
const { msgType, subType, subSubType } = sysMsg.msgSpec[0] ?? {}
|
const { msgType, subType, subSubType } = sysMsg.msgSpec[0] ?? {}
|
||||||
@ -385,7 +371,6 @@ namespace OneBot11Adapter {
|
|||||||
token: string
|
token: string
|
||||||
debug: boolean
|
debug: boolean
|
||||||
reportSelfMessage: boolean
|
reportSelfMessage: boolean
|
||||||
msgCacheExpire: number
|
|
||||||
musicSignUrl?: string
|
musicSignUrl?: string
|
||||||
enableLocalFile2Url: boolean
|
enableLocalFile2Url: boolean
|
||||||
ffmpeg?: string
|
ffmpeg?: string
|
||||||
|
@ -30,7 +30,6 @@ import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNotice
|
|||||||
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
||||||
import { calcQQLevel } from '../common/utils/misc'
|
import { calcQQLevel } from '../common/utils/misc'
|
||||||
import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent'
|
import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent'
|
||||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'
|
|
||||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
|
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
|
||||||
import { OB11GroupMsgEmojiLikeEvent } from './event/notice/OB11MsgEmojiLikeEvent'
|
import { OB11GroupMsgEmojiLikeEvent } from './event/notice/OB11MsgEmojiLikeEvent'
|
||||||
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'
|
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'
|
||||||
@ -39,7 +38,7 @@ import { OB11GroupRecallNoticeEvent } from './event/notice/OB11GroupRecallNotice
|
|||||||
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
|
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
|
||||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
|
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
|
||||||
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
|
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
|
||||||
import { omit, isNullable, pick, Dict } from 'cosmokit'
|
import { omit, pick, Dict } from 'cosmokit'
|
||||||
import { Context } from 'cordis'
|
import { Context } from 'cordis'
|
||||||
import { selfInfo } from '@/common/globalVars'
|
import { selfInfo } from '@/common/globalVars'
|
||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
@ -80,7 +79,7 @@ export namespace OB11Entities {
|
|||||||
if (msg.chatType === ChatType.Group) {
|
if (msg.chatType === ChatType.Group) {
|
||||||
resMsg.sub_type = 'normal'
|
resMsg.sub_type = 'normal'
|
||||||
resMsg.group_id = parseInt(msg.peerUin)
|
resMsg.group_id = parseInt(msg.peerUin)
|
||||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUin)
|
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUid)
|
||||||
if (member) {
|
if (member) {
|
||||||
resMsg.sender.role = groupMemberRole(member.role)
|
resMsg.sender.role = groupMemberRole(member.role)
|
||||||
resMsg.sender.nickname = member.nick
|
resMsg.sender.nickname = member.nick
|
||||||
@ -89,12 +88,12 @@ export namespace OB11Entities {
|
|||||||
}
|
}
|
||||||
else if (msg.chatType === ChatType.C2C) {
|
else if (msg.chatType === ChatType.C2C) {
|
||||||
resMsg.sub_type = 'friend'
|
resMsg.sub_type = 'friend'
|
||||||
resMsg.sender.nickname = (await ctx.ntUserApi.getUserDetailInfo(msg.senderUid)).nick
|
resMsg.sender.nickname = (await ctx.ntUserApi.getUserSimpleInfo(msg.senderUid)).coreInfo.nick
|
||||||
}
|
}
|
||||||
else if (msg.chatType === ChatType.TempC2CFromGroup) {
|
else if (msg.chatType === ChatType.TempC2CFromGroup) {
|
||||||
resMsg.sub_type = 'group'
|
resMsg.sub_type = 'group'
|
||||||
resMsg.temp_source = 0 //群聊
|
resMsg.temp_source = 0 //群聊
|
||||||
resMsg.sender.nickname = (await ctx.ntUserApi.getUserDetailInfo(msg.senderUid)).nick
|
resMsg.sender.nickname = (await ctx.ntUserApi.getUserSimpleInfo(msg.senderUid)).coreInfo.nick
|
||||||
const ret = await ctx.ntMsgApi.getTempChatInfo(ChatType.TempC2CFromGroup, msg.senderUid)
|
const ret = await ctx.ntMsgApi.getTempChatInfo(ChatType.TempC2CFromGroup, msg.senderUid)
|
||||||
if (ret?.result === 0) {
|
if (ret?.result === 0) {
|
||||||
resMsg.sender.group_id = Number(ret.tmpChatInfo?.groupCode)
|
resMsg.sender.group_id = Number(ret.tmpChatInfo?.groupCode)
|
||||||
@ -403,7 +402,7 @@ export namespace OB11Entities {
|
|||||||
if (msg.chatType !== ChatType.Group) {
|
if (msg.chatType !== ChatType.Group) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (msg.senderUin) {
|
/**if (msg.senderUin) {
|
||||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin)
|
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin)
|
||||||
if (member && member.cardName !== msg.sendMemberName) {
|
if (member && member.cardName !== msg.sendMemberName) {
|
||||||
const event = new OB11GroupCardEvent(
|
const event = new OB11GroupCardEvent(
|
||||||
@ -415,24 +414,17 @@ export namespace OB11Entities {
|
|||||||
member.cardName = msg.sendMemberName!
|
member.cardName = msg.sendMemberName!
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
for (const element of msg.elements) {
|
for (const element of msg.elements) {
|
||||||
const grayTipElement = element.grayTipElement
|
const grayTipElement = element.grayTipElement
|
||||||
const groupElement = grayTipElement?.groupElement
|
const groupElement = grayTipElement?.groupElement
|
||||||
if (groupElement) {
|
if (groupElement) {
|
||||||
if (groupElement.type === TipGroupElementType.MemberIncrease) {
|
if (groupElement.type === TipGroupElementType.MemberIncrease) {
|
||||||
ctx.logger.info('收到群成员增加消息', groupElement)
|
ctx.logger.info('收到群成员增加消息', groupElement)
|
||||||
await ctx.sleep(1000)
|
const { memberUid, adminUid } = groupElement
|
||||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, groupElement.memberUid)
|
const memberUin = await ctx.ntUserApi.getUinByUid(memberUid)
|
||||||
let memberUin = member?.uin
|
const operatorUin = adminUid ? await ctx.ntUserApi.getUinByUid(adminUid) : memberUin
|
||||||
if (!memberUin) {
|
return new OB11GroupIncreaseEvent(+msg.peerUid, +memberUin, +operatorUin)
|
||||||
memberUin = (await ctx.ntUserApi.getUserDetailInfo(groupElement.memberUid)).uin
|
|
||||||
}
|
|
||||||
const adminMember = await ctx.ntGroupApi.getGroupMember(msg.peerUid, groupElement.adminUid)
|
|
||||||
if (memberUin) {
|
|
||||||
const operatorUin = adminMember?.uin || memberUin
|
|
||||||
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(operatorUin))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (groupElement.type === TipGroupElementType.Ban) {
|
else if (groupElement.type === TipGroupElementType.Ban) {
|
||||||
ctx.logger.info('收到群成员禁言提示', groupElement)
|
ctx.logger.info('收到群成员禁言提示', groupElement)
|
||||||
@ -547,10 +539,9 @@ export namespace OB11Entities {
|
|||||||
while ((match = regex.exec(xmlElement.content)) !== null) {
|
while ((match = regex.exec(xmlElement.content)) !== null) {
|
||||||
matches.push(match[1])
|
matches.push(match[1])
|
||||||
}
|
}
|
||||||
// log("新人进群匹配到的QQ号", matches)
|
|
||||||
if (matches.length === 2) {
|
if (matches.length === 2) {
|
||||||
const [inviter, invitee] = matches
|
const [invitor, invitee] = matches
|
||||||
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), 'invite')
|
return new OB11GroupIncreaseEvent(+msg.peerUid, +invitee, +invitor, 'invite')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,11 +585,6 @@ export namespace OB11Entities {
|
|||||||
const memberUin = json.items[1].param[0]
|
const memberUin = json.items[1].param[0]
|
||||||
const title = json.items[3].txt
|
const title = json.items[3].txt
|
||||||
ctx.logger.info('收到群成员新头衔消息', json)
|
ctx.logger.info('收到群成员新头衔消息', json)
|
||||||
ctx.ntGroupApi.getGroupMember(msg.peerUid, memberUin).then(member => {
|
|
||||||
if (!isNullable(member)) {
|
|
||||||
member.memberSpecialTitle = title
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return new OB11GroupTitleEvent(parseInt(msg.peerUid), parseInt(memberUin), title)
|
return new OB11GroupTitleEvent(parseInt(msg.peerUid), parseInt(memberUin), title)
|
||||||
} else if (grayTipElement.jsonGrayTipElement?.busiId === '19217') {
|
} else if (grayTipElement.jsonGrayTipElement?.busiId === '19217') {
|
||||||
ctx.logger.info('收到新人被邀请进群消息', grayTipElement)
|
ctx.logger.info('收到新人被邀请进群消息', grayTipElement)
|
||||||
@ -616,13 +602,7 @@ export namespace OB11Entities {
|
|||||||
msg: RawMessage,
|
msg: RawMessage,
|
||||||
shortId: number
|
shortId: number
|
||||||
): Promise<OB11FriendRecallNoticeEvent | OB11GroupRecallNoticeEvent | undefined> {
|
): Promise<OB11FriendRecallNoticeEvent | OB11GroupRecallNoticeEvent | undefined> {
|
||||||
const msgElement = msg.elements.find(
|
const revokeElement = msg.elements[0].grayTipElement?.revokeElement
|
||||||
(element) => element.grayTipElement?.subElementType === GrayTipElementSubType.Revoke,
|
|
||||||
)
|
|
||||||
if (!msgElement) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const revokeElement = msgElement.grayTipElement!.revokeElement
|
|
||||||
if (msg.chatType === ChatType.Group) {
|
if (msg.chatType === ChatType.Group) {
|
||||||
const operator = await ctx.ntGroupApi.getGroupMember(msg.peerUid, revokeElement!.operatorUid)
|
const operator = await ctx.ntGroupApi.getGroupMember(msg.peerUid, revokeElement!.operatorUid)
|
||||||
return new OB11GroupRecallNoticeEvent(
|
return new OB11GroupRecallNoticeEvent(
|
||||||
|
@ -56,7 +56,7 @@ export async function createSendElements(
|
|||||||
remainAtAllCount = (await ctx.ntGroupApi.getGroupRemainAtTimes(groupCode)).atInfo
|
remainAtAllCount = (await ctx.ntGroupApi.getGroupRemainAtTimes(groupCode)).atInfo
|
||||||
.RemainAtAllCountForUin
|
.RemainAtAllCountForUin
|
||||||
ctx.logger.info(`群${groupCode}剩余at全体次数`, remainAtAllCount)
|
ctx.logger.info(`群${groupCode}剩余at全体次数`, remainAtAllCount)
|
||||||
const self = await ctx.ntGroupApi.getGroupMember(groupCode, selfInfo.uin)
|
const self = await ctx.ntGroupApi.getGroupMember(groupCode, selfInfo.uid)
|
||||||
isAdmin = self?.role === GroupMemberRole.admin || self?.role === GroupMemberRole.owner
|
isAdmin = self?.role === GroupMemberRole.admin || self?.role === GroupMemberRole.owner
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
@ -66,44 +66,24 @@ export async function createSendElements(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (peer.chatType === ChatType.Group) {
|
else if (peer.chatType === ChatType.Group) {
|
||||||
const atMember = await ctx.ntGroupApi.getGroupMember(peer.peerUid, atQQ)
|
const uid = await ctx.ntUserApi.getUidByUin(atQQ) ?? ''
|
||||||
if (atMember) {
|
|
||||||
const display = `@${atMember.cardName || atMember.nick}`
|
|
||||||
sendElements.push(
|
|
||||||
SendElement.at(atQQ, atMember.uid, AtType.One, display),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
const atNmae = sendMsg.data?.name
|
const atNmae = sendMsg.data?.name
|
||||||
const uid = await ctx.ntUserApi.getUidByUin(atQQ) || ''
|
|
||||||
const display = atNmae ? `@${atNmae}` : ''
|
const display = atNmae ? `@${atNmae}` : ''
|
||||||
sendElements.push(
|
sendElements.push(SendElement.at(atQQ, uid, AtType.One, display))
|
||||||
SendElement.at(atQQ, uid, AtType.One, display),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case OB11MessageDataType.reply: {
|
case OB11MessageDataType.reply: {
|
||||||
if (sendMsg.data?.id) {
|
if (sendMsg.data?.id) {
|
||||||
const replyMsgId = await ctx.store.getMsgInfoByShortId(+sendMsg.data.id)
|
const info = await ctx.store.getMsgInfoByShortId(+sendMsg.data.id)
|
||||||
if (!replyMsgId) {
|
if (!info) {
|
||||||
ctx.logger.warn('回复消息不存在', replyMsgId)
|
ctx.logger.warn('回复消息不存在', info)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const replyMsg = (await ctx.ntMsgApi.getMsgsByMsgId(
|
const source = (await ctx.ntMsgApi.getMsgsByMsgId(info.peer, [info.msgId])).msgList[0]
|
||||||
replyMsgId.peer,
|
if (source) {
|
||||||
[replyMsgId.msgId!]
|
sendElements.push(SendElement.reply(source.msgSeq, source.msgId, source.senderUin))
|
||||||
)).msgList[0]
|
|
||||||
if (replyMsg) {
|
|
||||||
sendElements.push(
|
|
||||||
SendElement.reply(
|
|
||||||
replyMsg.msgSeq,
|
|
||||||
replyMsg.msgId,
|
|
||||||
replyMsg.senderUin!,
|
|
||||||
replyMsg.senderUin!,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +127,7 @@ export async function createSendElements(
|
|||||||
const { path, fileName } = await handleOb11FileLikeMessage(ctx, sendMsg, { deleteAfterSentFiles })
|
const { path, fileName } = await handleOb11FileLikeMessage(ctx, sendMsg, { deleteAfterSentFiles })
|
||||||
let thumb = sendMsg.data.thumb
|
let thumb = sendMsg.data.thumb
|
||||||
if (thumb) {
|
if (thumb) {
|
||||||
const uri2LocalRes = await uri2local(thumb)
|
const uri2LocalRes = await uri2local(ctx, thumb)
|
||||||
if (uri2LocalRes.success) thumb = uri2LocalRes.path
|
if (uri2LocalRes.success) thumb = uri2LocalRes.path
|
||||||
}
|
}
|
||||||
const res = await SendElement.video(ctx, path, fileName, thumb)
|
const res = await SendElement.video(ctx, path, fileName, thumb)
|
||||||
@ -206,7 +186,7 @@ async function handleOb11FileLikeMessage(
|
|||||||
fileName,
|
fileName,
|
||||||
errMsg,
|
errMsg,
|
||||||
success,
|
success,
|
||||||
} = (await uri2local(inputdata?.url || inputdata.file))
|
} = (await uri2local(ctx, inputdata.url || inputdata.file))
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ctx.logger.error(errMsg)
|
ctx.logger.error(errMsg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user