mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
chore: improve code quality
This commit is contained in:
parent
f93e2b5a95
commit
3064a6eb7c
@ -16,8 +16,8 @@ type Input = string | Readable
|
|||||||
|
|
||||||
function convert(ctx: Context, input: Input, options: FFmpegOptions): Promise<Buffer>
|
function convert(ctx: Context, input: Input, options: FFmpegOptions): Promise<Buffer>
|
||||||
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath: string): Promise<string>
|
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath: string): Promise<string>
|
||||||
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?: string): Promise<Buffer> | Promise<string> {
|
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?: string): Promise<Buffer | string> {
|
||||||
return new Promise<any>((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const chunks: Buffer[] = []
|
const chunks: Buffer[] = []
|
||||||
let command = ffmpeg(input)
|
let command = ffmpeg(input)
|
||||||
.on('error', err => {
|
.on('error', err => {
|
||||||
@ -84,8 +84,8 @@ export async function encodeSilk(ctx: Context, filePath: string) {
|
|||||||
let duration = 1
|
let duration = 1
|
||||||
try {
|
try {
|
||||||
duration = getDuration(silk) / 1000
|
duration = getDuration(silk) / 1000
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
ctx.logger.warn('获取语音文件时长失败, 默认为1秒', filePath, e.stack)
|
ctx.logger.warn('获取语音文件时长失败, 默认为1秒', filePath, (e as Error).stack)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
converted: false,
|
converted: false,
|
||||||
@ -93,8 +93,8 @@ export async function encodeSilk(ctx: Context, filePath: string) {
|
|||||||
duration,
|
duration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (err) {
|
||||||
ctx.logger.error('convert silk failed', error.stack)
|
ctx.logger.error('convert silk failed', (err as Error).stack)
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import { randomUUID } from 'node:crypto'
|
|||||||
interface Internal_MapKey {
|
interface Internal_MapKey {
|
||||||
timeout: number
|
timeout: number
|
||||||
createtime: number
|
createtime: number
|
||||||
func: (...arg: any[]) => any
|
func: (...arg: any[]) => unknown
|
||||||
checker: ((...args: any[]) => boolean) | undefined
|
checker?: (...args: any[]) => boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ListenerClassBase {
|
export class ListenerClassBase {
|
||||||
@ -13,7 +13,7 @@ export class ListenerClassBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ListenerIBase {
|
export interface ListenerIBase {
|
||||||
new(listener: any): ListenerClassBase
|
new(listener: unknown): ListenerClassBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/EventTask.ts#L20
|
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/common/utils/EventTask.ts#L20
|
||||||
@ -30,11 +30,11 @@ export class NTEventWrapper {
|
|||||||
createProxyDispatch(ListenerMainName: string) {
|
createProxyDispatch(ListenerMainName: string) {
|
||||||
const current = this
|
const current = this
|
||||||
return new Proxy({}, {
|
return new Proxy({}, {
|
||||||
get(target: any, prop: any, receiver: any) {
|
get(target: any, prop: string, receiver: unknown) {
|
||||||
// console.log('get', prop, typeof target[prop])
|
// console.log('get', prop, typeof target[prop])
|
||||||
if (typeof target[prop] === 'undefined') {
|
if (typeof target[prop] === 'undefined') {
|
||||||
// 如果方法不存在,返回一个函数,这个函数调用existentMethod
|
// 如果方法不存在,返回一个函数,这个函数调用existentMethod
|
||||||
return (...args: any[]) => {
|
return (...args: unknown[]) => {
|
||||||
current.dispatcherListener.apply(current, [ListenerMainName, prop, ...args]).then()
|
current.dispatcherListener.apply(current, [ListenerMainName, prop, ...args]).then()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ export class NTEventWrapper {
|
|||||||
this.initialised = true
|
this.initialised = true
|
||||||
}
|
}
|
||||||
|
|
||||||
createEventFunction<T extends (...args: any) => any>(eventName: string): T | undefined {
|
createEventFunction<T extends (...args: any) => unknown>(eventName: string): T | undefined {
|
||||||
const eventNameArr = eventName.split('/')
|
const eventNameArr = eventName.split('/')
|
||||||
type eventType = {
|
type eventType = {
|
||||||
[key: string]: () => { [key: string]: (...params: Parameters<T>) => Promise<ReturnType<T>> }
|
[key: string]: () => { [key: string]: (...params: Parameters<T>) => Promise<ReturnType<T>> }
|
||||||
@ -87,7 +87,7 @@ export class NTEventWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//统一回调清理事件
|
//统一回调清理事件
|
||||||
async dispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: any[]) {
|
async dispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: unknown[]) {
|
||||||
//console.log("[EventDispatcher]",ListenerMainName, ListenerSubName, ...args)
|
//console.log("[EventDispatcher]",ListenerMainName, ListenerSubName, ...args)
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
||||||
//console.log(task.func, uuid, task.createtime, task.timeout)
|
//console.log(task.func, uuid, task.createtime, task.timeout)
|
||||||
@ -101,7 +101,7 @@ export class NTEventWrapper {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async CallNoListenerEvent<EventType extends (...args: any[]) => Promise<any> | any>(EventName = '', timeout: number = 3000, ...args: Parameters<EventType>) {
|
async CallNoListenerEvent<EventType extends (...args: any[]) => Promise<any>>(EventName = '', timeout: number = 3000, ...args: Parameters<EventType>) {
|
||||||
return new Promise<Awaited<ReturnType<EventType>>>(async (resolve, reject) => {
|
return new Promise<Awaited<ReturnType<EventType>>>(async (resolve, reject) => {
|
||||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
const EventFunc = this.createEventFunction<EventType>(EventName)
|
||||||
let complete = false
|
let complete = false
|
||||||
@ -162,7 +162,7 @@ export class NTEventWrapper {
|
|||||||
const id = randomUUID()
|
const id = randomUUID()
|
||||||
let complete = 0
|
let complete = 0
|
||||||
let retData: Parameters<ListenerType> | undefined = undefined
|
let retData: Parameters<ListenerType> | undefined = undefined
|
||||||
let retEvent: any = {}
|
let retEvent = {}
|
||||||
const databack = () => {
|
const databack = () => {
|
||||||
if (complete == 0) {
|
if (complete == 0) {
|
||||||
reject(new Error('Timeout: NTEvent EventName:' + EventName + ' ListenerName:' + ListenerName + ' EventRet:\n' + JSON.stringify(retEvent, null, 4) + '\n'))
|
reject(new Error('Timeout: NTEvent EventName:' + EventName + ' ListenerName:' + ListenerName + ' EventRet:\n' + JSON.stringify(retEvent, null, 4) + '\n'))
|
||||||
@ -181,7 +181,7 @@ export class NTEventWrapper {
|
|||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
createtime: Date.now(),
|
createtime: Date.now(),
|
||||||
checker: checker,
|
checker: checker,
|
||||||
func: (...args: any[]) => {
|
func: (...args: unknown[]) => {
|
||||||
complete++
|
complete++
|
||||||
//console.log('func', ...args)
|
//console.log('func', ...args)
|
||||||
retData = args as Parameters<ListenerType>
|
retData = args as Parameters<ListenerType>
|
||||||
@ -200,7 +200,7 @@ export class NTEventWrapper {
|
|||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak)
|
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak)
|
||||||
this.createListenerFunction(ListenerMainName)
|
this.createListenerFunction(ListenerMainName)
|
||||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
const EventFunc = this.createEventFunction<EventType>(EventName)
|
||||||
retEvent = await EventFunc!(...(args as any[]))
|
retEvent = await EventFunc!(...args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,106 +1,104 @@
|
|||||||
import https from 'node:https'
|
import https from 'node:https'
|
||||||
import http from 'node:http'
|
import http from 'node:http'
|
||||||
|
import { Dict } from 'cosmokit'
|
||||||
|
|
||||||
export class RequestUtil {
|
export class RequestUtil {
|
||||||
// 适用于获取服务器下发cookies时获取,仅GET
|
// 适用于获取服务器下发cookies时获取,仅GET
|
||||||
static async HttpsGetCookies(url: string): Promise<{ [key: string]: string }> {
|
static async HttpsGetCookies(url: string): Promise<{ [key: string]: string }> {
|
||||||
const client = url.startsWith('https') ? https : http;
|
const client = url.startsWith('https') ? https : http
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
client.get(url, (res) => {
|
client.get(url, (res) => {
|
||||||
let cookies: { [key: string]: string } = {};
|
let cookies: { [key: string]: string } = {}
|
||||||
const handleRedirect = (res: http.IncomingMessage) => {
|
const handleRedirect = (res: http.IncomingMessage) => {
|
||||||
//console.log(res.headers.location);
|
|
||||||
if (res.statusCode === 301 || res.statusCode === 302) {
|
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||||
if (res.headers.location) {
|
if (res.headers.location) {
|
||||||
const redirectUrl = new URL(res.headers.location, url);
|
const redirectUrl = new URL(res.headers.location, url)
|
||||||
RequestUtil.HttpsGetCookies(redirectUrl.href).then((redirectCookies) => {
|
RequestUtil.HttpsGetCookies(redirectUrl.href).then((redirectCookies) => {
|
||||||
// 合并重定向过程中的cookies
|
// 合并重定向过程中的cookies
|
||||||
//log('redirectCookies', redirectCookies)
|
//log('redirectCookies', redirectCookies)
|
||||||
cookies = { ...cookies, ...redirectCookies };
|
cookies = { ...cookies, ...redirectCookies }
|
||||||
resolve(cookies);
|
resolve(cookies)
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
resolve(cookies);
|
resolve(cookies)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolve(cookies);
|
resolve(cookies)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
res.on('data', () => { }); // Necessary to consume the stream
|
res.on('data', () => { }) // Necessary to consume the stream
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
handleRedirect(res);
|
handleRedirect(res)
|
||||||
});
|
})
|
||||||
if (res.headers['set-cookie']) {
|
if (res.headers['set-cookie']) {
|
||||||
// console.log(res.headers['set-cookie']);
|
//log('set-cookie', url, res.headers['set-cookie'])
|
||||||
//log('set-cookie', url, res.headers['set-cookie']);
|
|
||||||
res.headers['set-cookie'].forEach((cookie) => {
|
res.headers['set-cookie'].forEach((cookie) => {
|
||||||
const parts = cookie.split(';')[0].split('=');
|
const parts = cookie.split(';')[0].split('=')
|
||||||
const key = parts[0];
|
const key = parts[0]
|
||||||
const value = parts[1];
|
const value = parts[1]
|
||||||
if (key && value && key.length > 0 && value.length > 0) {
|
if (key && value && key.length > 0 && value.length > 0) {
|
||||||
cookies[key] = value;
|
cookies[key] = value
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}).on('error', (err) => {
|
}).on('error', (err) => {
|
||||||
reject(err);
|
reject(err)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求和回复都是JSON data传原始内容 自动编码json
|
// 请求和回复都是JSON data传原始内容 自动编码json
|
||||||
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}, isJsonRet: boolean = true, isArgJson: boolean = true): Promise<T> {
|
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: unknown, headers: Record<string, string> = {}, isJsonRet: boolean = true, isArgJson: boolean = true): Promise<T> {
|
||||||
let option = new URL(url);
|
const option = new URL(url)
|
||||||
const protocol = url.startsWith('https://') ? https : http;
|
const protocol = url.startsWith('https://') ? https : http
|
||||||
const options = {
|
const options = {
|
||||||
hostname: option.hostname,
|
hostname: option.hostname,
|
||||||
port: option.port,
|
port: option.port,
|
||||||
path: option.href,
|
path: option.href,
|
||||||
method: method,
|
method: method,
|
||||||
headers: headers
|
headers: headers
|
||||||
};
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const req = protocol.request(options, (res: any) => {
|
const req = protocol.request(options, (res: Dict) => {
|
||||||
let responseBody = '';
|
let responseBody = ''
|
||||||
res.on('data', (chunk: string | Buffer) => {
|
res.on('data', (chunk: string | Buffer) => {
|
||||||
responseBody += chunk.toString();
|
responseBody += chunk.toString()
|
||||||
});
|
})
|
||||||
|
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
try {
|
try {
|
||||||
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
if (isJsonRet) {
|
if (isJsonRet) {
|
||||||
const responseJson = JSON.parse(responseBody);
|
const responseJson = JSON.parse(responseBody)
|
||||||
resolve(responseJson as T);
|
resolve(responseJson as T)
|
||||||
} else {
|
} else {
|
||||||
resolve(responseBody as T);
|
resolve(responseBody as T)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Unexpected status code: ${res.statusCode}`));
|
reject(new Error(`Unexpected status code: ${res.statusCode}`))
|
||||||
}
|
}
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
reject(parseError);
|
reject(parseError)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
req.on('error', (error: any) => {
|
req.on('error', (error) => {
|
||||||
reject(error);
|
reject(error)
|
||||||
});
|
})
|
||||||
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
||||||
if (isArgJson) {
|
if (isArgJson) {
|
||||||
req.write(JSON.stringify(data));
|
req.write(JSON.stringify(data))
|
||||||
} else {
|
} else {
|
||||||
req.write(data);
|
req.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
req.end();
|
req.end()
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 请求返回都是原始内容
|
// 请求返回都是原始内容
|
||||||
static async HttpGetText(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}) {
|
static async HttpGetText(url: string, method: string = 'GET', data?: unknown, headers: Record<string, string> = {}) {
|
||||||
return this.HttpGetJson<string>(url, method, data, headers, false, false);
|
return this.HttpGetJson<string>(url, method, data, headers, false, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,8 +4,7 @@ import { invoke, NTClass, NTMethod } from '../ntcall'
|
|||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { NTQQWindows } from './window'
|
import { NTQQWindows } from './window'
|
||||||
import { getSession } from '../wrapper'
|
import { getSession } from '../wrapper'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
import { OnGroupFileInfoUpdateParams } from '../listeners'
|
||||||
import { NodeIKernelGroupListener, OnGroupFileInfoUpdateParams } from '../listeners'
|
|
||||||
import { NodeIKernelGroupService } from '../services'
|
import { NodeIKernelGroupService } from '../services'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { isNumeric } from '@/common/utils/misc'
|
import { isNumeric } from '@/common/utils/misc'
|
||||||
|
@ -2,7 +2,6 @@ import { invoke, NTMethod } from '../ntcall'
|
|||||||
import { GeneralCallResult } from '../services'
|
import { GeneralCallResult } from '../services'
|
||||||
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { selfInfo } from '@/common/globalVars'
|
import { selfInfo } from '@/common/globalVars'
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { invoke, NTMethod } from '../ntcall'
|
import { invoke } from '../ntcall'
|
||||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
import { UserDetailSource, ProfileBizType } from '../services'
|
||||||
import { NodeIKernelProfileListener } from '../listeners'
|
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
import { Service, Context } from 'cordis'
|
import { Service, Context } from 'cordis'
|
||||||
import { selfInfo } from '@/common/globalVars'
|
import { selfInfo } from '@/common/globalVars'
|
||||||
|
@ -52,6 +52,7 @@ interface IGroupListener {
|
|||||||
onJoinGroupNoVerifyFlag(...args: unknown[]): void
|
onJoinGroupNoVerifyFlag(...args: unknown[]): void
|
||||||
|
|
||||||
onGroupArkInviteStateResult(...args: unknown[]): void
|
onGroupArkInviteStateResult(...args: unknown[]): void
|
||||||
|
|
||||||
// 发现于Win 9.9.9 23159
|
// 发现于Win 9.9.9 23159
|
||||||
onGroupMemberLevelInfoChange(...args: unknown[]): void
|
onGroupMemberLevelInfoChange(...args: unknown[]): void
|
||||||
}
|
}
|
||||||
@ -60,181 +61,3 @@ export interface NodeIKernelGroupListener extends IGroupListener {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||||
new(listener: IGroupListener): NodeIKernelGroupListener
|
new(listener: IGroupListener): NodeIKernelGroupListener
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GroupListener implements IGroupListener {
|
|
||||||
// 发现于Win 9.9.9 23159
|
|
||||||
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
onGetGroupBulletinListResult(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupAllInfoChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRemindNotify(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupArkInviteStateResult(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRichMediaDownloadComplete(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupConfMemberChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupDetailInfoChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupExtListUpdate(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupFirstBulletinNotify(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupNotifiesUpdated(dboubt: boolean, notifies: GroupNotify[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRichMediaProgressUpdate(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupNotifiesUnreadCountUpdated(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupSingleScreenNotifies(doubt: boolean, seq: string, notifies: GroupNotify[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupsMsgMaskResult(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupStatisticInfoChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onJoinGroupNotify(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onJoinGroupNoVerifyFlag(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onMemberInfoChange(groupCode: string, changeType: number, members: Map<string, GroupMember>) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onMemberListChange(arg: {
|
|
||||||
sceneId: string,
|
|
||||||
ids: string[],
|
|
||||||
infos: Map<string, GroupMember>, // uid -> GroupMember
|
|
||||||
finish: boolean,
|
|
||||||
hasRobot: boolean
|
|
||||||
}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onSearchMemberChange(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
|
|
||||||
onShutUpMemberListChanged(...args: unknown[]) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class DebugGroupListener implements IGroupListener {
|
|
||||||
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
|
||||||
console.log('onGroupMemberLevelInfoChange:', ...args)
|
|
||||||
}
|
|
||||||
onGetGroupBulletinListResult(...args: unknown[]) {
|
|
||||||
console.log('onGetGroupBulletinListResult:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupAllInfoChange(...args: unknown[]) {
|
|
||||||
console.log('onGroupAllInfoChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinChange(...args: unknown[]) {
|
|
||||||
console.log('onGroupBulletinChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRemindNotify(...args: unknown[]) {
|
|
||||||
console.log('onGroupBulletinRemindNotify:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupArkInviteStateResult(...args: unknown[]) {
|
|
||||||
console.log('onGroupArkInviteStateResult:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRichMediaDownloadComplete(...args: unknown[]) {
|
|
||||||
console.log('onGroupBulletinRichMediaDownloadComplete:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupConfMemberChange(...args: unknown[]) {
|
|
||||||
console.log('onGroupConfMemberChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupDetailInfoChange(...args: unknown[]) {
|
|
||||||
console.log('onGroupDetailInfoChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupExtListUpdate(...args: unknown[]) {
|
|
||||||
console.log('onGroupExtListUpdate:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupFirstBulletinNotify(...args: unknown[]) {
|
|
||||||
console.log('onGroupFirstBulletinNotify:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupListUpdate(...args: unknown[]) {
|
|
||||||
console.log('onGroupListUpdate:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupNotifiesUpdated(...args: unknown[]) {
|
|
||||||
console.log('onGroupNotifiesUpdated:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupBulletinRichMediaProgressUpdate(...args: unknown[]) {
|
|
||||||
console.log('onGroupBulletinRichMediaProgressUpdate:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupNotifiesUnreadCountUpdated(...args: unknown[]) {
|
|
||||||
console.log('onGroupNotifiesUnreadCountUpdated:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupSingleScreenNotifies(doubt: boolean, seq: string, notifies: GroupNotify[]) {
|
|
||||||
console.log('onGroupSingleScreenNotifies:')
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupsMsgMaskResult(...args: unknown[]) {
|
|
||||||
console.log('onGroupsMsgMaskResult:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onGroupStatisticInfoChange(...args: unknown[]) {
|
|
||||||
console.log('onGroupStatisticInfoChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onJoinGroupNotify(...args: unknown[]) {
|
|
||||||
console.log('onJoinGroupNotify:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onJoinGroupNoVerifyFlag(...args: unknown[]) {
|
|
||||||
console.log('onJoinGroupNoVerifyFlag:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMemberInfoChange(groupCode: string, changeType: number, members: Map<string, GroupMember>) {
|
|
||||||
console.log('onMemberInfoChange:', groupCode, changeType, members)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMemberListChange(...args: unknown[]) {
|
|
||||||
console.log('onMemberListChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onSearchMemberChange(...args: unknown[]) {
|
|
||||||
console.log('onSearchMemberChange:', ...args)
|
|
||||||
}
|
|
||||||
|
|
||||||
onShutUpMemberListChanged(...args: unknown[]) {
|
|
||||||
console.log('onShutUpMemberListChanged:', ...args)
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,8 +7,7 @@ import {
|
|||||||
GroupRequestOperateTypes,
|
GroupRequestOperateTypes,
|
||||||
} from '@/ntqqapi/types'
|
} from '@/ntqqapi/types'
|
||||||
import { GeneralCallResult } from './common'
|
import { GeneralCallResult } from './common'
|
||||||
|
import { Dict } from 'cosmokit'
|
||||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
|
||||||
|
|
||||||
export interface NodeIKernelGroupService {
|
export interface NodeIKernelGroupService {
|
||||||
getMemberCommonInfo(Req: {
|
getMemberCommonInfo(Req: {
|
||||||
@ -29,8 +28,10 @@ export interface NodeIKernelGroupService {
|
|||||||
onlineFlag: string,
|
onlineFlag: string,
|
||||||
realSpecialTitleFlag: number
|
realSpecialTitleFlag: number
|
||||||
}): Promise<unknown>
|
}): Promise<unknown>
|
||||||
|
|
||||||
//26702
|
//26702
|
||||||
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>
|
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>
|
||||||
|
|
||||||
//26702
|
//26702
|
||||||
getGroupHonorList(groupCodes: Array<string>): unknown
|
getGroupHonorList(groupCodes: Array<string>): unknown
|
||||||
|
|
||||||
@ -45,6 +46,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>
|
||||||
|
|
||||||
@ -70,12 +72,16 @@ export interface NodeIKernelGroupService {
|
|||||||
brief: string
|
brief: string
|
||||||
}
|
}
|
||||||
}): Promise<unknown>
|
}): Promise<unknown>
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
//26702(其实更早 但是我不知道)
|
||||||
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
//26702(其实更早 但是我不知道)
|
||||||
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
//26702(其实更早 但是我不知道)
|
||||||
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>
|
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>
|
||||||
|
|
||||||
//26702
|
//26702
|
||||||
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||||
errCode: number,
|
errCode: number,
|
||||||
@ -85,7 +91,7 @@ export interface NodeIKernelGroupService {
|
|||||||
uid: string,
|
uid: string,
|
||||||
index: number//0
|
index: number//0
|
||||||
}>,
|
}>,
|
||||||
infos: {},
|
infos: Dict,
|
||||||
finish: true,
|
finish: true,
|
||||||
hasRobot: false
|
hasRobot: false
|
||||||
}
|
}
|
||||||
@ -171,7 +177,7 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
clearGroupNotifies(groupCode: string): void
|
clearGroupNotifies(groupCode: string): void
|
||||||
|
|
||||||
getGroupNotifiesUnreadCount(unknown: Boolean): Promise<GeneralCallResult>
|
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>
|
||||||
|
|
||||||
clearGroupNotifiesUnreadCount(groupCode: string): void
|
clearGroupNotifiesUnreadCount(groupCode: string): void
|
||||||
|
|
||||||
@ -193,7 +199,7 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
deleteGroupBulletin(groupCode: string, seq: string): void
|
deleteGroupBulletin(groupCode: string, seq: string): void
|
||||||
|
|
||||||
publishGroupBulletin(groupCode: string, pskey: string, data: any): Promise<GeneralCallResult>
|
publishGroupBulletin(groupCode: string, pskey: string, data: unknown): Promise<GeneralCallResult>
|
||||||
|
|
||||||
publishInstructionForNewcomers(groupCode: string, arg: unknown): void
|
publishInstructionForNewcomers(groupCode: string, arg: unknown): void
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ export interface TmpChatInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NodeIKernelMsgService {
|
export interface NodeIKernelMsgService {
|
||||||
|
|
||||||
generateMsgUniqueId(chatType: number, time: string): string
|
generateMsgUniqueId(chatType: number, time: string): string
|
||||||
|
|
||||||
addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number
|
addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number
|
||||||
|
@ -169,7 +169,7 @@ export interface NodeIKernelRichMediaService {
|
|||||||
|
|
||||||
downloadFileForFileInfo(fileInfo: CommonFileInfo[], savePath: string): unknown
|
downloadFileForFileInfo(fileInfo: CommonFileInfo[], savePath: string): unknown
|
||||||
|
|
||||||
createGroupFolder(GroupCode: string, FolderName: string): Promise<GeneralCallResult & { resultWithGroupItem: { result: any, groupItem: Array<any> } }>
|
createGroupFolder(GroupCode: string, FolderName: string): Promise<GeneralCallResult & { resultWithGroupItem: { result: unknown, groupItem: Array<unknown> } }>
|
||||||
|
|
||||||
downloadFile(commonFile: CommonFileInfo, arg2: unknown, arg3: unknown, savePath: string): unknown
|
downloadFile(commonFile: CommonFileInfo, arg2: unknown, arg3: unknown, savePath: string): unknown
|
||||||
|
|
||||||
@ -222,9 +222,9 @@ export interface NodeIKernelRichMediaService {
|
|||||||
|
|
||||||
deleteGroupFile(GroupCode: string, params: Array<number>, Files: Array<string>): Promise<GeneralCallResult & {
|
deleteGroupFile(GroupCode: string, params: Array<number>, Files: Array<string>): Promise<GeneralCallResult & {
|
||||||
transGroupFileResult: {
|
transGroupFileResult: {
|
||||||
result: any
|
result: unknown
|
||||||
successFileIdList: Array<any>
|
successFileIdList: Array<unknown>
|
||||||
failFileIdList: Array<any>
|
failFileIdList: Array<unknown>
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ interface CommonExt {
|
|||||||
address: string
|
address: string
|
||||||
regTime: number
|
regTime: number
|
||||||
interest: string
|
interest: string
|
||||||
labels: unknown[]
|
labels: string[]
|
||||||
qqLevel: QQLevel
|
qqLevel: QQLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import { Dict } from 'cosmokit'
|
|||||||
const Process = require('node:process')
|
const Process = require('node:process')
|
||||||
|
|
||||||
export interface NodeIQQNTWrapperSession {
|
export interface NodeIQQNTWrapperSession {
|
||||||
[key: string]: any
|
|
||||||
getBuddyService(): NodeIKernelBuddyService
|
getBuddyService(): NodeIKernelBuddyService
|
||||||
getGroupService(): NodeIKernelGroupService
|
getGroupService(): NodeIKernelGroupService
|
||||||
getProfileService(): NodeIKernelProfileService
|
getProfileService(): NodeIKernelProfileService
|
||||||
@ -36,19 +35,6 @@ export interface WrapperApi {
|
|||||||
|
|
||||||
export interface WrapperConstructor {
|
export interface WrapperConstructor {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
NodeIKernelBuddyListener?: any
|
|
||||||
NodeIKernelGroupListener?: any
|
|
||||||
NodeQQNTWrapperUtil?: any
|
|
||||||
NodeIKernelMsgListener?: any
|
|
||||||
NodeIQQNTWrapperEngine?: any
|
|
||||||
NodeIGlobalAdapter?: any
|
|
||||||
NodeIDependsAdapter?: any
|
|
||||||
NodeIDispatcherAdapter?: any
|
|
||||||
NodeIKernelSessionListener?: any
|
|
||||||
NodeIKernelLoginService?: any
|
|
||||||
NodeIKernelLoginListener?: any
|
|
||||||
NodeIKernelProfileService?: any
|
|
||||||
NodeIKernelProfileListener?: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperApi: WrapperApi = {}
|
const wrapperApi: WrapperApi = {}
|
||||||
@ -75,9 +61,9 @@ Process.dlopenOrig = Process.dlopen
|
|||||||
|
|
||||||
Process.dlopen = function (module: Dict, filename: string, flags = constants.dlopen.RTLD_LAZY) {
|
Process.dlopen = function (module: Dict, filename: string, flags = constants.dlopen.RTLD_LAZY) {
|
||||||
const dlopenRet = this.dlopenOrig(module, filename, flags)
|
const dlopenRet = this.dlopenOrig(module, filename, flags)
|
||||||
for (let export_name in module.exports) {
|
for (const export_name in module.exports) {
|
||||||
module.exports[export_name] = new Proxy(module.exports[export_name], {
|
module.exports[export_name] = new Proxy(module.exports[export_name], {
|
||||||
construct: (target, args, _newTarget) => {
|
construct: (target, args) => {
|
||||||
const ret = new target(...args)
|
const ret = new target(...args)
|
||||||
if (export_name === 'NodeIQQNTWrapperSession') wrapperApi.NodeIQQNTWrapperSession = ret
|
if (export_name === 'NodeIQQNTWrapperSession') wrapperApi.NodeIQQNTWrapperSession = ret
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
x
Reference in New Issue
Block a user