mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1d63473a04 | ||
![]() |
692ba5163e | ||
![]() |
8bcea090ec | ||
![]() |
67568a662d | ||
![]() |
66b3706524 | ||
![]() |
6d82dd1dad | ||
![]() |
20f2e66b11 | ||
![]() |
efefb963c0 | ||
![]() |
92d780cf70 | ||
![]() |
ce6886011f | ||
![]() |
319b275e4f | ||
![]() |
9738c3f63c | ||
![]() |
3de054600c | ||
![]() |
da0ebd3f80 | ||
![]() |
d5682a9788 | ||
![]() |
a1298b1c93 | ||
![]() |
6fac490d66 | ||
![]() |
dc25d83778 | ||
![]() |
1bcdbba29a | ||
![]() |
9ecfb6ea0c | ||
![]() |
5c68d4de84 | ||
![]() |
c1c22e872e | ||
![]() |
709c0b6f7b | ||
![]() |
dd34286b43 | ||
![]() |
80487e31f5 | ||
![]() |
bdf1c7fd5f |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,5 +11,6 @@ node_modules
|
|||||||
dist
|
dist
|
||||||
out
|
out
|
||||||
|
|
||||||
.idea/
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||||
"version": "3.31.9",
|
"version": "3.32.3",
|
||||||
"icon": "./icon.webp",
|
"icon": "./icon.webp",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
17
package.json
17
package.json
@@ -7,11 +7,12 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "electron-vite build",
|
"build": "electron-vite build",
|
||||||
"build-mac": "npm run build && npm run deploy-mac",
|
"build-mac": "npm run build && npm run deploy-mac",
|
||||||
"deploy-mac": "cp -r dist/* ~/Library/Containers/com.tencent.qq/Data/LiteLoaderQQNT/plugins/LLOneBot/",
|
"deploy-mac": "cp -r dist/* ~/Library/Containers/com.tencent.qq/Data/Documents/LiteLoaderQQNT/plugins/LLOneBot/",
|
||||||
"build-win": "npm run build && npm run deploy-win",
|
"build-win": "npm run build && npm run deploy-win",
|
||||||
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %USERPROFILE%\\documents\\LiteLoaderQQNT\\plugins\\LLOneBot\\\"",
|
"deploy-win": "cmd /c \"xcopy /C /S /Y dist\\* %LITELOADERQQNT_PROFILE%\\plugins\\LLOneBot\\\"",
|
||||||
"format": "prettier -cw .",
|
"format": "prettier -cw .",
|
||||||
"check": "tsc"
|
"check": "tsc",
|
||||||
|
"compile:proto": "pbjs -t static-module -w es6 -p ./src/ntqqapi/proto -o ./src/ntqqapi/proto/compiled.js systemMessage.proto profileLikeTip.proto && pbts -o ./src/ntqqapi/proto/compiled.d.ts ./src/ntqqapi/proto/compiled.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -21,11 +22,12 @@
|
|||||||
"cordis": "^3.18.0",
|
"cordis": "^3.18.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cosmokit": "^1.6.2",
|
"cosmokit": "^1.6.2",
|
||||||
"express": "^4.19.2",
|
"express": "^5.0.0",
|
||||||
"fast-xml-parser": "^4.5.0",
|
"fast-xml-parser": "^4.5.0",
|
||||||
"file-type": "^19.4.1",
|
"file-type": "^19.5.0",
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
"fluent-ffmpeg": "^2.1.3",
|
||||||
"minato": "^3.5.1",
|
"minato": "^3.5.1",
|
||||||
|
"protobufjs": "^7.4.0",
|
||||||
"silk-wasm": "^3.6.1",
|
"silk-wasm": "^3.6.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
},
|
},
|
||||||
@@ -37,8 +39,9 @@
|
|||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.5.12",
|
||||||
"electron": "^31.4.0",
|
"electron": "^31.4.0",
|
||||||
"electron-vite": "^2.3.0",
|
"electron-vite": "^2.3.0",
|
||||||
"typescript": "^5.5.4",
|
"protobufjs-cli": "^1.1.3",
|
||||||
"vite": "^5.4.3",
|
"typescript": "^5.6.2",
|
||||||
|
"vite": "^5.4.4",
|
||||||
"vite-plugin-cp": "^4.0.8"
|
"vite-plugin-cp": "^4.0.8"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.4.1"
|
"packageManager": "yarn@4.4.1"
|
||||||
|
@@ -1,234 +0,0 @@
|
|||||||
import { NodeIQQNTWrapperSession } from '@/ntqqapi/wrapper'
|
|
||||||
import { randomUUID } from 'node:crypto'
|
|
||||||
|
|
||||||
interface Internal_MapKey {
|
|
||||||
timeout: number
|
|
||||||
createtime: number
|
|
||||||
func: (...arg: any[]) => unknown
|
|
||||||
checker?: (...args: any[]) => boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ListenerClassBase {
|
|
||||||
[key: string]: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ListenerIBase {
|
|
||||||
new(listener: unknown): ListenerClassBase
|
|
||||||
}
|
|
||||||
|
|
||||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/EventTask.ts#L20
|
|
||||||
export class NTEventWrapper {
|
|
||||||
private ListenerMap: { [key: string]: ListenerIBase } | undefined//ListenerName-Unique -> Listener构造函数
|
|
||||||
private WrapperSession: NodeIQQNTWrapperSession | undefined//WrapperSession
|
|
||||||
private ListenerManger: Map<string, ListenerClassBase> = new Map<string, ListenerClassBase>() //ListenerName-Unique -> Listener实例
|
|
||||||
private EventTask = new Map<string, Map<string, Map<string, Internal_MapKey>>>()//tasks ListenerMainName -> ListenerSubName-> uuid -> {timeout,createtime,func}
|
|
||||||
public initialised = false
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
createProxyDispatch(ListenerMainName: string) {
|
|
||||||
const current = this
|
|
||||||
return new Proxy({}, {
|
|
||||||
get(target: any, prop: string, receiver: unknown) {
|
|
||||||
// console.log('get', prop, typeof target[prop])
|
|
||||||
if (typeof target[prop] === 'undefined') {
|
|
||||||
// 如果方法不存在,返回一个函数,这个函数调用existentMethod
|
|
||||||
return (...args: unknown[]) => {
|
|
||||||
current.dispatcherListener.apply(current, [ListenerMainName, prop, ...args]).then()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 如果方法存在,正常返回
|
|
||||||
return Reflect.get(target, prop, receiver)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
init({ ListenerMap, WrapperSession }: { ListenerMap: { [key: string]: typeof ListenerClassBase }, WrapperSession: NodeIQQNTWrapperSession }) {
|
|
||||||
this.ListenerMap = ListenerMap
|
|
||||||
this.WrapperSession = WrapperSession
|
|
||||||
this.initialised = true
|
|
||||||
}
|
|
||||||
|
|
||||||
createEventFunction<T extends (...args: any) => unknown>(eventName: string): T | undefined {
|
|
||||||
const eventNameArr = eventName.split('/')
|
|
||||||
type eventType = {
|
|
||||||
[key: string]: () => { [key: string]: (...params: Parameters<T>) => Promise<ReturnType<T>> }
|
|
||||||
}
|
|
||||||
if (eventNameArr.length > 1) {
|
|
||||||
const serviceName = 'get' + eventNameArr[0].replace('NodeIKernel', '')
|
|
||||||
const eventName = eventNameArr[1]
|
|
||||||
//getNodeIKernelGroupListener,GroupService
|
|
||||||
//console.log('2', eventName)
|
|
||||||
const services = (this.WrapperSession as unknown as eventType)[serviceName]()
|
|
||||||
let event = services[eventName]
|
|
||||||
//重新绑定this
|
|
||||||
event = event.bind(services)
|
|
||||||
if (event) {
|
|
||||||
return event as T
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createListenerFunction<T>(listenerMainName: string, uniqueCode: string = ''): T {
|
|
||||||
const ListenerType = this.ListenerMap![listenerMainName]
|
|
||||||
let Listener = this.ListenerManger.get(listenerMainName + uniqueCode)
|
|
||||||
if (!Listener && ListenerType) {
|
|
||||||
Listener = new ListenerType(this.createProxyDispatch(listenerMainName))
|
|
||||||
const ServiceSubName = listenerMainName.match(/^NodeIKernel(.*?)Listener$/)![1]
|
|
||||||
const Service = 'NodeIKernel' + ServiceSubName + 'Service/addKernel' + ServiceSubName + 'Listener'
|
|
||||||
const addfunc = this.createEventFunction<(listener: T) => number>(Service)
|
|
||||||
addfunc!(Listener as T)
|
|
||||||
//console.log(addfunc!(Listener as T))
|
|
||||||
this.ListenerManger.set(listenerMainName + uniqueCode, Listener)
|
|
||||||
}
|
|
||||||
return Listener as T
|
|
||||||
}
|
|
||||||
|
|
||||||
//统一回调清理事件
|
|
||||||
async dispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: unknown[]) {
|
|
||||||
//console.log("[EventDispatcher]",ListenerMainName, ListenerSubName, ...args)
|
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
|
||||||
//console.log(task.func, uuid, task.createtime, task.timeout)
|
|
||||||
if (task.createtime + task.timeout < Date.now()) {
|
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.delete(uuid)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (task.checker && task.checker(...args)) {
|
|
||||||
task.func(...args)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async CallNoListenerEvent<EventType extends (...args: any[]) => Promise<any>>(EventName = '', timeout: number = 3000, ...args: Parameters<EventType>) {
|
|
||||||
return new Promise<Awaited<ReturnType<EventType>>>(async (resolve, reject) => {
|
|
||||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
|
||||||
let complete = false
|
|
||||||
const Timeouter = setTimeout(() => {
|
|
||||||
if (!complete) {
|
|
||||||
reject(new Error('NTEvent EventName:' + EventName + ' timeout'))
|
|
||||||
}
|
|
||||||
}, timeout)
|
|
||||||
const retData = await EventFunc!(...args)
|
|
||||||
complete = true
|
|
||||||
resolve(retData)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async RegisterListen<ListenerType extends (...args: any[]) => void>(ListenerName = '', waitTimes = 1, timeout = 5000, checker: (...args: Parameters<ListenerType>) => boolean) {
|
|
||||||
return new Promise<Parameters<ListenerType>>((resolve, reject) => {
|
|
||||||
const ListenerNameList = ListenerName.split('/')
|
|
||||||
const ListenerMainName = ListenerNameList[0]
|
|
||||||
const ListenerSubName = ListenerNameList[1]
|
|
||||||
const id = randomUUID()
|
|
||||||
let complete = 0
|
|
||||||
let retData: Parameters<ListenerType> | undefined = undefined
|
|
||||||
const databack = () => {
|
|
||||||
if (complete == 0) {
|
|
||||||
reject(new Error(' ListenerName:' + ListenerName + ' timeout'))
|
|
||||||
} else {
|
|
||||||
resolve(retData!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const Timeouter = setTimeout(databack, timeout)
|
|
||||||
const eventCallbak = {
|
|
||||||
timeout: timeout,
|
|
||||||
createtime: Date.now(),
|
|
||||||
checker: checker,
|
|
||||||
func: (...args: Parameters<ListenerType>) => {
|
|
||||||
complete++
|
|
||||||
retData = args
|
|
||||||
if (complete >= waitTimes) {
|
|
||||||
clearTimeout(Timeouter)
|
|
||||||
databack()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.EventTask.get(ListenerMainName)) {
|
|
||||||
this.EventTask.set(ListenerMainName, new Map())
|
|
||||||
}
|
|
||||||
if (!(this.EventTask.get(ListenerMainName)?.get(ListenerSubName))) {
|
|
||||||
this.EventTask.get(ListenerMainName)?.set(ListenerSubName, new Map())
|
|
||||||
}
|
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak)
|
|
||||||
this.createListenerFunction(ListenerMainName)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async CallNormalEvent<EventType extends (...args: any[]) => Promise<any>, ListenerType extends (...args: any[]) => void>
|
|
||||||
(EventName = '', ListenerName = '', waitTimes = 1, timeout: number = 3000, checker: (...args: Parameters<ListenerType>) => boolean, ...args: Parameters<EventType>) {
|
|
||||||
return new Promise<[EventRet: Awaited<ReturnType<EventType>>, ...Parameters<ListenerType>]>(async (resolve, reject) => {
|
|
||||||
const id = randomUUID()
|
|
||||||
let complete = 0
|
|
||||||
let retData: Parameters<ListenerType> | undefined = undefined
|
|
||||||
let retEvent = {}
|
|
||||||
const databack = () => {
|
|
||||||
if (complete == 0) {
|
|
||||||
reject(new Error('Timeout: NTEvent EventName:' + EventName + ' ListenerName:' + ListenerName + ' EventRet:\n' + JSON.stringify(retEvent, null, 4) + '\n'))
|
|
||||||
} else {
|
|
||||||
resolve([retEvent as Awaited<ReturnType<EventType>>, ...retData!])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ListenerNameList = ListenerName.split('/')
|
|
||||||
const ListenerMainName = ListenerNameList[0]
|
|
||||||
const ListenerSubName = ListenerNameList[1]
|
|
||||||
|
|
||||||
const Timeouter = setTimeout(databack, timeout)
|
|
||||||
|
|
||||||
const eventCallbak = {
|
|
||||||
timeout: timeout,
|
|
||||||
createtime: Date.now(),
|
|
||||||
checker: checker,
|
|
||||||
func: (...args: unknown[]) => {
|
|
||||||
complete++
|
|
||||||
//console.log('func', ...args)
|
|
||||||
retData = args as Parameters<ListenerType>
|
|
||||||
if (complete >= waitTimes) {
|
|
||||||
clearTimeout(Timeouter)
|
|
||||||
databack()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.EventTask.get(ListenerMainName)) {
|
|
||||||
this.EventTask.set(ListenerMainName, new Map())
|
|
||||||
}
|
|
||||||
if (!(this.EventTask.get(ListenerMainName)?.get(ListenerSubName))) {
|
|
||||||
this.EventTask.get(ListenerMainName)?.set(ListenerSubName, new Map())
|
|
||||||
}
|
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak)
|
|
||||||
this.createListenerFunction(ListenerMainName)
|
|
||||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
|
||||||
retEvent = await EventFunc!(...args)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const NTEventDispatch = new NTEventWrapper()
|
|
||||||
|
|
||||||
// 示例代码 快速创建事件
|
|
||||||
// let NTEvent = new NTEventWrapper()
|
|
||||||
// let TestEvent = NTEvent.CreatEventFunction<(force: boolean) => Promise<Number>>('NodeIKernelProfileLikeService/GetTest')
|
|
||||||
// if (TestEvent) {
|
|
||||||
// TestEvent(true)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 示例代码 快速创建监听Listener类
|
|
||||||
// let NTEvent = new NTEventWrapper()
|
|
||||||
// NTEvent.CreatListenerFunction<NodeIKernelMsgListener>('NodeIKernelMsgListener', 'core')
|
|
||||||
|
|
||||||
|
|
||||||
// 调用接口
|
|
||||||
//let NTEvent = new NTEventWrapper()
|
|
||||||
//let ret = await NTEvent.CallNormalEvent<(force: boolean) => Promise<Number>, (data1: string, data2: number) => void>('NodeIKernelProfileLikeService/GetTest', 'NodeIKernelMsgListener/onAddSendMsg', 1, 3000, true)
|
|
||||||
|
|
||||||
// 注册监听 解除监听
|
|
||||||
// NTEventDispatch.RigisterListener('NodeIKernelMsgListener/onAddSendMsg','core',cb)
|
|
||||||
// NTEventDispatch.UnRigisterListener('NodeIKernelMsgListener/onAddSendMsg','core')
|
|
||||||
|
|
||||||
// let GetTest = NTEventDispatch.CreatEvent('NodeIKernelProfileLikeService/GetTest','NodeIKernelMsgListener/onAddSendMsg',Mode)
|
|
||||||
// GetTest('test')
|
|
||||||
|
|
||||||
// always模式
|
|
||||||
// NTEventDispatch.CreatEvent('NodeIKernelProfileLikeService/GetTest','NodeIKernelMsgListener/onAddSendMsg',Mode,(...args:any[])=>{ console.log(args) })
|
|
@@ -4,6 +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'
|
||||||
|
|
||||||
export function isGIF(path: string) {
|
export function isGIF(path: string) {
|
||||||
const buffer = Buffer.alloc(4)
|
const buffer = Buffer.alloc(4)
|
||||||
@@ -116,7 +117,7 @@ type Uri2LocalRes = {
|
|||||||
isLocal: boolean
|
isLocal: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uri2local(uri: string, filename?: string): Promise<Uri2LocalRes> {
|
export async function uri2local(uri: string, filename?: string, needExt?: boolean): Promise<Uri2LocalRes> {
|
||||||
const { type } = checkUriType(uri)
|
const { type } = checkUriType(uri)
|
||||||
|
|
||||||
if (type === FileUriType.FileURL) {
|
if (type === FileUriType.FileURL) {
|
||||||
@@ -132,15 +133,21 @@ export async function uri2local(uri: string, filename?: string): Promise<Uri2Loc
|
|||||||
|
|
||||||
if (type === FileUriType.RemoteURL) {
|
if (type === FileUriType.RemoteURL) {
|
||||||
try {
|
try {
|
||||||
const res = await fetchFile(uri)
|
const res = await fetchFile(uri, { 'Referer': uri })
|
||||||
const match = res.url.match(/.+\/([^/?]*)(?=\?)?/)
|
const match = res.url.match(/.+\/([^/?]*)(?=\?)?/)
|
||||||
if (match?.[1]) {
|
if (match?.[1]) {
|
||||||
filename ??= match[1].replace(/[/\\:*?"<>|]/g, '_')
|
filename ??= match[1].replace(/[/\\:*?"<>|]/g, '_')
|
||||||
} else {
|
} else {
|
||||||
filename ??= randomUUID()
|
filename ??= randomUUID()
|
||||||
}
|
}
|
||||||
const 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)) {
|
||||||
|
const ext = (await fileTypeFromFile(filePath))?.ext
|
||||||
|
filename += `.${ext}`
|
||||||
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
|
filePath = `${filePath}.${ext}`
|
||||||
|
}
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const errMsg = `${uri} 下载失败, ${(e as Error).message}`
|
const errMsg = `${uri} 下载失败, ${(e as Error).message}`
|
||||||
@@ -150,9 +157,15 @@ export async function uri2local(uri: string, filename?: string): Promise<Uri2Loc
|
|||||||
|
|
||||||
if (type === FileUriType.OneBotBase64) {
|
if (type === FileUriType.OneBotBase64) {
|
||||||
filename ??= randomUUID()
|
filename ??= randomUUID()
|
||||||
const 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) {
|
||||||
|
const ext = (await fileTypeFromFile(filePath))?.ext
|
||||||
|
filename += `.${ext}`
|
||||||
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
|
filePath = `${filePath}.${ext}`
|
||||||
|
}
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +175,14 @@ export async function uri2local(uri: string, filename?: string): Promise<Uri2Loc
|
|||||||
if (capture) {
|
if (capture) {
|
||||||
filename ??= randomUUID()
|
filename ??= randomUUID()
|
||||||
const [, _type, base64] = capture
|
const [, _type, base64] = capture
|
||||||
const 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) {
|
||||||
|
const ext = (await fileTypeFromFile(filePath))?.ext
|
||||||
|
filename += `.${ext}`
|
||||||
|
await fsPromise.rename(filePath, `${filePath}.${ext}`)
|
||||||
|
filePath = `${filePath}.${ext}`
|
||||||
|
}
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,154 +10,154 @@ import { DATA_DIR } from '../globalVars'
|
|||||||
import { FileCacheV2 } from '../types'
|
import { FileCacheV2 } from '../types'
|
||||||
|
|
||||||
interface SQLiteTables extends Tables {
|
interface SQLiteTables extends Tables {
|
||||||
message: {
|
message: {
|
||||||
shortId: number
|
shortId: number
|
||||||
msgId: string
|
msgId: string
|
||||||
chatType: number
|
chatType: number
|
||||||
peerUid: string
|
peerUid: string
|
||||||
}
|
}
|
||||||
file_v2: FileCacheV2
|
file_v2: FileCacheV2
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MsgIdAndPeerByShortId {
|
interface MsgIdAndPeerByShortId {
|
||||||
MsgId: string
|
MsgId: string
|
||||||
Peer: Peer
|
Peer: Peer
|
||||||
}
|
}
|
||||||
|
|
||||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/MessageUnique.ts#L84
|
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/MessageUnique.ts#L84
|
||||||
class MessageUniqueWrapper {
|
class MessageUniqueWrapper {
|
||||||
private msgDataMap: LimitedHashTable<string, number>
|
private msgDataMap: LimitedHashTable<string, number>
|
||||||
private msgIdMap: LimitedHashTable<string, number>
|
private msgIdMap: LimitedHashTable<string, number>
|
||||||
private db: Database<SQLiteTables> | undefined
|
private db: Database<SQLiteTables> | undefined
|
||||||
|
|
||||||
constructor(maxMap: number = 1000) {
|
constructor(maxMap: number = 1000) {
|
||||||
this.msgIdMap = new LimitedHashTable<string, number>(maxMap)
|
this.msgIdMap = new LimitedHashTable<string, number>(maxMap)
|
||||||
this.msgDataMap = new LimitedHashTable<string, number>(maxMap)
|
this.msgDataMap = new LimitedHashTable<string, number>(maxMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(uin: string) {
|
||||||
|
const dbDir = path.join(DATA_DIR, 'database')
|
||||||
|
if (!fs.existsSync(dbDir)) {
|
||||||
|
await fsPromise.mkdir(dbDir)
|
||||||
}
|
}
|
||||||
|
const database = new Database<SQLiteTables>()
|
||||||
|
await database.connect(SQLite, {
|
||||||
|
path: path.join(dbDir, `${uin}.db`)
|
||||||
|
})
|
||||||
|
database.extend('message', {
|
||||||
|
shortId: 'integer(10)',
|
||||||
|
chatType: 'unsigned',
|
||||||
|
msgId: 'string(24)',
|
||||||
|
peerUid: 'string(24)'
|
||||||
|
}, {
|
||||||
|
primary: 'shortId'
|
||||||
|
})
|
||||||
|
database.extend('file_v2', {
|
||||||
|
fileName: 'string',
|
||||||
|
fileSize: 'string',
|
||||||
|
fileUuid: 'string(128)',
|
||||||
|
msgId: 'string(24)',
|
||||||
|
msgTime: 'unsigned(10)',
|
||||||
|
peerUid: 'string(24)',
|
||||||
|
chatType: 'unsigned',
|
||||||
|
elementId: 'string(24)',
|
||||||
|
elementType: 'unsigned',
|
||||||
|
}, {
|
||||||
|
primary: 'fileUuid',
|
||||||
|
indexes: ['fileName']
|
||||||
|
})
|
||||||
|
this.db = database
|
||||||
|
}
|
||||||
|
|
||||||
async init(uin: string) {
|
async getRecentMsgIds(Peer: Peer, size: number): Promise<string[]> {
|
||||||
const dbDir = path.join(DATA_DIR, 'database')
|
const heads = this.msgIdMap.getHeads(size)
|
||||||
if (!fs.existsSync(dbDir)) {
|
if (!heads) {
|
||||||
await fsPromise.mkdir(dbDir)
|
return []
|
||||||
|
}
|
||||||
|
const data: (MsgIdAndPeerByShortId | undefined)[] = []
|
||||||
|
for (const t of heads) {
|
||||||
|
data.push(await MessageUnique.getMsgIdAndPeerByShortId(t.value))
|
||||||
|
}
|
||||||
|
const ret = data.filter((t) => t?.Peer.chatType === Peer.chatType && t?.Peer.peerUid === Peer.peerUid)
|
||||||
|
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined)
|
||||||
|
}
|
||||||
|
|
||||||
|
createMsg(peer: Peer, msgId: string): number {
|
||||||
|
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`
|
||||||
|
const hash = createHash('md5').update(key).digest()
|
||||||
|
//设置第一个bit为0 保证shortId为正数
|
||||||
|
hash[0] &= 0x7f
|
||||||
|
const shortId = hash.readInt32BE(0)
|
||||||
|
//减少性能损耗
|
||||||
|
// const isExist = this.msgIdMap.getKey(shortId)
|
||||||
|
// if (isExist && isExist === msgId) {
|
||||||
|
// return shortId
|
||||||
|
// }
|
||||||
|
this.msgIdMap.set(msgId, shortId)
|
||||||
|
this.msgDataMap.set(key, shortId)
|
||||||
|
this.db?.upsert('message', [{
|
||||||
|
msgId,
|
||||||
|
shortId,
|
||||||
|
chatType: peer.chatType,
|
||||||
|
peerUid: peer.peerUid
|
||||||
|
}], 'shortId').then()
|
||||||
|
return shortId
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMsgIdAndPeerByShortId(shortId: number): Promise<MsgIdAndPeerByShortId | undefined> {
|
||||||
|
const data = this.msgDataMap.getKey(shortId)
|
||||||
|
if (data) {
|
||||||
|
const [msgId, chatTypeStr, peerUid] = data.split('|')
|
||||||
|
const peer: Peer = {
|
||||||
|
chatType: parseInt(chatTypeStr),
|
||||||
|
peerUid,
|
||||||
|
guildId: '',
|
||||||
|
}
|
||||||
|
return { MsgId: msgId, Peer: peer }
|
||||||
|
}
|
||||||
|
const items = await this.db?.get('message', { shortId })
|
||||||
|
if (items?.length) {
|
||||||
|
const { msgId, chatType, peerUid } = items[0]
|
||||||
|
return {
|
||||||
|
MsgId: msgId,
|
||||||
|
Peer: {
|
||||||
|
chatType,
|
||||||
|
peerUid,
|
||||||
|
guildId: '',
|
||||||
}
|
}
|
||||||
const database = new Database<SQLiteTables>()
|
}
|
||||||
await database.connect(SQLite, {
|
|
||||||
path: path.join(dbDir, `${uin}.db`)
|
|
||||||
})
|
|
||||||
database.extend('message', {
|
|
||||||
shortId: 'integer(10)',
|
|
||||||
chatType: 'unsigned',
|
|
||||||
msgId: 'string(24)',
|
|
||||||
peerUid: 'string(24)'
|
|
||||||
}, {
|
|
||||||
primary: 'shortId'
|
|
||||||
})
|
|
||||||
database.extend('file_v2', {
|
|
||||||
fileName: 'string',
|
|
||||||
fileSize: 'string',
|
|
||||||
fileUuid: 'string(128)',
|
|
||||||
msgId: 'string(24)',
|
|
||||||
msgTime: 'unsigned(10)',
|
|
||||||
peerUid: 'string(24)',
|
|
||||||
chatType: 'unsigned',
|
|
||||||
elementId: 'string(24)',
|
|
||||||
elementType: 'unsigned',
|
|
||||||
}, {
|
|
||||||
primary: 'fileUuid',
|
|
||||||
indexes: ['fileName']
|
|
||||||
})
|
|
||||||
this.db = database
|
|
||||||
}
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
async getRecentMsgIds(Peer: Peer, size: number): Promise<string[]> {
|
getShortIdByMsgId(msgId: string): number | undefined {
|
||||||
const heads = this.msgIdMap.getHeads(size)
|
return this.msgIdMap.getValue(msgId)
|
||||||
if (!heads) {
|
}
|
||||||
return []
|
|
||||||
}
|
|
||||||
const data: (MsgIdAndPeerByShortId | undefined)[] = []
|
|
||||||
for (const t of heads) {
|
|
||||||
data.push(await MessageUnique.getMsgIdAndPeerByShortId(t.value))
|
|
||||||
}
|
|
||||||
const ret = data.filter((t) => t?.Peer.chatType === Peer.chatType && t?.Peer.peerUid === Peer.peerUid)
|
|
||||||
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
createMsg(peer: Peer, msgId: string): number {
|
async getPeerByMsgId(msgId: string) {
|
||||||
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`
|
const shortId = this.msgIdMap.getValue(msgId)
|
||||||
const hash = createHash('md5').update(key).digest()
|
if (!shortId) return undefined
|
||||||
//设置第一个bit为0 保证shortId为正数
|
return await this.getMsgIdAndPeerByShortId(shortId)
|
||||||
hash[0] &= 0x7f
|
}
|
||||||
const shortId = hash.readInt32BE(0)
|
|
||||||
//减少性能损耗
|
|
||||||
// const isExist = this.msgIdMap.getKey(shortId)
|
|
||||||
// if (isExist && isExist === msgId) {
|
|
||||||
// return shortId
|
|
||||||
// }
|
|
||||||
this.msgIdMap.set(msgId, shortId)
|
|
||||||
this.msgDataMap.set(key, shortId)
|
|
||||||
this.db?.upsert('message', [{
|
|
||||||
msgId,
|
|
||||||
shortId,
|
|
||||||
chatType: peer.chatType,
|
|
||||||
peerUid: peer.peerUid
|
|
||||||
}], 'shortId').then()
|
|
||||||
return shortId
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMsgIdAndPeerByShortId(shortId: number): Promise<MsgIdAndPeerByShortId | undefined> {
|
resize(maxSize: number): void {
|
||||||
const data = this.msgDataMap.getKey(shortId)
|
this.msgIdMap.resize(maxSize)
|
||||||
if (data) {
|
this.msgDataMap.resize(maxSize)
|
||||||
const [msgId, chatTypeStr, peerUid] = data.split('|')
|
}
|
||||||
const peer: Peer = {
|
|
||||||
chatType: parseInt(chatTypeStr),
|
|
||||||
peerUid,
|
|
||||||
guildId: '',
|
|
||||||
}
|
|
||||||
return { MsgId: msgId, Peer: peer }
|
|
||||||
}
|
|
||||||
const items = await this.db?.get('message', { shortId })
|
|
||||||
if (items?.length) {
|
|
||||||
const { msgId, chatType, peerUid } = items[0]
|
|
||||||
return {
|
|
||||||
MsgId: msgId,
|
|
||||||
Peer: {
|
|
||||||
chatType,
|
|
||||||
peerUid,
|
|
||||||
guildId: '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
getShortIdByMsgId(msgId: string): number | undefined {
|
addFileCache(data: FileCacheV2) {
|
||||||
return this.msgIdMap.getValue(msgId)
|
return this.db?.upsert('file_v2', [data], 'fileUuid')
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPeerByMsgId(msgId: string) {
|
getFileCacheByName(fileName: string) {
|
||||||
const shortId = this.msgIdMap.getValue(msgId)
|
return this.db?.get('file_v2', { fileName }, {
|
||||||
if (!shortId) return undefined
|
sort: { msgTime: 'desc' }
|
||||||
return await this.getMsgIdAndPeerByShortId(shortId)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(maxSize: number): void {
|
getFileCacheById(fileUuid: string) {
|
||||||
this.msgIdMap.resize(maxSize)
|
return this.db?.get('file_v2', { fileUuid })
|
||||||
this.msgDataMap.resize(maxSize)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
addFileCache(data: FileCacheV2) {
|
|
||||||
return this.db?.upsert('file_v2', [data], 'fileUuid')
|
|
||||||
}
|
|
||||||
|
|
||||||
getFileCacheByName(fileName: string) {
|
|
||||||
return this.db?.get('file_v2', { fileName }, {
|
|
||||||
sort: { msgTime: 'desc' }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
getFileCacheById(fileUuid: string) {
|
|
||||||
return this.db?.get('file_v2', { fileUuid })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MessageUnique: MessageUniqueWrapper = new MessageUniqueWrapper()
|
export const MessageUnique: MessageUniqueWrapper = new MessageUniqueWrapper()
|
@@ -1,72 +1,71 @@
|
|||||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/MessageUnique.ts#L5
|
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/MessageUnique.ts#L5
|
||||||
export class LimitedHashTable<K, V> {
|
export class LimitedHashTable<K, V> {
|
||||||
private keyToValue: Map<K, V> = new Map()
|
private keyToValue: Map<K, V> = new Map()
|
||||||
private valueToKey: Map<V, K> = new Map()
|
private valueToKey: Map<V, K> = new Map()
|
||||||
private maxSize: number
|
private maxSize: number
|
||||||
|
|
||||||
constructor(maxSize: number) {
|
constructor(maxSize: number) {
|
||||||
this.maxSize = maxSize
|
this.maxSize = maxSize
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(count: number) {
|
resize(count: number) {
|
||||||
this.maxSize = count
|
this.maxSize = count
|
||||||
}
|
}
|
||||||
|
|
||||||
set(key: K, value: V): void {
|
set(key: K, value: V): void {
|
||||||
this.keyToValue.set(key, value)
|
this.keyToValue.set(key, value)
|
||||||
this.valueToKey.set(value, key)
|
this.valueToKey.set(value, key)
|
||||||
while (this.keyToValue.size !== this.valueToKey.size) {
|
while (this.keyToValue.size !== this.valueToKey.size) {
|
||||||
console.log('keyToValue.size !== valueToKey.size Error Atom')
|
this.keyToValue.clear()
|
||||||
this.keyToValue.clear()
|
this.valueToKey.clear()
|
||||||
this.valueToKey.clear()
|
|
||||||
}
|
|
||||||
while (this.keyToValue.size > this.maxSize || this.valueToKey.size > this.maxSize) {
|
|
||||||
const oldestKey = this.keyToValue.keys().next().value
|
|
||||||
this.valueToKey.delete(this.keyToValue.get(oldestKey)!)
|
|
||||||
this.keyToValue.delete(oldestKey)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (this.keyToValue.size > this.maxSize || this.valueToKey.size > this.maxSize) {
|
||||||
|
const oldestKey = this.keyToValue.keys().next().value!
|
||||||
|
this.valueToKey.delete(this.keyToValue.get(oldestKey)!)
|
||||||
|
this.keyToValue.delete(oldestKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getValue(key: K): V | undefined {
|
getValue(key: K): V | undefined {
|
||||||
return this.keyToValue.get(key)
|
return this.keyToValue.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
getKey(value: V): K | undefined {
|
getKey(value: V): K | undefined {
|
||||||
return this.valueToKey.get(value)
|
return this.valueToKey.get(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteByValue(value: V): void {
|
deleteByValue(value: V): void {
|
||||||
const key = this.valueToKey.get(value)
|
const key = this.valueToKey.get(value)
|
||||||
if (key !== undefined) {
|
if (key !== undefined) {
|
||||||
this.keyToValue.delete(key)
|
this.keyToValue.delete(key)
|
||||||
this.valueToKey.delete(value)
|
this.valueToKey.delete(value)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deleteByKey(key: K): void {
|
deleteByKey(key: K): void {
|
||||||
const value = this.keyToValue.get(key)
|
const value = this.keyToValue.get(key)
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
this.keyToValue.delete(key)
|
this.keyToValue.delete(key)
|
||||||
this.valueToKey.delete(value)
|
this.valueToKey.delete(value)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getKeyList(): K[] {
|
getKeyList(): K[] {
|
||||||
return Array.from(this.keyToValue.keys())
|
return Array.from(this.keyToValue.keys())
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取最近刚写入的几个值
|
//获取最近刚写入的几个值
|
||||||
getHeads(size: number): { key: K; value: V }[] | undefined {
|
getHeads(size: number): { key: K, value: V }[] | undefined {
|
||||||
const keyList = this.getKeyList()
|
const keyList = this.getKeyList()
|
||||||
if (keyList.length === 0) {
|
if (keyList.length === 0) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
|
||||||
const result: { key: K; value: V }[] = []
|
|
||||||
const listSize = Math.min(size, keyList.length)
|
|
||||||
for (let i = 0; i < listSize; i++) {
|
|
||||||
const key = keyList[listSize - i]
|
|
||||||
result.push({ key, value: this.keyToValue.get(key)! })
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
const result: { key: K; value: V }[] = []
|
||||||
|
const listSize = Math.min(size, keyList.length)
|
||||||
|
for (let i = 0; i < listSize; i++) {
|
||||||
|
const key = keyList[listSize - i]
|
||||||
|
result.push({ key, value: this.keyToValue.get(key)! })
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
@@ -14,19 +14,14 @@ export default class Log {
|
|||||||
|
|
||||||
constructor(ctx: Context, cfg: Config) {
|
constructor(ctx: Context, cfg: Config) {
|
||||||
Logger.targets.splice(0, Logger.targets.length)
|
Logger.targets.splice(0, Logger.targets.length)
|
||||||
if (!cfg.enable) {
|
let enable = cfg.enable
|
||||||
return
|
|
||||||
}
|
|
||||||
const file = path.join(LOG_DIR, cfg.filename)
|
const file = path.join(LOG_DIR, cfg.filename)
|
||||||
/*const refreshNick = ctx.debounce(() => {
|
|
||||||
const ntUserApi = ctx.get('ntUserApi')
|
|
||||||
if (ntUserApi && !selfInfo.nick) {
|
|
||||||
ntUserApi.getSelfNick(true)
|
|
||||||
}
|
|
||||||
}, 1000)*/
|
|
||||||
const target: Logger.Target = {
|
const target: Logger.Target = {
|
||||||
colors: 0,
|
colors: 0,
|
||||||
record: (record: Logger.Record) => {
|
record: (record: Logger.Record) => {
|
||||||
|
if (!enable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const dateTime = new Date(record.timestamp).toLocaleString()
|
const dateTime = new Date(record.timestamp).toLocaleString()
|
||||||
const userInfo = selfInfo.uin ? `${selfInfo.nick}(${selfInfo.uin})` : ''
|
const userInfo = selfInfo.uin ? `${selfInfo.nick}(${selfInfo.uin})` : ''
|
||||||
const content = `${dateTime} [${record.type}] ${userInfo} | ${record.name} ${record.content}\n\n`
|
const content = `${dateTime} [${record.type}] ${userInfo} | ${record.name} ${record.content}\n\n`
|
||||||
@@ -34,5 +29,8 @@ export default class Log {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
Logger.targets.push(target)
|
Logger.targets.push(target)
|
||||||
|
ctx.on('llonebot/config-updated', input => {
|
||||||
|
enable = input.log!
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -202,7 +202,7 @@ function onLoad() {
|
|||||||
|
|
||||||
// 创建窗口时触发
|
// 创建窗口时触发
|
||||||
function onBrowserWindowCreated(window: BrowserWindow) {
|
function onBrowserWindowCreated(window: BrowserWindow) {
|
||||||
if (![2, 4].includes(window.id)) {
|
if (![2, 4, 6].includes(window.id)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (window.id === 2) {
|
if (window.id === 2) {
|
||||||
|
@@ -21,7 +21,6 @@ import { Peer } from '@/ntqqapi/types/msg'
|
|||||||
import { calculateFileMD5 } from '@/common/utils/file'
|
import { calculateFileMD5 } from '@/common/utils/file'
|
||||||
import { fileTypeFromFile } from 'file-type'
|
import { fileTypeFromFile } from 'file-type'
|
||||||
import fsPromise from 'node:fs/promises'
|
import fsPromise from 'node:fs/promises'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
|
||||||
import { OnRichMediaDownloadCompleteParams } from '@/ntqqapi/listeners'
|
import { OnRichMediaDownloadCompleteParams } from '@/ntqqapi/listeners'
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
@@ -39,7 +38,7 @@ export class NTQQFileApi extends Service {
|
|||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntFileApi', true)
|
super(ctx, 'ntFileApi', true)
|
||||||
this.rkeyManager = new RkeyManager(ctx, 'http://napcat-sign.wumiao.wang:2082/rkey')
|
this.rkeyManager = new RkeyManager(ctx, 'https://llob.linyuchen.net/rkey')
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVideoUrl(peer: Peer, msgId: string, elementId: string) {
|
async getVideoUrl(peer: Peer, msgId: string, elementId: string) {
|
||||||
@@ -143,76 +142,32 @@ export class NTQQFileApi extends Service {
|
|||||||
return sourcePath
|
return sourcePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let filePath: string
|
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
||||||
if (NTEventDispatch.initialised) {
|
'nodeIKernelMsgService/downloadRichMedia',
|
||||||
const data = await NTEventDispatch.CallNormalEvent<
|
[
|
||||||
(
|
|
||||||
params: {
|
|
||||||
fileModelId: string,
|
|
||||||
downloadSourceType: number,
|
|
||||||
triggerType: number,
|
|
||||||
msgId: string,
|
|
||||||
chatType: ChatType,
|
|
||||||
peerUid: string,
|
|
||||||
elementId: string,
|
|
||||||
thumbSize: number,
|
|
||||||
downloadType: number,
|
|
||||||
filePath: string
|
|
||||||
}) => Promise<unknown>,
|
|
||||||
(fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void
|
|
||||||
>(
|
|
||||||
'NodeIKernelMsgService/downloadRichMedia',
|
|
||||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
|
||||||
1,
|
|
||||||
timeout,
|
|
||||||
(arg: OnRichMediaDownloadCompleteParams) => {
|
|
||||||
if (arg.msgId === msgId) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
fileModelId: '0',
|
getReq: {
|
||||||
downloadSourceType: 0,
|
fileModelId: '0',
|
||||||
triggerType: 1,
|
downloadSourceType: 0,
|
||||||
msgId: msgId,
|
triggerType: 1,
|
||||||
chatType: chatType,
|
msgId: msgId,
|
||||||
peerUid: peerUid,
|
chatType: chatType,
|
||||||
elementId: elementId,
|
peerUid: peerUid,
|
||||||
thumbSize: 0,
|
elementId: elementId,
|
||||||
downloadType: 1,
|
thumbSize: 0,
|
||||||
filePath: thumbPath
|
downloadType: 1,
|
||||||
}
|
filePath: thumbPath,
|
||||||
)
|
|
||||||
filePath = data[1].filePath
|
|
||||||
} else {
|
|
||||||
const data = await invoke<{ notifyInfo: OnRichMediaDownloadCompleteParams }>(
|
|
||||||
'nodeIKernelMsgService/downloadRichMedia',
|
|
||||||
[
|
|
||||||
{
|
|
||||||
getReq: {
|
|
||||||
fileModelId: '0',
|
|
||||||
downloadSourceType: 0,
|
|
||||||
triggerType: 1,
|
|
||||||
msgId: msgId,
|
|
||||||
chatType: chatType,
|
|
||||||
peerUid: peerUid,
|
|
||||||
elementId: elementId,
|
|
||||||
thumbSize: 0,
|
|
||||||
downloadType: 1,
|
|
||||||
filePath: thumbPath,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
null,
|
},
|
||||||
],
|
null,
|
||||||
{
|
],
|
||||||
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
{
|
||||||
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
cbCmd: ReceiveCmdS.MEDIA_DOWNLOAD_COMPLETE,
|
||||||
timeout
|
cmdCB: payload => payload.notifyInfo.msgId === msgId,
|
||||||
}
|
timeout
|
||||||
)
|
}
|
||||||
filePath = data.notifyInfo.filePath
|
)
|
||||||
}
|
let filePath = data.notifyInfo.filePath
|
||||||
if (filePath.startsWith('\\')) {
|
if (filePath.startsWith('\\')) {
|
||||||
const downloadPath = TEMP_DIR
|
const downloadPath = TEMP_DIR
|
||||||
filePath = path.join(downloadPath, filePath)
|
filePath = path.join(downloadPath, filePath)
|
||||||
@@ -238,7 +193,7 @@ export class NTQQFileApi extends Service {
|
|||||||
const url: string = element.originImageUrl! // 没有域名
|
const url: string = element.originImageUrl! // 没有域名
|
||||||
const md5HexStr = element.md5HexStr
|
const md5HexStr = element.md5HexStr
|
||||||
const fileMd5 = element.md5HexStr
|
const fileMd5 = element.md5HexStr
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
const parsedUrl = new URL(IMAGE_HTTP_HOST + url) //临时解析拼接
|
const parsedUrl = new URL(IMAGE_HTTP_HOST + url) //临时解析拼接
|
||||||
const imageAppid = parsedUrl.searchParams.get('appid')
|
const imageAppid = parsedUrl.searchParams.get('appid')
|
||||||
|
@@ -2,8 +2,7 @@ import { Friend, FriendV2, SimpleInfo, CategoryFriend } from '../types'
|
|||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { invoke, NTMethod, NTClass } from '../ntcall'
|
import { invoke, NTMethod, NTClass } from '../ntcall'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
import { BuddyListReqType } from '../services'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
|
||||||
import { Dict, pick } from 'cosmokit'
|
import { Dict, pick } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ export class NTQQFriendApi extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 大于或等于 26702 应使用 getBuddyV2 */
|
/** 大于或等于 26702 应使用 getBuddyV2 */
|
||||||
async getFriends(_forced = false) {
|
async getFriends() {
|
||||||
const data = await invoke<{
|
const data = await invoke<{
|
||||||
data: {
|
data: {
|
||||||
categoryId: number
|
categoryId: number
|
||||||
@@ -75,9 +74,7 @@ export class NTQQFriendApi extends Service {
|
|||||||
const buddyService = session.getBuddyService()
|
const buddyService = session.getBuddyService()
|
||||||
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids))
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids))
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await session.getProfileService().getCoreAndBaseInfo('nodeStore', uids)
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
|
||||||
)
|
|
||||||
return Array.from(data.values())
|
return Array.from(data.values())
|
||||||
} else {
|
} else {
|
||||||
const data = await invoke<{
|
const data = await invoke<{
|
||||||
@@ -92,11 +89,8 @@ export class NTQQFriendApi extends Service {
|
|||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const categoryUids: Map<number, string[]> = new Map()
|
const uids = data.buddyCategory.flatMap(item => item.buddyUids)
|
||||||
for (const item of data.buddyCategory) {
|
return Object.values(data.userSimpleInfos).filter(v => uids.includes(v.uid!))
|
||||||
categoryUids.set(item.categoryId, item.buddyUids)
|
|
||||||
}
|
|
||||||
return Object.values(data.userSimpleInfos).filter(v => v.baseInfo && categoryUids.get(v.baseInfo.categoryId)?.includes(v.uid!))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +100,10 @@ export class NTQQFriendApi extends Service {
|
|||||||
const session = getSession()
|
const session = getSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
const uids: string[] = []
|
const uids: string[] = []
|
||||||
const buddyService = session?.getBuddyService()
|
const buddyService = session.getBuddyService()
|
||||||
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids))
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids))
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await session.getProfileService().getCoreAndBaseInfo('nodeStore', uids)
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
|
||||||
)
|
|
||||||
for (const [, item] of data) {
|
for (const [, item] of data) {
|
||||||
if (retMap.size > 5000) {
|
if (retMap.size > 5000) {
|
||||||
break
|
break
|
||||||
@@ -155,9 +147,7 @@ export class NTQQFriendApi extends Service {
|
|||||||
})
|
})
|
||||||
return item.buddyUids
|
return item.buddyUids
|
||||||
}))
|
}))
|
||||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
const data = await session.getProfileService().getCoreAndBaseInfo('nodeStore', uids)
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
|
||||||
)
|
|
||||||
return Array.from(data).map(([key, value]) => {
|
return Array.from(data).map(([key, value]) => {
|
||||||
const category = categoryMap.get(key)
|
const category = categoryMap.get(key)
|
||||||
return category ? { ...value, categoryId: category.categoryId, categroyName: category.categroyName } : value
|
return category ? { ...value, categoryId: category.categoryId, categroyName: category.categroyName } : value
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes, GroupNotify, GetFileListParam } from '../types'
|
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes, GetFileListParam, PublishGroupBulletinReq } from '../types'
|
||||||
import { invoke, NTClass, NTMethod } from '../ntcall'
|
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { NTQQWindows } from './window'
|
import { NTQQWindows } from './window'
|
||||||
@@ -24,7 +24,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
super(ctx, 'ntGroupApi', true)
|
super(ctx, 'ntGroupApi', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroups(forced = false): Promise<Group[]> {
|
async getGroups(): Promise<Group[]> {
|
||||||
const result = await invoke<{
|
const result = await invoke<{
|
||||||
updateType: number
|
updateType: number
|
||||||
groupList: Group[]
|
groupList: Group[]
|
||||||
@@ -288,4 +288,16 @@ export class NTQQGroupApi extends Service {
|
|||||||
)
|
)
|
||||||
return data.fileInfo.item
|
return data.fileInfo.item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async publishGroupBulletin(groupCode: string, req: PublishGroupBulletinReq) {
|
||||||
|
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||||
|
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||||
|
return await invoke('nodeIKernelGroupService/publishGroupBulletin', [{ groupCode, psKey, req }, null])
|
||||||
|
}
|
||||||
|
|
||||||
|
async uploadGroupBulletinPic(groupCode: string, path: string) {
|
||||||
|
const ntUserApi = this.ctx.get('ntUserApi')!
|
||||||
|
const psKey = (await ntUserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!
|
||||||
|
return await invoke('nodeIKernelGroupService/uploadGroupBulletinPic', [{ groupCode, psKey, path }, null])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -252,4 +252,8 @@ export class NTQQMsgApi extends Service {
|
|||||||
}
|
}
|
||||||
}, null])
|
}, null])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setMsgRead(peer: Peer) {
|
||||||
|
return await invoke('nodeIKernelMsgService/setMsgRead', [{ peer }, null])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ export class NTQQUserApi extends Service {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfo(uid: string, _getLevel = false) {
|
async getUserDetailInfo(uid: string) {
|
||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return this.fetchUserDetailInfo(uid)
|
return this.fetchUserDetailInfo(uid)
|
||||||
}
|
}
|
||||||
@@ -109,6 +109,10 @@ export class NTQQUserApi extends Service {
|
|||||||
return cookies
|
return cookies
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPSkey(domains: string[]) {
|
||||||
|
return await invoke('nodeIKernelTipOffService/getPskey', [{ domains, isForNewPCQQ: true }, null])
|
||||||
|
}
|
||||||
|
|
||||||
genBkn(sKey: string) {
|
genBkn(sKey: string) {
|
||||||
sKey = sKey || ''
|
sKey = sKey || ''
|
||||||
let hash = 5381
|
let hash = 5381
|
||||||
@@ -292,4 +296,19 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
}, null])
|
}, null])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getProfileLike(uid: string) {
|
||||||
|
return await invoke('nodeIKernelProfileLikeService/getBuddyProfileLike', [{
|
||||||
|
req: {
|
||||||
|
friendUids: [uid],
|
||||||
|
basic: 1,
|
||||||
|
vote: 1,
|
||||||
|
favorite: 0,
|
||||||
|
userProfile: 1,
|
||||||
|
type: 2,
|
||||||
|
start: 0,
|
||||||
|
limit: 20,
|
||||||
|
}
|
||||||
|
}, null])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { invoke, NTClass, NTMethod } from '../ntcall'
|
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { ReceiveCmd } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { BrowserWindow } from 'electron'
|
import { BrowserWindow } from 'electron'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ export class NTQQWindowApi extends Service {
|
|||||||
async openWindow<R = GeneralCallResult>(
|
async openWindow<R = GeneralCallResult>(
|
||||||
ntQQWindow: NTQQWindow,
|
ntQQWindow: NTQQWindow,
|
||||||
args: unknown[],
|
args: unknown[],
|
||||||
cbCmd: ReceiveCmd | undefined,
|
cbCmd: ReceiveCmdS | undefined,
|
||||||
autoCloseSeconds: number = 2,
|
autoCloseSeconds: number = 2,
|
||||||
) {
|
) {
|
||||||
const result = await invoke<R>(
|
const result = await invoke<R>(
|
||||||
|
@@ -2,8 +2,6 @@ import fs from 'node:fs'
|
|||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { registerCallHook, registerReceiveHook, ReceiveCmdS } from './hook'
|
import { registerCallHook, registerReceiveHook, ReceiveCmdS } from './hook'
|
||||||
import { MessageUnique } from '../common/utils/messageUnique'
|
import { MessageUnique } from '../common/utils/messageUnique'
|
||||||
import { NTEventDispatch } from '../common/utils/eventTask'
|
|
||||||
import { wrapperConstructor, getSession } from './wrapper'
|
|
||||||
import { Config as LLOBConfig } from '../common/types'
|
import { Config as LLOBConfig } from '../common/types'
|
||||||
import { llonebotError } from '../common/globalVars'
|
import { llonebotError } from '../common/globalVars'
|
||||||
import { isNumeric } from '../common/utils/misc'
|
import { isNumeric } from '../common/utils/misc'
|
||||||
@@ -21,6 +19,7 @@ import {
|
|||||||
} from './types'
|
} from './types'
|
||||||
import { selfInfo } from '../common/globalVars'
|
import { selfInfo } from '../common/globalVars'
|
||||||
import { version } from '../version'
|
import { version } from '../version'
|
||||||
|
import { invoke } from './ntcall'
|
||||||
|
|
||||||
declare module 'cordis' {
|
declare module 'cordis' {
|
||||||
interface Context {
|
interface Context {
|
||||||
@@ -32,7 +31,8 @@ declare module 'cordis' {
|
|||||||
'nt/message-sent': (input: RawMessage[]) => void
|
'nt/message-sent': (input: RawMessage[]) => void
|
||||||
'nt/group-notify': (input: GroupNotify[]) => void
|
'nt/group-notify': (input: GroupNotify[]) => void
|
||||||
'nt/friend-request': (input: FriendRequest[]) => void
|
'nt/friend-request': (input: FriendRequest[]) => void
|
||||||
'nt/group-member-info-updated': (input: { groupCode: string; members: GroupMember[] }) => void
|
'nt/group-member-info-updated': (input: { groupCode: string, members: GroupMember[] }) => void
|
||||||
|
'nt/system-message-created': (input: Uint8Array) => void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +45,6 @@ class Core extends Service {
|
|||||||
|
|
||||||
public start() {
|
public start() {
|
||||||
llonebotError.otherError = ''
|
llonebotError.otherError = ''
|
||||||
const WrapperSession = getSession()
|
|
||||||
if (WrapperSession) {
|
|
||||||
NTEventDispatch.init({ ListenerMap: wrapperConstructor, WrapperSession })
|
|
||||||
}
|
|
||||||
MessageUnique.init(selfInfo.uin)
|
MessageUnique.init(selfInfo.uin)
|
||||||
this.registerListener()
|
this.registerListener()
|
||||||
this.ctx.logger.info(`LLOneBot/${version}`)
|
this.ctx.logger.info(`LLOneBot/${version}`)
|
||||||
@@ -191,12 +187,6 @@ class Core extends Service {
|
|||||||
})
|
})
|
||||||
|
|
||||||
registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, payload => {
|
registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, payload => {
|
||||||
const { msgId, chatType, peerUid } = payload.msgRecord
|
|
||||||
const peer = {
|
|
||||||
chatType,
|
|
||||||
peerUid
|
|
||||||
}
|
|
||||||
MessageUnique.createMsg(peer, msgId)
|
|
||||||
if (!this.config.reportSelfMessage) {
|
if (!this.config.reportSelfMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -231,6 +221,14 @@ class Core extends Service {
|
|||||||
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, payload => {
|
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, payload => {
|
||||||
this.ctx.parallel('nt/friend-request', payload.data.buddyReqs)
|
this.ctx.parallel('nt/friend-request', payload.data.buddyReqs)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
invoke('nodeIKernelMsgListener/onRecvSysMsg', [], { classNameIsRegister: true })
|
||||||
|
|
||||||
|
registerReceiveHook<{
|
||||||
|
msgBuf: number[]
|
||||||
|
}>('nodeIKernelMsgListener/onRecvSysMsg', payload => {
|
||||||
|
this.ctx.parallel('nt/system-message-created', Uint8Array.from(payload.msgBuf))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -99,19 +99,20 @@ export namespace SendElementEntities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function file(ctx: Context, filePath: string, fileName = '', folderId = ''): Promise<SendFileElement> {
|
export async function file(ctx: Context, filePath: string, fileName: string, folderId = ''): Promise<SendFileElement> {
|
||||||
const { fileName: _fileName, path, fileSize } = await ctx.ntFileApi.uploadFile(filePath, ElementType.FILE)
|
const fileSize = (await stat(filePath)).size.toString()
|
||||||
if (fileSize === 0) {
|
if (fileSize === '0') {
|
||||||
throw '文件异常,大小为 0'
|
ctx.logger.warn(`文件${fileName}异常,大小为 0`)
|
||||||
|
throw new Error('文件异常,大小为 0')
|
||||||
}
|
}
|
||||||
const element: SendFileElement = {
|
const element: SendFileElement = {
|
||||||
elementType: ElementType.FILE,
|
elementType: ElementType.FILE,
|
||||||
elementId: '',
|
elementId: '',
|
||||||
fileElement: {
|
fileElement: {
|
||||||
fileName: fileName || _fileName,
|
fileName,
|
||||||
folderId: folderId,
|
folderId,
|
||||||
filePath: path!,
|
filePath,
|
||||||
fileSize: fileSize.toString(),
|
fileSize,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return element
|
return element
|
||||||
@@ -201,7 +202,7 @@ export namespace SendElementEntities {
|
|||||||
// log("生成缩略图", _thumbPath)
|
// log("生成缩略图", _thumbPath)
|
||||||
thumbPath.set(0, _thumbPath)
|
thumbPath.set(0, _thumbPath)
|
||||||
const thumbMd5 = await calculateFileMD5(_thumbPath)
|
const thumbMd5 = await calculateFileMD5(_thumbPath)
|
||||||
let element: SendVideoElement = {
|
const element: SendVideoElement = {
|
||||||
elementType: ElementType.VIDEO,
|
elementType: ElementType.VIDEO,
|
||||||
elementId: '',
|
elementId: '',
|
||||||
videoElement: {
|
videoElement: {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Context } from "cordis"
|
import { Context } from 'cordis'
|
||||||
|
|
||||||
interface ServerRkeyData {
|
interface ServerRkeyData {
|
||||||
group_rkey: string
|
group_rkey: string
|
||||||
|
@@ -6,48 +6,46 @@ import { Dict } from 'cosmokit'
|
|||||||
|
|
||||||
export const hookApiCallbacks: Record<string, (res: any) => void> = {}
|
export const hookApiCallbacks: Record<string, (res: any) => void> = {}
|
||||||
|
|
||||||
export const ReceiveCmdS = {
|
export enum ReceiveCmdS {
|
||||||
RECENT_CONTACT: 'nodeIKernelRecentContactListener/onRecentContactListChangedVer2',
|
RECENT_CONTACT = 'nodeIKernelRecentContactListener/onRecentContactListChangedVer2',
|
||||||
UPDATE_MSG: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
UPDATE_MSG = 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
UPDATE_ACTIVE_MSG: 'nodeIKernelMsgListener/onActiveMsgInfoUpdate',
|
UPDATE_ACTIVE_MSG = 'nodeIKernelMsgListener/onActiveMsgInfoUpdate',
|
||||||
NEW_MSG: `nodeIKernelMsgListener/onRecvMsg`,
|
NEW_MSG = 'nodeIKernelMsgListener/onRecvMsg',
|
||||||
NEW_ACTIVE_MSG: `nodeIKernelMsgListener/onRecvActiveMsg`,
|
NEW_ACTIVE_MSG = 'nodeIKernelMsgListener/onRecvActiveMsg',
|
||||||
SELF_SEND_MSG: 'nodeIKernelMsgListener/onAddSendMsg',
|
SELF_SEND_MSG = 'nodeIKernelMsgListener/onAddSendMsg',
|
||||||
USER_INFO: 'nodeIKernelProfileListener/onProfileSimpleChanged',
|
USER_INFO = 'nodeIKernelProfileListener/onProfileSimpleChanged',
|
||||||
USER_DETAIL_INFO: 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
USER_DETAIL_INFO = 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
||||||
GROUPS: 'nodeIKernelGroupListener/onGroupListUpdate',
|
GROUPS = 'nodeIKernelGroupListener/onGroupListUpdate',
|
||||||
GROUPS_STORE: 'onGroupListUpdate',
|
GROUPS_STORE = 'onGroupListUpdate',
|
||||||
GROUP_MEMBER_INFO_UPDATE: 'nodeIKernelGroupListener/onMemberInfoChange',
|
GROUP_MEMBER_INFO_UPDATE = 'nodeIKernelGroupListener/onMemberInfoChange',
|
||||||
FRIENDS: 'onBuddyListChange',
|
FRIENDS = 'onBuddyListChange',
|
||||||
MEDIA_DOWNLOAD_COMPLETE: 'nodeIKernelMsgListener/onRichMediaDownloadComplete',
|
MEDIA_DOWNLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||||
UNREAD_GROUP_NOTIFY: 'nodeIKernelGroupListener/onGroupNotifiesUnreadCountUpdated',
|
UNREAD_GROUP_NOTIFY = 'nodeIKernelGroupListener/onGroupNotifiesUnreadCountUpdated',
|
||||||
GROUP_NOTIFY: 'nodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
GROUP_NOTIFY = 'nodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
||||||
FRIEND_REQUEST: 'nodeIKernelBuddyListener/onBuddyReqChange',
|
FRIEND_REQUEST = 'nodeIKernelBuddyListener/onBuddyReqChange',
|
||||||
SELF_STATUS: 'nodeIKernelProfileListener/onSelfStatusChanged',
|
SELF_STATUS = 'nodeIKernelProfileListener/onSelfStatusChanged',
|
||||||
CACHE_SCAN_FINISH: 'nodeIKernelStorageCleanListener/onFinishScan',
|
CACHE_SCAN_FINISH = 'nodeIKernelStorageCleanListener/onFinishScan',
|
||||||
MEDIA_UPLOAD_COMPLETE: 'nodeIKernelMsgListener/onRichMediaUploadComplete',
|
MEDIA_UPLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaUploadComplete',
|
||||||
SKEY_UPDATE: 'onSkeyUpdate',
|
SKEY_UPDATE = 'onSkeyUpdate',
|
||||||
} as const
|
}
|
||||||
|
|
||||||
export type ReceiveCmd = string
|
type NTReturnData = [
|
||||||
|
{
|
||||||
interface NTQQApiReturnData extends Array<unknown> {
|
|
||||||
0: {
|
|
||||||
type: 'request'
|
type: 'request'
|
||||||
eventName: NTClass
|
eventName: NTClass
|
||||||
callbackId?: string
|
callbackId?: string
|
||||||
}
|
},
|
||||||
1: {
|
{
|
||||||
cmdName: ReceiveCmd
|
cmdName: ReceiveCmdS
|
||||||
cmdType: 'event'
|
cmdType: 'event'
|
||||||
payload: unknown
|
payload: unknown
|
||||||
}[]
|
}[]
|
||||||
}
|
]
|
||||||
|
|
||||||
const logHook = false
|
const logHook = false
|
||||||
|
|
||||||
const receiveHooks: Array<{
|
const receiveHooks: Array<{
|
||||||
method: ReceiveCmd[]
|
method: ReceiveCmdS[]
|
||||||
hookFunc: (payload: any) => void | Promise<void>
|
hookFunc: (payload: any) => void | Promise<void>
|
||||||
id: string
|
id: string
|
||||||
}> = []
|
}> = []
|
||||||
@@ -58,62 +56,44 @@ const callHooks: Array<{
|
|||||||
}> = []
|
}> = []
|
||||||
|
|
||||||
export function hookNTQQApiReceive(window: BrowserWindow, onlyLog: boolean) {
|
export function hookNTQQApiReceive(window: BrowserWindow, onlyLog: boolean) {
|
||||||
const originalSend = window.webContents.send
|
window.webContents.send = new Proxy(window.webContents.send, {
|
||||||
const patchSend = (channel: string, ...args: NTQQApiReturnData) => {
|
apply(target, thisArg, args: [channel: string, ...args: NTReturnData]) {
|
||||||
try {
|
try {
|
||||||
const isLogger = args[0]?.eventName?.startsWith('ns-LoggerApi')
|
if (logHook && !args[1]?.eventName?.startsWith('ns-LoggerApi')) {
|
||||||
if (logHook && !isLogger) {
|
log('received ntqq api message', args)
|
||||||
log(`received ntqq api message: ${channel}`, args)
|
}
|
||||||
}
|
} catch { }
|
||||||
} catch { }
|
if (!onlyLog) {
|
||||||
if (!onlyLog) {
|
if (args[2] instanceof Array) {
|
||||||
if (args?.[1] instanceof Array) {
|
for (const receiveData of args[2]) {
|
||||||
for (const receiveData of args[1]) {
|
const ntMethodName = receiveData.cmdName
|
||||||
const ntQQApiMethodName = receiveData.cmdName
|
for (const hook of receiveHooks) {
|
||||||
// log(`received ntqq api message: ${channel} ${ntQQApiMethodName}`, JSON.stringify(receiveData))
|
if (hook.method.includes(ntMethodName)) {
|
||||||
for (const hook of receiveHooks) {
|
Promise.resolve(hook.hookFunc(receiveData.payload))
|
||||||
if (hook.method.includes(ntQQApiMethodName)) {
|
}
|
||||||
new Promise(resolve => {
|
|
||||||
try {
|
|
||||||
hook.hookFunc(receiveData.payload)
|
|
||||||
} catch (e) {
|
|
||||||
log('hook error', ntQQApiMethodName, (e as Error).stack?.toString())
|
|
||||||
}
|
|
||||||
resolve(undefined)
|
|
||||||
}).then()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (args[1]?.callbackId) {
|
||||||
if (args[0]?.callbackId) {
|
const callbackId = args[1].callbackId
|
||||||
// log("hookApiCallback", hookApiCallbacks, args)
|
if (hookApiCallbacks[callbackId]) {
|
||||||
const callbackId = args[0].callbackId
|
Promise.resolve(hookApiCallbacks[callbackId](args[2]))
|
||||||
if (hookApiCallbacks[callbackId]) {
|
delete hookApiCallbacks[callbackId]
|
||||||
new Promise(resolve => {
|
}
|
||||||
hookApiCallbacks[callbackId](args[1])
|
|
||||||
resolve(undefined)
|
|
||||||
}).then()
|
|
||||||
delete hookApiCallbacks[callbackId]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return target.apply(thisArg, args)
|
||||||
originalSend.call(window.webContents, channel, ...args)
|
},
|
||||||
}
|
})
|
||||||
window.webContents.send = patchSend
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
||||||
// 监听调用NTQQApi
|
|
||||||
const webContents = window.webContents as Dict
|
const webContents = window.webContents as Dict
|
||||||
const ipc_message_proxy = webContents._events['-ipc-message']?.[0] || webContents._events['-ipc-message']
|
const ipc_message_proxy = webContents._events['-ipc-message']?.[0] || webContents._events['-ipc-message']
|
||||||
|
|
||||||
const proxyIpcMsg = new Proxy(ipc_message_proxy, {
|
const proxyIpcMsg = new Proxy(ipc_message_proxy, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
// console.log(thisArg, args);
|
const isLogger = args[3]?.[0]?.eventName?.startsWith('ns-LoggerApi')
|
||||||
let isLogger = false
|
|
||||||
try {
|
|
||||||
isLogger = args[3][0].eventName.startsWith('ns-LoggerApi')
|
|
||||||
} catch (e) { }
|
|
||||||
if (!isLogger) {
|
if (!isLogger) {
|
||||||
try {
|
try {
|
||||||
logHook && log('call NTQQ api', thisArg, args)
|
logHook && log('call NTQQ api', thisArg, args)
|
||||||
@@ -121,21 +101,14 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
|||||||
if (!onlyLog) {
|
if (!onlyLog) {
|
||||||
try {
|
try {
|
||||||
const _args: unknown[] = args[3][1]
|
const _args: unknown[] = args[3][1]
|
||||||
const cmdName: NTMethod = _args[0] as NTMethod
|
const cmdName = _args[0] as NTMethod
|
||||||
const callParams = _args.slice(1)
|
const callParams = _args.slice(1)
|
||||||
callHooks.forEach((hook) => {
|
callHooks.forEach((hook) => {
|
||||||
if (hook.method.includes(cmdName)) {
|
if (hook.method.includes(cmdName)) {
|
||||||
new Promise(resolve => {
|
Promise.resolve(hook.hookFunc(callParams))
|
||||||
try {
|
|
||||||
hook.hookFunc(callParams)
|
|
||||||
} catch (e) {
|
|
||||||
log('hook call error', e, _args)
|
|
||||||
}
|
|
||||||
resolve(undefined)
|
|
||||||
}).then()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) { }
|
} catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return target.apply(thisArg, args)
|
return target.apply(thisArg, args)
|
||||||
@@ -147,7 +120,7 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
|||||||
webContents._events['-ipc-message'] = proxyIpcMsg
|
webContents._events['-ipc-message'] = proxyIpcMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
const ipc_invoke_proxy = webContents._events['-ipc-invoke']?.[0] || webContents._events['-ipc-invoke']
|
/*const ipc_invoke_proxy = webContents._events['-ipc-invoke']?.[0] || webContents._events['-ipc-invoke']
|
||||||
const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
|
const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
|
||||||
apply(target, thisArg, args) {
|
apply(target, thisArg, args) {
|
||||||
//HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
|
//HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
|
||||||
@@ -157,9 +130,7 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const ret = target.apply(thisArg, args)
|
const ret = target.apply(thisArg, args)
|
||||||
/*try {
|
//HOOK_LOG && log('call NTQQ invoke api return', ret)
|
||||||
HOOK_LOG && log('call NTQQ invoke api return', ret)
|
|
||||||
} catch (e) { }*/
|
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -167,11 +138,11 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
|||||||
webContents._events['-ipc-invoke'][0] = proxyIpcInvoke
|
webContents._events['-ipc-invoke'][0] = proxyIpcInvoke
|
||||||
} else {
|
} else {
|
||||||
webContents._events['-ipc-invoke'] = proxyIpcInvoke
|
webContents._events['-ipc-invoke'] = proxyIpcInvoke
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerReceiveHook<PayloadType>(
|
export function registerReceiveHook<PayloadType>(
|
||||||
method: ReceiveCmd | ReceiveCmd[],
|
method: string | string[],
|
||||||
hookFunc: (payload: PayloadType) => void,
|
hookFunc: (payload: PayloadType) => void,
|
||||||
): string {
|
): string {
|
||||||
const id = randomUUID()
|
const id = randomUUID()
|
||||||
@@ -179,7 +150,7 @@ export function registerReceiveHook<PayloadType>(
|
|||||||
method = [method]
|
method = [method]
|
||||||
}
|
}
|
||||||
receiveHooks.push({
|
receiveHooks.push({
|
||||||
method,
|
method: method as ReceiveCmdS[],
|
||||||
hookFunc,
|
hookFunc,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
|
@@ -136,7 +136,6 @@ export function invoke<
|
|||||||
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
// 这里的callback比较特殊,QQ后端先返回是否调用成功,再返回一条结果数据
|
||||||
const secondCallback = () => {
|
const secondCallback = () => {
|
||||||
const hookId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
|
const hookId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
|
||||||
// log(methodName, "second callback", cbCmd, payload, cmdCB);
|
|
||||||
if (options.cmdCB) {
|
if (options.cmdCB) {
|
||||||
if (options.cmdCB(payload, result)) {
|
if (options.cmdCB(payload, result)) {
|
||||||
removeReceiveHook(hookId)
|
removeReceiveHook(hookId)
|
||||||
|
768
src/ntqqapi/proto/compiled.d.ts
vendored
Normal file
768
src/ntqqapi/proto/compiled.d.ts
vendored
Normal file
@@ -0,0 +1,768 @@
|
|||||||
|
import * as $protobuf from "protobufjs";
|
||||||
|
import Long = require("long");
|
||||||
|
/** Namespace SysMsg. */
|
||||||
|
export namespace SysMsg {
|
||||||
|
|
||||||
|
/** Properties of a SystemMessage. */
|
||||||
|
interface ISystemMessage {
|
||||||
|
|
||||||
|
/** SystemMessage header */
|
||||||
|
header?: (SysMsg.ISystemMessageHeader[]|null);
|
||||||
|
|
||||||
|
/** SystemMessage msgSpec */
|
||||||
|
msgSpec?: (SysMsg.ISystemMessageMsgSpec[]|null);
|
||||||
|
|
||||||
|
/** SystemMessage bodyWrapper */
|
||||||
|
bodyWrapper?: (SysMsg.ISystemMessageBodyWrapper|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a SystemMessage. */
|
||||||
|
class SystemMessage implements ISystemMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new SystemMessage.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ISystemMessage);
|
||||||
|
|
||||||
|
/** SystemMessage header. */
|
||||||
|
public header: SysMsg.ISystemMessageHeader[];
|
||||||
|
|
||||||
|
/** SystemMessage msgSpec. */
|
||||||
|
public msgSpec: SysMsg.ISystemMessageMsgSpec[];
|
||||||
|
|
||||||
|
/** SystemMessage bodyWrapper. */
|
||||||
|
public bodyWrapper?: (SysMsg.ISystemMessageBodyWrapper|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SystemMessage instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns SystemMessage instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ISystemMessage): SysMsg.SystemMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessage message. Does not implicitly {@link SysMsg.SystemMessage.verify|verify} messages.
|
||||||
|
* @param message SystemMessage message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ISystemMessage, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessage message, length delimited. Does not implicitly {@link SysMsg.SystemMessage.verify|verify} messages.
|
||||||
|
* @param message SystemMessage message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ISystemMessage, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessage message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns SystemMessage
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.SystemMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessage message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns SystemMessage
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a SystemMessage message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SystemMessage message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns SystemMessage
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a SystemMessage message. Also converts values to other types if specified.
|
||||||
|
* @param message SystemMessage
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.SystemMessage, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this SystemMessage to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for SystemMessage
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a SystemMessageHeader. */
|
||||||
|
interface ISystemMessageHeader {
|
||||||
|
|
||||||
|
/** SystemMessageHeader peerNumber */
|
||||||
|
peerNumber?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageHeader peerString */
|
||||||
|
peerString?: (string|null);
|
||||||
|
|
||||||
|
/** SystemMessageHeader uin */
|
||||||
|
uin?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageHeader uid */
|
||||||
|
uid?: (string|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a SystemMessageHeader. */
|
||||||
|
class SystemMessageHeader implements ISystemMessageHeader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new SystemMessageHeader.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ISystemMessageHeader);
|
||||||
|
|
||||||
|
/** SystemMessageHeader peerNumber. */
|
||||||
|
public peerNumber: number;
|
||||||
|
|
||||||
|
/** SystemMessageHeader peerString. */
|
||||||
|
public peerString: string;
|
||||||
|
|
||||||
|
/** SystemMessageHeader uin. */
|
||||||
|
public uin: number;
|
||||||
|
|
||||||
|
/** SystemMessageHeader uid. */
|
||||||
|
public uid?: (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SystemMessageHeader instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns SystemMessageHeader instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ISystemMessageHeader): SysMsg.SystemMessageHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageHeader message. Does not implicitly {@link SysMsg.SystemMessageHeader.verify|verify} messages.
|
||||||
|
* @param message SystemMessageHeader message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ISystemMessageHeader, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageHeader message, length delimited. Does not implicitly {@link SysMsg.SystemMessageHeader.verify|verify} messages.
|
||||||
|
* @param message SystemMessageHeader message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ISystemMessageHeader, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageHeader message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns SystemMessageHeader
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.SystemMessageHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageHeader message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns SystemMessageHeader
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a SystemMessageHeader message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SystemMessageHeader message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns SystemMessageHeader
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a SystemMessageHeader message. Also converts values to other types if specified.
|
||||||
|
* @param message SystemMessageHeader
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.SystemMessageHeader, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this SystemMessageHeader to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for SystemMessageHeader
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a SystemMessageMsgSpec. */
|
||||||
|
interface ISystemMessageMsgSpec {
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec msgType */
|
||||||
|
msgType?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec subType */
|
||||||
|
subType?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec subSubType */
|
||||||
|
subSubType?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec msgSeq */
|
||||||
|
msgSeq?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec time */
|
||||||
|
time?: (number|null);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec other */
|
||||||
|
other?: (number|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a SystemMessageMsgSpec. */
|
||||||
|
class SystemMessageMsgSpec implements ISystemMessageMsgSpec {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new SystemMessageMsgSpec.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ISystemMessageMsgSpec);
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec msgType. */
|
||||||
|
public msgType: number;
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec subType. */
|
||||||
|
public subType: number;
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec subSubType. */
|
||||||
|
public subSubType: number;
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec msgSeq. */
|
||||||
|
public msgSeq: number;
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec time. */
|
||||||
|
public time: number;
|
||||||
|
|
||||||
|
/** SystemMessageMsgSpec other. */
|
||||||
|
public other: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SystemMessageMsgSpec instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns SystemMessageMsgSpec instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ISystemMessageMsgSpec): SysMsg.SystemMessageMsgSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageMsgSpec message. Does not implicitly {@link SysMsg.SystemMessageMsgSpec.verify|verify} messages.
|
||||||
|
* @param message SystemMessageMsgSpec message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ISystemMessageMsgSpec, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageMsgSpec message, length delimited. Does not implicitly {@link SysMsg.SystemMessageMsgSpec.verify|verify} messages.
|
||||||
|
* @param message SystemMessageMsgSpec message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ISystemMessageMsgSpec, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageMsgSpec message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns SystemMessageMsgSpec
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.SystemMessageMsgSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageMsgSpec message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns SystemMessageMsgSpec
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageMsgSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a SystemMessageMsgSpec message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SystemMessageMsgSpec message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns SystemMessageMsgSpec
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageMsgSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a SystemMessageMsgSpec message. Also converts values to other types if specified.
|
||||||
|
* @param message SystemMessageMsgSpec
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.SystemMessageMsgSpec, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this SystemMessageMsgSpec to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for SystemMessageMsgSpec
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a SystemMessageBodyWrapper. */
|
||||||
|
interface ISystemMessageBodyWrapper {
|
||||||
|
|
||||||
|
/** SystemMessageBodyWrapper body */
|
||||||
|
body?: (Uint8Array|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a SystemMessageBodyWrapper. */
|
||||||
|
class SystemMessageBodyWrapper implements ISystemMessageBodyWrapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new SystemMessageBodyWrapper.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ISystemMessageBodyWrapper);
|
||||||
|
|
||||||
|
/** SystemMessageBodyWrapper body. */
|
||||||
|
public body: Uint8Array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SystemMessageBodyWrapper instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns SystemMessageBodyWrapper instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ISystemMessageBodyWrapper): SysMsg.SystemMessageBodyWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageBodyWrapper message. Does not implicitly {@link SysMsg.SystemMessageBodyWrapper.verify|verify} messages.
|
||||||
|
* @param message SystemMessageBodyWrapper message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ISystemMessageBodyWrapper, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified SystemMessageBodyWrapper message, length delimited. Does not implicitly {@link SysMsg.SystemMessageBodyWrapper.verify|verify} messages.
|
||||||
|
* @param message SystemMessageBodyWrapper message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ISystemMessageBodyWrapper, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageBodyWrapper message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns SystemMessageBodyWrapper
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.SystemMessageBodyWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a SystemMessageBodyWrapper message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns SystemMessageBodyWrapper
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.SystemMessageBodyWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a SystemMessageBodyWrapper message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SystemMessageBodyWrapper message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns SystemMessageBodyWrapper
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.SystemMessageBodyWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a SystemMessageBodyWrapper message. Also converts values to other types if specified.
|
||||||
|
* @param message SystemMessageBodyWrapper
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.SystemMessageBodyWrapper, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this SystemMessageBodyWrapper to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for SystemMessageBodyWrapper
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a LikeDetail. */
|
||||||
|
interface ILikeDetail {
|
||||||
|
|
||||||
|
/** LikeDetail txt */
|
||||||
|
txt?: (string|null);
|
||||||
|
|
||||||
|
/** LikeDetail uin */
|
||||||
|
uin?: (number|null);
|
||||||
|
|
||||||
|
/** LikeDetail nickname */
|
||||||
|
nickname?: (string|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a LikeDetail. */
|
||||||
|
class LikeDetail implements ILikeDetail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new LikeDetail.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ILikeDetail);
|
||||||
|
|
||||||
|
/** LikeDetail txt. */
|
||||||
|
public txt: string;
|
||||||
|
|
||||||
|
/** LikeDetail uin. */
|
||||||
|
public uin: number;
|
||||||
|
|
||||||
|
/** LikeDetail nickname. */
|
||||||
|
public nickname: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LikeDetail instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns LikeDetail instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ILikeDetail): SysMsg.LikeDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified LikeDetail message. Does not implicitly {@link SysMsg.LikeDetail.verify|verify} messages.
|
||||||
|
* @param message LikeDetail message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ILikeDetail, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified LikeDetail message, length delimited. Does not implicitly {@link SysMsg.LikeDetail.verify|verify} messages.
|
||||||
|
* @param message LikeDetail message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ILikeDetail, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a LikeDetail message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns LikeDetail
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.LikeDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a LikeDetail message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns LikeDetail
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a LikeDetail message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a LikeDetail message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns LikeDetail
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.LikeDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a LikeDetail message. Also converts values to other types if specified.
|
||||||
|
* @param message LikeDetail
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.LikeDetail, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this LikeDetail to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for LikeDetail
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a LikeMsg. */
|
||||||
|
interface ILikeMsg {
|
||||||
|
|
||||||
|
/** LikeMsg count */
|
||||||
|
count?: (number|null);
|
||||||
|
|
||||||
|
/** LikeMsg time */
|
||||||
|
time?: (number|null);
|
||||||
|
|
||||||
|
/** LikeMsg detail */
|
||||||
|
detail?: (SysMsg.ILikeDetail|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a LikeMsg. */
|
||||||
|
class LikeMsg implements ILikeMsg {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new LikeMsg.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.ILikeMsg);
|
||||||
|
|
||||||
|
/** LikeMsg count. */
|
||||||
|
public count: number;
|
||||||
|
|
||||||
|
/** LikeMsg time. */
|
||||||
|
public time: number;
|
||||||
|
|
||||||
|
/** LikeMsg detail. */
|
||||||
|
public detail?: (SysMsg.ILikeDetail|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LikeMsg instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns LikeMsg instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.ILikeMsg): SysMsg.LikeMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified LikeMsg message. Does not implicitly {@link SysMsg.LikeMsg.verify|verify} messages.
|
||||||
|
* @param message LikeMsg message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.ILikeMsg, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified LikeMsg message, length delimited. Does not implicitly {@link SysMsg.LikeMsg.verify|verify} messages.
|
||||||
|
* @param message LikeMsg message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.ILikeMsg, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a LikeMsg message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns LikeMsg
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.LikeMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a LikeMsg message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns LikeMsg
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.LikeMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a LikeMsg message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a LikeMsg message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns LikeMsg
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.LikeMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a LikeMsg message. Also converts values to other types if specified.
|
||||||
|
* @param message LikeMsg
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.LikeMsg, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this LikeMsg to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for LikeMsg
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Properties of a ProfileLikeTip. */
|
||||||
|
interface IProfileLikeTip {
|
||||||
|
|
||||||
|
/** ProfileLikeTip msg */
|
||||||
|
msg?: (SysMsg.ILikeMsg|null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Represents a ProfileLikeTip. */
|
||||||
|
class ProfileLikeTip implements IProfileLikeTip {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new ProfileLikeTip.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
*/
|
||||||
|
constructor(properties?: SysMsg.IProfileLikeTip);
|
||||||
|
|
||||||
|
/** ProfileLikeTip msg. */
|
||||||
|
public msg?: (SysMsg.ILikeMsg|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ProfileLikeTip instance using the specified properties.
|
||||||
|
* @param [properties] Properties to set
|
||||||
|
* @returns ProfileLikeTip instance
|
||||||
|
*/
|
||||||
|
public static create(properties?: SysMsg.IProfileLikeTip): SysMsg.ProfileLikeTip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified ProfileLikeTip message. Does not implicitly {@link SysMsg.ProfileLikeTip.verify|verify} messages.
|
||||||
|
* @param message ProfileLikeTip message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encode(message: SysMsg.IProfileLikeTip, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes the specified ProfileLikeTip message, length delimited. Does not implicitly {@link SysMsg.ProfileLikeTip.verify|verify} messages.
|
||||||
|
* @param message ProfileLikeTip message or plain object to encode
|
||||||
|
* @param [writer] Writer to encode to
|
||||||
|
* @returns Writer
|
||||||
|
*/
|
||||||
|
public static encodeDelimited(message: SysMsg.IProfileLikeTip, writer?: $protobuf.Writer): $protobuf.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a ProfileLikeTip message from the specified reader or buffer.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @param [length] Message length if known beforehand
|
||||||
|
* @returns ProfileLikeTip
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): SysMsg.ProfileLikeTip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a ProfileLikeTip message from the specified reader or buffer, length delimited.
|
||||||
|
* @param reader Reader or buffer to decode from
|
||||||
|
* @returns ProfileLikeTip
|
||||||
|
* @throws {Error} If the payload is not a reader or valid buffer
|
||||||
|
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
||||||
|
*/
|
||||||
|
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): SysMsg.ProfileLikeTip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a ProfileLikeTip message.
|
||||||
|
* @param message Plain object to verify
|
||||||
|
* @returns `null` if valid, otherwise the reason why it is not
|
||||||
|
*/
|
||||||
|
public static verify(message: { [k: string]: any }): (string|null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a ProfileLikeTip message from a plain object. Also converts values to their respective internal types.
|
||||||
|
* @param object Plain object
|
||||||
|
* @returns ProfileLikeTip
|
||||||
|
*/
|
||||||
|
public static fromObject(object: { [k: string]: any }): SysMsg.ProfileLikeTip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a plain object from a ProfileLikeTip message. Also converts values to other types if specified.
|
||||||
|
* @param message ProfileLikeTip
|
||||||
|
* @param [options] Conversion options
|
||||||
|
* @returns Plain object
|
||||||
|
*/
|
||||||
|
public static toObject(message: SysMsg.ProfileLikeTip, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this ProfileLikeTip to JSON.
|
||||||
|
* @returns JSON object
|
||||||
|
*/
|
||||||
|
public toJSON(): { [k: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default type url for ProfileLikeTip
|
||||||
|
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
||||||
|
* @returns The default type url
|
||||||
|
*/
|
||||||
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
||||||
|
}
|
||||||
|
}
|
1851
src/ntqqapi/proto/compiled.js
Normal file
1851
src/ntqqapi/proto/compiled.js
Normal file
File diff suppressed because it is too large
Load Diff
18
src/ntqqapi/proto/profileLikeTip.proto
Normal file
18
src/ntqqapi/proto/profileLikeTip.proto
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package SysMsg;
|
||||||
|
|
||||||
|
message LikeDetail {
|
||||||
|
string txt = 1;
|
||||||
|
uint32 uin = 3;
|
||||||
|
string nickname = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LikeMsg {
|
||||||
|
uint32 count = 1;
|
||||||
|
uint32 time = 2;
|
||||||
|
LikeDetail detail = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProfileLikeTip {
|
||||||
|
LikeMsg msg = 14;
|
||||||
|
}
|
30
src/ntqqapi/proto/systemMessage.proto
Normal file
30
src/ntqqapi/proto/systemMessage.proto
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package SysMsg;
|
||||||
|
|
||||||
|
message SystemMessage {
|
||||||
|
repeated SystemMessageHeader header = 1;
|
||||||
|
repeated SystemMessageMsgSpec msgSpec = 2;
|
||||||
|
SystemMessageBodyWrapper bodyWrapper = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SystemMessageHeader {
|
||||||
|
uint32 peerNumber = 1;
|
||||||
|
string peerString = 2;
|
||||||
|
uint32 uin = 5;
|
||||||
|
optional string uid = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SystemMessageMsgSpec {
|
||||||
|
uint32 msgType = 1;
|
||||||
|
uint32 subType = 2;
|
||||||
|
uint32 subSubType = 3;
|
||||||
|
uint32 msgSeq = 5;
|
||||||
|
uint32 time = 6;
|
||||||
|
//uint64 msgId = 12;
|
||||||
|
uint32 other = 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SystemMessageBodyWrapper {
|
||||||
|
bytes body = 2;
|
||||||
|
// Find the first [08], or ignore the first 7 bytes?
|
||||||
|
}
|
@@ -45,7 +45,7 @@ export interface NodeIKernelGroupService {
|
|||||||
errMsg: string,
|
errMsg: string,
|
||||||
uids: Map<string, string>
|
uids: Map<string, string>
|
||||||
}>
|
}>
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
//26702(其实更早 但是我不知道)
|
||||||
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>
|
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>
|
||||||
|
|
||||||
@@ -202,11 +202,12 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
publishInstructionForNewcomers(groupCode: string, arg: unknown): void
|
publishInstructionForNewcomers(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
uploadGroupBulletinPic(groupCode: string, pskey: string, imagePath: string): Promise<GeneralCallResult & {
|
uploadGroupBulletinPic(groupCode: string, pskey: string, imagePath: string): Promise<{
|
||||||
errCode: number
|
errCode: number
|
||||||
|
errMsg: string
|
||||||
picInfo?: {
|
picInfo?: {
|
||||||
id: string,
|
id: string
|
||||||
width: number,
|
width: number
|
||||||
height: number
|
height: number
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { BuddyProfileLikeReq } from '../types'
|
import { BuddyProfileLikeReq } from '../types'
|
||||||
import { GeneralCallResult } from './common'
|
import { GeneralCallResult } from './common'
|
||||||
|
import { Dict } from 'cosmokit'
|
||||||
|
|
||||||
export interface NodeIKernelProfileLikeService {
|
export interface NodeIKernelProfileLikeService {
|
||||||
addKernelProfileLikeListener(listener: NodeIKernelProfileLikeService): void
|
addKernelProfileLikeListener(listener: NodeIKernelProfileLikeService): void
|
||||||
@@ -10,8 +11,18 @@ export interface NodeIKernelProfileLikeService {
|
|||||||
|
|
||||||
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
||||||
info: {
|
info: {
|
||||||
userLikeInfos: Array<unknown>,
|
userLikeInfos: {
|
||||||
friendMaxVotes: number,
|
uid: string
|
||||||
|
time: string
|
||||||
|
favoriteInfo: {
|
||||||
|
total_count: number
|
||||||
|
last_time: number
|
||||||
|
today_count: number
|
||||||
|
userInfos: Dict[]
|
||||||
|
}
|
||||||
|
voteInfo: Dict
|
||||||
|
}[]
|
||||||
|
friendMaxVotes: number
|
||||||
start: number
|
start: number
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
@@ -65,3 +65,15 @@ export interface GroupMember {
|
|||||||
joinTime: string
|
joinTime: string
|
||||||
lastSpeakTime: string
|
lastSpeakTime: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PublishGroupBulletinReq {
|
||||||
|
text: string
|
||||||
|
picInfo?: {
|
||||||
|
id: string
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
}
|
||||||
|
oldFeedsId: ''
|
||||||
|
pinned: number
|
||||||
|
confirmRequired: number
|
||||||
|
}
|
@@ -34,7 +34,7 @@ export interface WrapperApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface WrapperConstructor {
|
export interface WrapperConstructor {
|
||||||
[key: string]: any
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperApi: WrapperApi = {}
|
const wrapperApi: WrapperApi = {}
|
||||||
|
@@ -1,14 +1,23 @@
|
|||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
message_id: number
|
message_id: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MarkMsgAsRead extends BaseAction<Payload, null> {
|
export class MarkMsgAsRead extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
||||||
|
|
||||||
protected async _handle() {
|
protected async _handle(payload: Payload) {
|
||||||
|
if (!payload.message_id) {
|
||||||
|
throw new Error('参数 message_id 不能为空')
|
||||||
|
}
|
||||||
|
const msg = await MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)
|
||||||
|
if (!msg) {
|
||||||
|
throw new Error('msg not found')
|
||||||
|
}
|
||||||
|
await this.ctx.ntMsgApi.setMsgRead(msg.Peer)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
|
import { unlink } from 'fs/promises'
|
||||||
|
import { checkFileReceived, uri2local } from '@/common/utils/file'
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
group_id: number | string
|
group_id: number | string
|
||||||
@@ -13,24 +15,39 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice
|
actionName = ActionName.GoCQHTTP_SendGroupNotice
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const type = 1
|
if(!payload.content){
|
||||||
const isShowEditCard = 0
|
throw new Error('参数 content 不能为空')
|
||||||
const tipWindowType = 0
|
}
|
||||||
|
const groupCode = payload.group_id.toString()
|
||||||
const pinned = Number(payload.pinned ?? 0)
|
const pinned = Number(payload.pinned ?? 0)
|
||||||
const confirmRequired = Number(payload.confirm_required ?? 1)
|
const confirmRequired = Number(payload.confirm_required ?? 1)
|
||||||
|
|
||||||
const result = await this.ctx.ntWebApi.setGroupNotice({
|
let picInfo: { id: string, width: number, height: number } | undefined
|
||||||
groupCode: payload.group_id.toString(),
|
if (payload.image) {
|
||||||
content: payload.content,
|
const { path, isLocal, success, errMsg } = await uri2local(payload.image, undefined, true)
|
||||||
|
if (!success) {
|
||||||
|
throw new Error(`设置群公告失败, 错误信息: uri2local: ${errMsg}`)
|
||||||
|
}
|
||||||
|
await checkFileReceived(path, 5000) // 文件不存在QQ会崩溃,需要提前判断
|
||||||
|
const result = await this.ctx.ntGroupApi.uploadGroupBulletinPic(groupCode, path)
|
||||||
|
if (result.errCode !== 0) {
|
||||||
|
throw new Error(`设置群公告失败, 错误信息: uploadGroupBulletinPic: ${result.errMsg}`)
|
||||||
|
}
|
||||||
|
if (!isLocal) {
|
||||||
|
unlink(path)
|
||||||
|
}
|
||||||
|
picInfo = result.picInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await this.ctx.ntGroupApi.publishGroupBulletin(groupCode, {
|
||||||
|
text: encodeURIComponent(payload.content),
|
||||||
|
oldFeedsId: '',
|
||||||
pinned,
|
pinned,
|
||||||
type,
|
|
||||||
isShowEditCard,
|
|
||||||
tipWindowType,
|
|
||||||
confirmRequired,
|
confirmRequired,
|
||||||
picId: ''
|
picInfo
|
||||||
})
|
})
|
||||||
if (result.ec !== 0) {
|
if (res.result !== 0) {
|
||||||
throw new Error(`设置群公告失败, 错误信息: ${result.em}`)
|
throw new Error(`设置群公告失败, 错误信息: ${res.errMsg}`)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import fs from 'node:fs'
|
|
||||||
import BaseAction from '../BaseAction'
|
import BaseAction from '../BaseAction'
|
||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { SendElementEntities } from '@/ntqqapi/entities'
|
import { SendElementEntities } from '@/ntqqapi/entities'
|
||||||
import { SendFileElement } from '@/ntqqapi/types'
|
|
||||||
import { uri2local } from '@/common/utils'
|
import { uri2local } from '@/common/utils'
|
||||||
import { sendMsg, createPeer, CreatePeerMode } from '../../helper/createMessage'
|
import { sendMsg, createPeer, CreatePeerMode } from '../../helper/createMessage'
|
||||||
|
|
||||||
@@ -18,17 +16,13 @@ export class UploadGroupFile extends BaseAction<UploadGroupFilePayload, null> {
|
|||||||
actionName = ActionName.GoCQHTTP_UploadGroupFile
|
actionName = ActionName.GoCQHTTP_UploadGroupFile
|
||||||
|
|
||||||
protected async _handle(payload: UploadGroupFilePayload): Promise<null> {
|
protected async _handle(payload: UploadGroupFilePayload): Promise<null> {
|
||||||
let file = payload.file
|
const { success, errMsg, path, fileName } = await uri2local(payload.file)
|
||||||
if (fs.existsSync(file)) {
|
if (!success) {
|
||||||
file = `file://${file}`
|
throw new Error(errMsg)
|
||||||
}
|
}
|
||||||
const downloadResult = await uri2local(file)
|
const sendFileEle = await SendElementEntities.file(this.ctx, path, payload.name || fileName, payload.folder_id)
|
||||||
if (!downloadResult.success) {
|
|
||||||
throw new Error(downloadResult.errMsg)
|
|
||||||
}
|
|
||||||
const sendFileEle = await SendElementEntities.file(this.ctx, downloadResult.path, payload.name, payload.folder_id)
|
|
||||||
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Group)
|
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Group)
|
||||||
await sendMsg(this.ctx, peer, [sendFileEle], [], true)
|
await sendMsg(this.ctx, peer, [sendFileEle], [])
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,17 +37,13 @@ export class UploadPrivateFile extends BaseAction<UploadPrivateFilePayload, null
|
|||||||
actionName = ActionName.GoCQHTTP_UploadPrivateFile
|
actionName = ActionName.GoCQHTTP_UploadPrivateFile
|
||||||
|
|
||||||
protected async _handle(payload: UploadPrivateFilePayload): Promise<null> {
|
protected async _handle(payload: UploadPrivateFilePayload): Promise<null> {
|
||||||
|
const { success, errMsg, path, fileName } = await uri2local(payload.file)
|
||||||
|
if (!success) {
|
||||||
|
throw new Error(errMsg)
|
||||||
|
}
|
||||||
|
const sendFileEle = await SendElementEntities.file(this.ctx, path, payload.name || fileName)
|
||||||
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Private)
|
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Private)
|
||||||
let file = payload.file
|
await sendMsg(this.ctx, peer, [sendFileEle], [])
|
||||||
if (fs.existsSync(file)) {
|
|
||||||
file = `file://${file}`
|
|
||||||
}
|
|
||||||
const downloadResult = await uri2local(file)
|
|
||||||
if (!downloadResult.success) {
|
|
||||||
throw new Error(downloadResult.errMsg)
|
|
||||||
}
|
|
||||||
const sendFileEle: SendFileElement = await SendElementEntities.file(this.ctx, downloadResult.path, payload.name)
|
|
||||||
await sendMsg(this.ctx, peer, [sendFileEle], [], true)
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,8 @@ interface Payload {
|
|||||||
class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
||||||
actionName = ActionName.GetGroupList
|
actionName = ActionName.GetGroupList
|
||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle() {
|
||||||
const groupList = await this.ctx.ntGroupApi.getGroups(payload?.no_cache === true || payload?.no_cache === 'true')
|
const groupList = await this.ctx.ntGroupApi.getGroups()
|
||||||
return OB11Entities.groups(groupList)
|
return OB11Entities.groups(groupList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
if (member) {
|
if (member) {
|
||||||
if (isNullable(member.sex)) {
|
if (isNullable(member.sex)) {
|
||||||
//log('获取群成员详细信息')
|
//log('获取群成员详细信息')
|
||||||
const info = await this.ctx.ntUserApi.getUserDetailInfo(member.uid, true)
|
const info = await this.ctx.ntUserApi.getUserDetailInfo(member.uid)
|
||||||
//log('群成员详细信息结果', info)
|
//log('群成员详细信息结果', info)
|
||||||
Object.assign(member, info)
|
Object.assign(member, info)
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,7 @@ import { GetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain'
|
|||||||
import { GetGroupRootFiles } from './go-cqhttp/GetGroupRootFiles'
|
import { GetGroupRootFiles } from './go-cqhttp/GetGroupRootFiles'
|
||||||
import { SetOnlineStatus } from './llonebot/SetOnlineStatus'
|
import { SetOnlineStatus } from './llonebot/SetOnlineStatus'
|
||||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice'
|
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice'
|
||||||
|
import { GetProfileLike } from './llonebot/GetProfileLike'
|
||||||
|
|
||||||
export function initActionMap(adapter: Adapter) {
|
export function initActionMap(adapter: Adapter) {
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
@@ -74,6 +75,7 @@ export function initActionMap(adapter: Adapter) {
|
|||||||
new GetFriendWithCategory(adapter),
|
new GetFriendWithCategory(adapter),
|
||||||
new GetEvent(adapter),
|
new GetEvent(adapter),
|
||||||
new SetOnlineStatus(adapter),
|
new SetOnlineStatus(adapter),
|
||||||
|
new GetProfileLike(adapter),
|
||||||
// onebot11
|
// onebot11
|
||||||
new SendLike(adapter),
|
new SendLike(adapter),
|
||||||
new GetMsg(adapter),
|
new GetMsg(adapter),
|
||||||
|
17
src/onebot11/action/llonebot/GetProfileLike.ts
Normal file
17
src/onebot11/action/llonebot/GetProfileLike.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import BaseAction from '../BaseAction'
|
||||||
|
import { ActionName } from '../types'
|
||||||
|
import { selfInfo } from '@/common/globalVars'
|
||||||
|
import { Dict } from 'cosmokit'
|
||||||
|
|
||||||
|
export class GetProfileLike extends BaseAction<void, Dict[]> {
|
||||||
|
actionName = ActionName.GetProfileLike
|
||||||
|
|
||||||
|
async _handle() {
|
||||||
|
const ret = await this.ctx.ntUserApi.getProfileLike(selfInfo.uid)
|
||||||
|
const listdata = ret.info.userLikeInfos[0].favoriteInfo.userInfos
|
||||||
|
for (const item of listdata) {
|
||||||
|
item.uin = Number(await this.ctx.ntUserApi.getUinByUid(item.uid)) || 0
|
||||||
|
}
|
||||||
|
return listdata
|
||||||
|
}
|
||||||
|
}
|
@@ -214,7 +214,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnData> {
|
|||||||
}
|
}
|
||||||
// log("分割后的转发节点", sendElementsSplit)
|
// log("分割后的转发节点", sendElementsSplit)
|
||||||
for (const eles of sendElementsSplit) {
|
for (const eles of sendElementsSplit) {
|
||||||
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [], true)
|
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [])
|
||||||
if (!nodeMsg) {
|
if (!nodeMsg) {
|
||||||
this.ctx.logger.warn('转发节点生成失败', eles)
|
this.ctx.logger.warn('转发节点生成失败', eles)
|
||||||
continue
|
continue
|
||||||
|
@@ -5,7 +5,7 @@ interface ReturnType {
|
|||||||
yes: boolean
|
yes: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class CanSendRecord extends BaseAction<any, ReturnType> {
|
export default class CanSendRecord extends BaseAction<null, ReturnType> {
|
||||||
actionName = ActionName.CanSendRecord
|
actionName = ActionName.CanSendRecord
|
||||||
|
|
||||||
protected async _handle() {
|
protected async _handle() {
|
||||||
|
@@ -20,6 +20,7 @@ export enum ActionName {
|
|||||||
GetFriendsWithCategory = 'get_friends_with_category',
|
GetFriendsWithCategory = 'get_friends_with_category',
|
||||||
GetEvent = 'get_event',
|
GetEvent = 'get_event',
|
||||||
SetOnlineStatus = 'set_online_status',
|
SetOnlineStatus = 'set_online_status',
|
||||||
|
GetProfileLike = 'get_profile_like',
|
||||||
// onebot 11
|
// onebot 11
|
||||||
SendLike = 'send_like',
|
SendLike = 'send_like',
|
||||||
GetLoginInfo = 'get_login_info',
|
GetLoginInfo = 'get_login_info',
|
||||||
@@ -65,9 +66,9 @@ export enum ActionName {
|
|||||||
GoCQHTTP_DownloadFile = 'download_file',
|
GoCQHTTP_DownloadFile = 'download_file',
|
||||||
GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',
|
GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',
|
||||||
GoCQHTTP_GetForwardMsg = 'get_forward_msg',
|
GoCQHTTP_GetForwardMsg = 'get_forward_msg',
|
||||||
GoCQHTTP_GetEssenceMsg = "get_essence_msg_list",
|
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
|
||||||
GoCQHTTP_HandleQuickOperation = ".handle_quick_operation",
|
GoCQHTTP_HandleQuickOperation = '.handle_quick_operation',
|
||||||
GetGroupHonorInfo = "get_group_honor_info",
|
GetGroupHonorInfo = 'get_group_honor_info',
|
||||||
GoCQHTTP_SetEssenceMsg = 'set_essence_msg',
|
GoCQHTTP_SetEssenceMsg = 'set_essence_msg',
|
||||||
GoCQHTTP_DelEssenceMsg = 'delete_essence_msg',
|
GoCQHTTP_DelEssenceMsg = 'delete_essence_msg',
|
||||||
GoCQHTTP_DelGroupFile = 'delete_group_file',
|
GoCQHTTP_DelGroupFile = 'delete_group_file',
|
||||||
|
@@ -16,7 +16,7 @@ export class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2(refresh))
|
return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2(refresh))
|
||||||
}
|
}
|
||||||
return OB11Entities.friends(await this.ctx.ntFriendApi.getFriends(refresh))
|
return OB11Entities.friends(await this.ctx.ntFriendApi.getFriends())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,8 @@ import { initActionMap } from './action'
|
|||||||
import { llonebotError } from '../common/globalVars'
|
import { llonebotError } from '../common/globalVars'
|
||||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'
|
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 { SysMsg } from '@/ntqqapi/proto/compiled'
|
||||||
|
|
||||||
declare module 'cordis' {
|
declare module 'cordis' {
|
||||||
interface Context {
|
interface Context {
|
||||||
@@ -399,7 +401,7 @@ class OneBot11Adapter extends Service {
|
|||||||
this.handleRecallMsg(input)
|
this.handleRecallMsg(input)
|
||||||
})
|
})
|
||||||
this.ctx.on('nt/message-sent', input => {
|
this.ctx.on('nt/message-sent', input => {
|
||||||
this.handleRecallMsg(input)
|
this.handleMsg(input)
|
||||||
})
|
})
|
||||||
this.ctx.on('nt/group-notify', input => {
|
this.ctx.on('nt/group-notify', input => {
|
||||||
this.handleGroupNotify(input)
|
this.handleGroupNotify(input)
|
||||||
@@ -410,6 +412,18 @@ class OneBot11Adapter extends Service {
|
|||||||
this.ctx.on('nt/group-member-info-updated', input => {
|
this.ctx.on('nt/group-member-info-updated', input => {
|
||||||
this.handleGroupMemberInfoUpdated(input.groupCode, input.members)
|
this.handleGroupMemberInfoUpdated(input.groupCode, input.members)
|
||||||
})
|
})
|
||||||
|
this.ctx.on('nt/system-message-created', input => {
|
||||||
|
const sysMsg = SysMsg.SystemMessage.decode(input)
|
||||||
|
const { msgType, subType, subSubType } = sysMsg.msgSpec[0] ?? {}
|
||||||
|
if (msgType === 528 && subType === 39 && subSubType === 39) {
|
||||||
|
const tip = SysMsg.ProfileLikeTip.decode(sysMsg.bodyWrapper!.body!.slice(12))
|
||||||
|
const detail = tip.msg?.detail
|
||||||
|
if (!detail) return
|
||||||
|
const [times] = detail.txt?.match(/\d+/) ?? ['0']
|
||||||
|
const profileLikeEvent = new OB11ProfileLikeEvent(detail.uin!, detail.nickname!, +times)
|
||||||
|
this.dispatch(profileLikeEvent)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -173,8 +173,8 @@ export namespace OB11Entities {
|
|||||||
id: MessageUnique.createMsg(peer, replyMsg ? replyMsg.msgId : records.msgId).toString()
|
id: MessageUnique.createMsg(peer, replyMsg ? replyMsg.msgId : records.msgId).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
ctx.logger.error('获取不到引用的消息', replyElement, e.stack)
|
ctx.logger.error('获取不到引用的消息', replyElement, (e as Error).stack)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,7 +378,7 @@ export namespace OB11Entities {
|
|||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||||
//判断业务类型
|
//判断业务类型
|
||||||
//Poke事件
|
//Poke事件
|
||||||
const pokedetail: any[] = json.items
|
const pokedetail: Dict[] = json.items
|
||||||
//筛选item带有uid的元素
|
//筛选item带有uid的元素
|
||||||
const poke_uid = pokedetail.filter(item => item.uid)
|
const poke_uid = pokedetail.filter(item => item.uid)
|
||||||
if (poke_uid.length == 2) {
|
if (poke_uid.length == 2) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { selfInfo } from "@/common/globalVars"
|
import { selfInfo } from '@/common/globalVars'
|
||||||
|
|
||||||
export enum EventType {
|
export enum EventType {
|
||||||
META = 'meta_event',
|
META = 'meta_event',
|
||||||
|
@@ -4,7 +4,7 @@ export type GroupDecreaseSubType = 'leave' | 'kick' | 'kick_me'
|
|||||||
|
|
||||||
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupDecreaseEvent extends OB11GroupNoticeEvent {
|
||||||
notice_type = 'group_decrease'
|
notice_type = 'group_decrease'
|
||||||
sub_type: GroupDecreaseSubType = 'leave' // TODO: 实现其他几种子类型的识别 ("leave" | "kick" | "kick_me")
|
sub_type: GroupDecreaseSubType = 'leave'
|
||||||
operator_id: number
|
operator_id: number
|
||||||
group_id: number
|
group_id: number
|
||||||
user_id: number
|
user_id: number
|
||||||
|
16
src/onebot11/event/notice/OB11ProfileLikeEvent.ts
Normal file
16
src/onebot11/event/notice/OB11ProfileLikeEvent.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent'
|
||||||
|
|
||||||
|
export class OB11ProfileLikeEvent extends OB11BaseNoticeEvent {
|
||||||
|
notice_type = 'notify'
|
||||||
|
sub_type = 'profile_like'
|
||||||
|
operator_id: number
|
||||||
|
operator_nick: string
|
||||||
|
times: number
|
||||||
|
|
||||||
|
constructor(operatorId: number, operatorNick: string, times: number) {
|
||||||
|
super()
|
||||||
|
this.operator_id = operatorId
|
||||||
|
this.operator_nick = operatorNick
|
||||||
|
this.times = times
|
||||||
|
}
|
||||||
|
}
|
@@ -236,8 +236,7 @@ export async function sendMsg(
|
|||||||
ctx: Context,
|
ctx: Context,
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
sendElements: SendMessageElement[],
|
sendElements: SendMessageElement[],
|
||||||
deleteAfterSentFiles: string[],
|
deleteAfterSentFiles: string[]
|
||||||
waitComplete = true,
|
|
||||||
) {
|
) {
|
||||||
if (!sendElements.length) {
|
if (!sendElements.length) {
|
||||||
throw '消息体无法解析,请检查是否发送了不支持的消息类型'
|
throw '消息体无法解析,请检查是否发送了不支持的消息类型'
|
||||||
|
@@ -88,7 +88,7 @@ async function handleMsg(ctx: Context, msg: OB11Message, quickAction: QuickOpera
|
|||||||
}
|
}
|
||||||
replyMessage = replyMessage.concat(convertMessage2List(reply, quickAction.auto_escape))
|
replyMessage = replyMessage.concat(convertMessage2List(reply, quickAction.auto_escape))
|
||||||
const { sendElements, deleteAfterSentFiles } = await createSendElements(ctx, replyMessage, peer)
|
const { sendElements, deleteAfterSentFiles } = await createSendElements(ctx, replyMessage, peer)
|
||||||
sendMsg(ctx, peer, sendElements, deleteAfterSentFiles, false).catch(e => ctx.logger.error(e))
|
sendMsg(ctx, peer, sendElements, deleteAfterSentFiles).catch(e => ctx.logger.error(e))
|
||||||
}
|
}
|
||||||
if (msg.message_type === 'group') {
|
if (msg.message_type === 'group') {
|
||||||
const groupMsgQuickAction = quickAction as QuickOperationGroupMessage
|
const groupMsgQuickAction = quickAction as QuickOperationGroupMessage
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { CheckVersion, Config } from '../common/types'
|
import { CheckVersion, Config } from '../common/types'
|
||||||
import { SettingButton, SettingItem, SettingList, SettingSwitch, SettingSelect } from './components'
|
import { SettingButton, SettingItem, SettingList, SettingSwitch, SettingSelect } from './components'
|
||||||
import { version } from '../version'
|
import { version } from '../version'
|
||||||
// @ts-expect-error
|
// @ts-expect-error: Unreachable code error
|
||||||
import StyleRaw from './style.css?raw'
|
import StyleRaw from './style.css?raw'
|
||||||
|
|
||||||
type HostsType = 'httpHosts' | 'wsHosts'
|
type HostsType = 'httpHosts' | 'wsHosts'
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = '3.31.9'
|
export const version = '3.32.3'
|
||||||
|
@@ -24,11 +24,7 @@
|
|||||||
"noEmit": true
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/*",
|
"src",
|
||||||
"src/**/*",
|
"scripts"
|
||||||
"scripts/*"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
Reference in New Issue
Block a user