mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
285fc1d33d | ||
![]() |
e14ba108fc | ||
![]() |
e0be0bcc77 | ||
![]() |
c24fa6cea1 | ||
![]() |
04b2a323a7 | ||
![]() |
970f1a98ec | ||
![]() |
3064a6eb7c | ||
![]() |
f93e2b5a95 | ||
![]() |
e185e700b7 | ||
![]() |
eae6e09e22 | ||
![]() |
e204bb0957 | ||
![]() |
ed546ace3d | ||
![]() |
3c79cffa42 | ||
![]() |
acce444dee | ||
![]() |
f359e3ea9d | ||
![]() |
fe99da985f | ||
![]() |
58d5de572c | ||
![]() |
b2088824cc | ||
![]() |
fffa664400 | ||
![]() |
02e5222f92 | ||
![]() |
18d253edf6 | ||
![]() |
da8b5e2429 | ||
![]() |
502be69bc5 | ||
![]() |
273d4133eb | ||
![]() |
44bfc5aab9 | ||
![]() |
050c9d9b54 |
@@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||
"version": "3.31.6",
|
||||
"version": "3.31.9",
|
||||
"icon": "./icon.webp",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -22,7 +22,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"cosmokit": "^1.6.2",
|
||||
"express": "^4.19.2",
|
||||
"fast-xml-parser": "^4.4.1",
|
||||
"fast-xml-parser": "^4.5.0",
|
||||
"file-type": "^19.4.1",
|
||||
"fluent-ffmpeg": "^2.1.3",
|
||||
"minato": "^3.5.1",
|
||||
@@ -38,7 +38,7 @@
|
||||
"electron": "^31.4.0",
|
||||
"electron-vite": "^2.3.0",
|
||||
"typescript": "^5.5.4",
|
||||
"vite": "^5.4.2",
|
||||
"vite": "^5.4.3",
|
||||
"vite-plugin-cp": "^4.0.8"
|
||||
},
|
||||
"packageManager": "yarn@4.4.1"
|
||||
|
@@ -1,25 +1,8 @@
|
||||
import fs from 'node:fs'
|
||||
import { Config, OB11Config } from './types'
|
||||
import path from 'node:path'
|
||||
import { Config, OB11Config } from './types'
|
||||
import { selfInfo, DATA_DIR } from './globalVars'
|
||||
|
||||
// 在保证老对象已有的属性不变化的情况下将新对象的属性复制到老对象
|
||||
function mergeNewProperties(newObj: any, oldObj: any) {
|
||||
Object.keys(newObj).forEach((key) => {
|
||||
// 如果老对象不存在当前属性,则直接复制
|
||||
if (!oldObj.hasOwnProperty(key)) {
|
||||
oldObj[key] = newObj[key]
|
||||
} else {
|
||||
// 如果老对象和新对象的当前属性都是对象,则递归合并
|
||||
if (typeof oldObj[key] === 'object' && typeof newObj[key] === 'object') {
|
||||
mergeNewProperties(newObj[key], oldObj[key])
|
||||
} else if (typeof oldObj[key] === 'object' || typeof newObj[key] === 'object') {
|
||||
// 属性冲突,有一方不是对象,直接覆盖
|
||||
oldObj[key] = newObj[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
import { mergeNewProperties } from './utils/misc'
|
||||
|
||||
export class ConfigUtil {
|
||||
private readonly configPath: string
|
||||
@@ -50,7 +33,8 @@ export class ConfigUtil {
|
||||
enableWsReverse: false,
|
||||
messagePostFormat: 'array',
|
||||
enableHttpHeart: false,
|
||||
enableQOAutoQuote: false
|
||||
enableQOAutoQuote: false,
|
||||
listenLocalhost: false
|
||||
}
|
||||
const defaultConfig: Config = {
|
||||
enableLLOB: true,
|
||||
@@ -102,7 +86,7 @@ export class ConfigUtil {
|
||||
// 迁移旧的配置到新配置,避免用户重新填写配置
|
||||
const oldValue = oldConfig[oldKey]
|
||||
if (oldValue) {
|
||||
currentConfig[currentKey] = oldValue as any
|
||||
Object.assign(currentConfig, { [currentKey]: oldValue })
|
||||
delete oldConfig[oldKey]
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ export interface OB11Config {
|
||||
messagePostFormat?: 'array' | 'string'
|
||||
enableHttpHeart?: boolean
|
||||
enableQOAutoQuote: boolean // 快速操作回复自动引用原消息
|
||||
listenLocalhost: boolean
|
||||
}
|
||||
|
||||
export interface CheckVersion {
|
||||
|
@@ -3,7 +3,6 @@ import ffmpeg from 'fluent-ffmpeg'
|
||||
import fsPromise from 'node:fs/promises'
|
||||
import { decode, encode, getDuration, getWavFileInfo, isWav, isSilk, EncodeResult } from 'silk-wasm'
|
||||
import { TEMP_DIR } from '../globalVars'
|
||||
import { getConfigUtil } from '../config'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Readable } from 'node:stream'
|
||||
import { Context } from 'cordis'
|
||||
@@ -17,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, outputPath: string): Promise<string>
|
||||
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?: string): Promise<Buffer> | Promise<string> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?: string): Promise<Buffer | string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks: Buffer[] = []
|
||||
let command = ffmpeg(input)
|
||||
.on('error', err => {
|
||||
@@ -38,7 +37,7 @@ function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?
|
||||
if (options.output) {
|
||||
command = command.outputOptions(options.output)
|
||||
}
|
||||
const ffmpegPath = getConfigUtil().getConfig().ffmpeg
|
||||
const ffmpegPath: string | undefined = ctx.config.ffmpeg
|
||||
if (ffmpegPath) {
|
||||
command = command.setFfmpegPath(ffmpegPath)
|
||||
}
|
||||
@@ -85,8 +84,8 @@ export async function encodeSilk(ctx: Context, filePath: string) {
|
||||
let duration = 1
|
||||
try {
|
||||
duration = getDuration(silk) / 1000
|
||||
} catch (e: any) {
|
||||
ctx.logger.warn('获取语音文件时长失败, 默认为1秒', filePath, e.stack)
|
||||
} catch (e) {
|
||||
ctx.logger.warn('获取语音文件时长失败, 默认为1秒', filePath, (e as Error).stack)
|
||||
}
|
||||
return {
|
||||
converted: false,
|
||||
@@ -94,8 +93,8 @@ export async function encodeSilk(ctx: Context, filePath: string) {
|
||||
duration,
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
ctx.logger.error('convert silk failed', error.stack)
|
||||
} catch (err) {
|
||||
ctx.logger.error('convert silk failed', (err as Error).stack)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import { randomUUID } from 'node:crypto'
|
||||
interface Internal_MapKey {
|
||||
timeout: number
|
||||
createtime: number
|
||||
func: (...arg: any[]) => any
|
||||
checker: ((...args: any[]) => boolean) | undefined
|
||||
func: (...arg: any[]) => unknown
|
||||
checker?: (...args: any[]) => boolean
|
||||
}
|
||||
|
||||
export class ListenerClassBase {
|
||||
@@ -13,7 +13,7 @@ export class ListenerClassBase {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -30,11 +30,11 @@ export class NTEventWrapper {
|
||||
createProxyDispatch(ListenerMainName: string) {
|
||||
const current = this
|
||||
return new Proxy({}, {
|
||||
get(target: any, prop: any, receiver: any) {
|
||||
get(target: any, prop: string, receiver: unknown) {
|
||||
// console.log('get', prop, typeof target[prop])
|
||||
if (typeof target[prop] === 'undefined') {
|
||||
// 如果方法不存在,返回一个函数,这个函数调用existentMethod
|
||||
return (...args: any[]) => {
|
||||
return (...args: unknown[]) => {
|
||||
current.dispatcherListener.apply(current, [ListenerMainName, prop, ...args]).then()
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ export class NTEventWrapper {
|
||||
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('/')
|
||||
type eventType = {
|
||||
[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)
|
||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
||||
//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) => {
|
||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
||||
let complete = false
|
||||
@@ -162,7 +162,7 @@ export class NTEventWrapper {
|
||||
const id = randomUUID()
|
||||
let complete = 0
|
||||
let retData: Parameters<ListenerType> | undefined = undefined
|
||||
let retEvent: any = {}
|
||||
let retEvent = {}
|
||||
const databack = () => {
|
||||
if (complete == 0) {
|
||||
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,
|
||||
createtime: Date.now(),
|
||||
checker: checker,
|
||||
func: (...args: any[]) => {
|
||||
func: (...args: unknown[]) => {
|
||||
complete++
|
||||
//console.log('func', ...args)
|
||||
retData = args as Parameters<ListenerType>
|
||||
@@ -200,7 +200,7 @@ export class NTEventWrapper {
|
||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak)
|
||||
this.createListenerFunction(ListenerMainName)
|
||||
const EventFunc = this.createEventFunction<EventType>(EventName)
|
||||
retEvent = await EventFunc!(...(args as any[]))
|
||||
retEvent = await EventFunc!(...args)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -142,8 +142,8 @@ export async function uri2local(uri: string, filename?: string): Promise<Uri2Loc
|
||||
const filePath = path.join(TEMP_DIR, filename)
|
||||
await fsPromise.writeFile(filePath, res.data)
|
||||
return { success: true, errMsg: '', fileName: filename, path: filePath, isLocal: false }
|
||||
} catch (e: any) {
|
||||
const errMsg = `${uri} 下载失败, ${e.message}`
|
||||
} catch (e) {
|
||||
const errMsg = `${uri} 下载失败, ${(e as Error).message}`
|
||||
return { success: false, errMsg, fileName: '', path: '', isLocal: false }
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ export async function copyFolder(sourcePath: string, destPath: string) {
|
||||
try {
|
||||
const entries = await fsPromise.readdir(sourcePath, { withFileTypes: true })
|
||||
await fsPromise.mkdir(destPath, { recursive: true })
|
||||
for (let entry of entries) {
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(sourcePath, entry.name)
|
||||
const dstPath = path.join(destPath, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
|
@@ -2,8 +2,9 @@ import fs from 'fs'
|
||||
import path from 'node:path'
|
||||
import { getConfigUtil } from '../config'
|
||||
import { LOG_DIR } from '../globalVars'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
function truncateString(obj: any, maxLength = 500) {
|
||||
function truncateString(obj: Dict | null, maxLength = 500) {
|
||||
if (obj !== null && typeof obj === 'object') {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
if (typeof obj[key] === 'string') {
|
||||
@@ -22,7 +23,7 @@ function truncateString(obj: any, maxLength = 500) {
|
||||
|
||||
export const logFileName = `llonebot-${new Date().toLocaleString('zh-CN')}.log`.replace(/\//g, '-').replace(/:/g, '-')
|
||||
|
||||
export function log(...msg: any[]) {
|
||||
export function log(...msg: unknown[]) {
|
||||
if (!getConfigUtil().getConfig().log) {
|
||||
return
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { QQLevel } from '@/ntqqapi/types'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
export function isNumeric(str: string) {
|
||||
return /^\d+$/.test(str)
|
||||
@@ -13,4 +14,22 @@ export function calcQQLevel(level: QQLevel) {
|
||||
export function getBuildVersion(): number {
|
||||
const version: string = globalThis.LiteLoader.versions.qqnt
|
||||
return +version.split('-')[1]
|
||||
}
|
||||
|
||||
/** 在保证老对象已有的属性不变化的情况下将新对象的属性复制到老对象 */
|
||||
export function mergeNewProperties(newObj: Dict, oldObj: Dict) {
|
||||
Object.keys(newObj).forEach((key) => {
|
||||
// 如果老对象不存在当前属性,则直接复制
|
||||
if (!oldObj.hasOwnProperty(key)) {
|
||||
oldObj[key] = newObj[key]
|
||||
} else {
|
||||
// 如果老对象和新对象的当前属性都是对象,则递归合并
|
||||
if (typeof oldObj[key] === 'object' && typeof newObj[key] === 'object') {
|
||||
mergeNewProperties(newObj[key], oldObj[key])
|
||||
} else if (typeof oldObj[key] === 'object' || typeof newObj[key] === 'object') {
|
||||
// 属性冲突,有一方不是对象,直接覆盖
|
||||
oldObj[key] = newObj[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
@@ -1,106 +1,104 @@
|
||||
import https from 'node:https'
|
||||
import http from 'node:http'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
export class RequestUtil {
|
||||
// 适用于获取服务器下发cookies时获取,仅GET
|
||||
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) => {
|
||||
client.get(url, (res) => {
|
||||
let cookies: { [key: string]: string } = {};
|
||||
let cookies: { [key: string]: string } = {}
|
||||
const handleRedirect = (res: http.IncomingMessage) => {
|
||||
//console.log(res.headers.location);
|
||||
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||
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) => {
|
||||
// 合并重定向过程中的cookies
|
||||
//log('redirectCookies', redirectCookies)
|
||||
cookies = { ...cookies, ...redirectCookies };
|
||||
resolve(cookies);
|
||||
});
|
||||
cookies = { ...cookies, ...redirectCookies }
|
||||
resolve(cookies)
|
||||
})
|
||||
} else {
|
||||
resolve(cookies);
|
||||
resolve(cookies)
|
||||
}
|
||||
} else {
|
||||
resolve(cookies);
|
||||
resolve(cookies)
|
||||
}
|
||||
};
|
||||
res.on('data', () => { }); // Necessary to consume the stream
|
||||
}
|
||||
res.on('data', () => { }) // Necessary to consume the stream
|
||||
res.on('end', () => {
|
||||
handleRedirect(res);
|
||||
});
|
||||
handleRedirect(res)
|
||||
})
|
||||
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) => {
|
||||
const parts = cookie.split(';')[0].split('=');
|
||||
const key = parts[0];
|
||||
const value = parts[1];
|
||||
const parts = cookie.split(';')[0].split('=')
|
||||
const key = parts[0]
|
||||
const value = parts[1]
|
||||
if (key && value && key.length > 0 && value.length > 0) {
|
||||
cookies[key] = value;
|
||||
cookies[key] = value
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}).on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 请求和回复都是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> {
|
||||
let option = new URL(url);
|
||||
const protocol = url.startsWith('https://') ? https : http;
|
||||
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: unknown, headers: Record<string, string> = {}, isJsonRet: boolean = true, isArgJson: boolean = true): Promise<T> {
|
||||
const option = new URL(url)
|
||||
const protocol = url.startsWith('https://') ? https : http
|
||||
const options = {
|
||||
hostname: option.hostname,
|
||||
port: option.port,
|
||||
path: option.href,
|
||||
method: method,
|
||||
headers: headers
|
||||
};
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = protocol.request(options, (res: any) => {
|
||||
let responseBody = '';
|
||||
const req = protocol.request(options, (res: Dict) => {
|
||||
let responseBody = ''
|
||||
res.on('data', (chunk: string | Buffer) => {
|
||||
responseBody += chunk.toString();
|
||||
});
|
||||
responseBody += chunk.toString()
|
||||
})
|
||||
|
||||
res.on('end', () => {
|
||||
try {
|
||||
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (isJsonRet) {
|
||||
const responseJson = JSON.parse(responseBody);
|
||||
resolve(responseJson as T);
|
||||
const responseJson = JSON.parse(responseBody)
|
||||
resolve(responseJson as T)
|
||||
} else {
|
||||
resolve(responseBody as T);
|
||||
resolve(responseBody as T)
|
||||
}
|
||||
} else {
|
||||
reject(new Error(`Unexpected status code: ${res.statusCode}`));
|
||||
reject(new Error(`Unexpected status code: ${res.statusCode}`))
|
||||
}
|
||||
} catch (parseError) {
|
||||
reject(parseError);
|
||||
reject(parseError)
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
req.on('error', (error) => {
|
||||
reject(error)
|
||||
})
|
||||
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
||||
if (isArgJson) {
|
||||
req.write(JSON.stringify(data));
|
||||
req.write(JSON.stringify(data))
|
||||
} 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> = {}) {
|
||||
return this.HttpGetJson<string>(url, method, data, headers, false, false);
|
||||
static async HttpGetText(url: string, method: string = 'GET', data?: unknown, headers: Record<string, string> = {}) {
|
||||
return this.HttpGetJson<string>(url, method, data, headers, false, false)
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@ export async function checkNewVersion() {
|
||||
//log('llonebot last version', latestVersion)
|
||||
const currentVersion: string[] = version.split('.')
|
||||
//log('llonebot current version', currentVersion)
|
||||
for (let k of [0, 1, 2]) {
|
||||
for (const k of [0, 1, 2]) {
|
||||
if (parseInt(latestVersion[k]) > parseInt(currentVersion[k])) {
|
||||
log('')
|
||||
return { result: true, version: latestVersionText }
|
||||
@@ -47,14 +47,14 @@ export async function upgradeLLOneBot() {
|
||||
return false
|
||||
}
|
||||
const temp_ver_dir = path.join(TEMP_DIR, 'LLOneBot' + latestVersion)
|
||||
let uncompressedPromise = async function () {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
const uncompressedPromise = async function () {
|
||||
return new Promise<boolean>(resolve => {
|
||||
compressing.zip
|
||||
.uncompress(filePath, temp_ver_dir)
|
||||
.then(() => {
|
||||
resolve(true)
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
.catch(reason => {
|
||||
log('llonebot upgrade failed, ', reason)
|
||||
if (reason?.errno == -4082) {
|
||||
resolve(true)
|
||||
@@ -75,8 +75,8 @@ export async function upgradeLLOneBot() {
|
||||
export async function getRemoteVersion() {
|
||||
let Version = ''
|
||||
for (let i = 0; i < checkVersionMirrorHosts.length; i++) {
|
||||
let mirrorGithub = checkVersionMirrorHosts[i]
|
||||
let tVersion = await getRemoteVersionByMirror(mirrorGithub)
|
||||
const mirrorGithub = checkVersionMirrorHosts[i]
|
||||
const tVersion = await getRemoteVersionByMirror(mirrorGithub)
|
||||
if (tVersion && tVersion != '') {
|
||||
Version = tVersion
|
||||
break
|
||||
|
File diff suppressed because one or more lines are too long
@@ -53,15 +53,15 @@ function onLoad() {
|
||||
fs.mkdirSync(LOG_DIR)
|
||||
}
|
||||
|
||||
ipcMain.handle(CHANNEL_CHECK_VERSION, async (event, arg) => {
|
||||
ipcMain.handle(CHANNEL_CHECK_VERSION, async () => {
|
||||
return checkNewVersion()
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNEL_UPDATE, async (event, arg) => {
|
||||
ipcMain.handle(CHANNEL_UPDATE, async () => {
|
||||
return upgradeLLOneBot()
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNEL_SELECT_FILE, async (event, arg) => {
|
||||
ipcMain.handle(CHANNEL_SELECT_FILE, async () => {
|
||||
const selectPath = new Promise<string>((resolve, reject) => {
|
||||
dialog
|
||||
.showOpenDialog({
|
||||
@@ -90,10 +90,10 @@ function onLoad() {
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNEL_ERROR, async (event, arg) => {
|
||||
ipcMain.handle(CHANNEL_ERROR, async () => {
|
||||
const ffmpegOk = await checkFfmpeg(getConfigUtil().getConfig().ffmpeg)
|
||||
llonebotError.ffmpegError = ffmpegOk ? '' : '没有找到 FFmpeg, 音频只能发送 WAV 和 SILK, 视频尺寸可能异常'
|
||||
let { httpServerError, wsServerError, otherError, ffmpegError } = llonebotError
|
||||
const { httpServerError, wsServerError, otherError, ffmpegError } = llonebotError
|
||||
let error = `${otherError}\n${httpServerError}\n${wsServerError}\n${ffmpegError}`
|
||||
error = error.replace('\n\n', '\n')
|
||||
error = error.trim()
|
||||
@@ -101,12 +101,12 @@ function onLoad() {
|
||||
return error
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNEL_GET_CONFIG, async (event, arg) => {
|
||||
ipcMain.handle(CHANNEL_GET_CONFIG, async () => {
|
||||
const config = getConfigUtil().getConfig()
|
||||
return config
|
||||
})
|
||||
|
||||
ipcMain.handle(CHANNEL_SET_CONFIG, (event, ask: boolean, config: LLOBConfig) => {
|
||||
ipcMain.handle(CHANNEL_SET_CONFIG, (_event, ask: boolean, config: LLOBConfig) => {
|
||||
return new Promise<boolean>(resolve => {
|
||||
if (!ask) {
|
||||
getConfigUtil().setConfig(config)
|
||||
@@ -139,7 +139,7 @@ function onLoad() {
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on(CHANNEL_LOG, (event, arg) => {
|
||||
ipcMain.on(CHANNEL_LOG, (_event, arg) => {
|
||||
log(arg)
|
||||
})
|
||||
|
||||
@@ -175,6 +175,9 @@ function onLoad() {
|
||||
debug: config.debug!,
|
||||
reportSelfMessage: config.reportSelfMessage!,
|
||||
msgCacheExpire: config.msgCacheExpire!,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url!,
|
||||
ffmpeg: config.ffmpeg,
|
||||
})
|
||||
ctx.start()
|
||||
ipcMain.on(CHANNEL_SET_CONFIG_CONFIRMED, (event, config: LLOBConfig) => {
|
||||
@@ -209,15 +212,15 @@ function onBrowserWindowCreated(window: BrowserWindow) {
|
||||
try {
|
||||
hookNTQQApiCall(window, window.id !== 2)
|
||||
hookNTQQApiReceive(window, window.id !== 2)
|
||||
} catch (e: any) {
|
||||
log('LLOneBot hook error: ', e.toString())
|
||||
} catch (e) {
|
||||
log('LLOneBot hook error: ', String(e))
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
onLoad()
|
||||
} catch (e: any) {
|
||||
console.log(e.toString())
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
// 这两个函数都是可选的
|
||||
|
@@ -238,19 +238,19 @@ export class NTQQFileApi extends Service {
|
||||
const url: string = element.originImageUrl! // 没有域名
|
||||
const md5HexStr = element.md5HexStr
|
||||
const fileMd5 = element.md5HexStr
|
||||
|
||||
|
||||
if (url) {
|
||||
const UrlParse = new URL(IMAGE_HTTP_HOST + url) //临时解析拼接
|
||||
const imageAppid = UrlParse.searchParams.get('appid')
|
||||
const parsedUrl = new URL(IMAGE_HTTP_HOST + url) //临时解析拼接
|
||||
const imageAppid = parsedUrl.searchParams.get('appid')
|
||||
const isNewPic = imageAppid && ['1406', '1407'].includes(imageAppid)
|
||||
if (isNewPic) {
|
||||
let UrlRkey = UrlParse.searchParams.get('rkey')
|
||||
if (UrlRkey) {
|
||||
let rkey = parsedUrl.searchParams.get('rkey')
|
||||
if (rkey) {
|
||||
return IMAGE_HTTP_HOST_NT + url
|
||||
}
|
||||
const rkeyData = await this.rkeyManager.getRkey()
|
||||
UrlRkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey
|
||||
return IMAGE_HTTP_HOST_NT + url + `${UrlRkey}`
|
||||
rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey
|
||||
return IMAGE_HTTP_HOST_NT + url + rkey
|
||||
} else {
|
||||
// 老的图片url,不需要rkey
|
||||
return IMAGE_HTTP_HOST + url
|
||||
|
@@ -4,7 +4,7 @@ import { invoke, NTMethod, NTClass } from '../ntcall'
|
||||
import { getSession } from '@/ntqqapi/wrapper'
|
||||
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||
import { pick } from 'cosmokit'
|
||||
import { Dict, pick } from 'cosmokit'
|
||||
import { Service, Context } from 'cordis'
|
||||
|
||||
declare module 'cordis' {
|
||||
@@ -19,7 +19,7 @@ export class NTQQFriendApi extends Service {
|
||||
}
|
||||
|
||||
/** 大于或等于 26702 应使用 getBuddyV2 */
|
||||
async getFriends(forced = false) {
|
||||
async getFriends(_forced = false) {
|
||||
const data = await invoke<{
|
||||
data: {
|
||||
categoryId: number
|
||||
@@ -145,16 +145,16 @@ export class NTQQFriendApi extends Service {
|
||||
const session = getSession()
|
||||
if (session) {
|
||||
const uids: string[] = []
|
||||
const categoryMap: Map<string, any> = new Map()
|
||||
const categoryMap: Map<string, Dict> = new Map()
|
||||
const buddyService = session.getBuddyService()
|
||||
const buddyListV2 = (await buddyService?.getBuddyListV2('0', BuddyListReqType.KNOMAL))?.data
|
||||
const buddyListV2 = (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data
|
||||
uids.push(
|
||||
...buddyListV2?.flatMap(item => {
|
||||
...buddyListV2.flatMap(item => {
|
||||
item.buddyUids.forEach(uid => {
|
||||
categoryMap.set(uid, { categoryId: item.categoryId, categroyName: item.categroyName })
|
||||
})
|
||||
return item.buddyUids
|
||||
})!)
|
||||
}))
|
||||
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||
)
|
||||
|
@@ -4,8 +4,7 @@ import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||
import { GeneralCallResult } from '../services'
|
||||
import { NTQQWindows } from './window'
|
||||
import { getSession } from '../wrapper'
|
||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||
import { NodeIKernelGroupListener, OnGroupFileInfoUpdateParams } from '../listeners'
|
||||
import { OnGroupFileInfoUpdateParams } from '../listeners'
|
||||
import { NodeIKernelGroupService } from '../services'
|
||||
import { Service, Context } from 'cordis'
|
||||
import { isNumeric } from '@/common/utils/misc'
|
||||
@@ -26,34 +25,19 @@ export class NTQQGroupApi extends Service {
|
||||
}
|
||||
|
||||
async getGroups(forced = false): Promise<Group[]> {
|
||||
if (NTEventDispatch.initialised) {
|
||||
type ListenerType = NodeIKernelGroupListener['onGroupListUpdate']
|
||||
const [, , groupList] = await NTEventDispatch.CallNormalEvent
|
||||
<(force: boolean) => Promise<any>, ListenerType>
|
||||
(
|
||||
'NodeIKernelGroupService/getGroupList',
|
||||
'NodeIKernelGroupListener/onGroupListUpdate',
|
||||
1,
|
||||
5000,
|
||||
() => true,
|
||||
forced
|
||||
)
|
||||
return groupList
|
||||
} else {
|
||||
const result = await invoke<{
|
||||
updateType: number
|
||||
groupList: Group[]
|
||||
}>(
|
||||
'getGroupList',
|
||||
[],
|
||||
{
|
||||
className: NTClass.NODE_STORE_API,
|
||||
cbCmd: ReceiveCmdS.GROUPS_STORE,
|
||||
afterFirstCmd: false,
|
||||
}
|
||||
)
|
||||
return result.groupList
|
||||
}
|
||||
const result = await invoke<{
|
||||
updateType: number
|
||||
groupList: Group[]
|
||||
}>(
|
||||
'getGroupList',
|
||||
[],
|
||||
{
|
||||
className: NTClass.NODE_STORE_API,
|
||||
cbCmd: ReceiveCmdS.GROUPS_STORE,
|
||||
afterFirstCmd: false,
|
||||
}
|
||||
)
|
||||
return result.groupList
|
||||
}
|
||||
|
||||
async getGroupMembers(groupCode: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||
@@ -76,30 +60,29 @@ export class NTQQGroupApi extends Service {
|
||||
async getGroupMember(groupCode: string | number, memberUinOrUid: string | number) {
|
||||
const groupCodeStr = groupCode.toString()
|
||||
const memberUinOrUidStr = memberUinOrUid.toString()
|
||||
let members = this.groupMembers.get(groupCodeStr)
|
||||
if (!members) {
|
||||
if (!this.groupMembers.has(groupCodeStr)) {
|
||||
try {
|
||||
members = await this.getGroupMembers(groupCodeStr)
|
||||
// 更新群成员列表
|
||||
this.groupMembers.set(groupCodeStr, members)
|
||||
this.groupMembers.set(groupCodeStr, await this.getGroupMembers(groupCodeStr))
|
||||
}
|
||||
catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
let members = this.groupMembers.get(groupCodeStr)!
|
||||
const getMember = () => {
|
||||
let member: GroupMember | undefined = undefined
|
||||
if (isNumeric(memberUinOrUidStr)) {
|
||||
member = Array.from(members!.values()).find(member => member.uin === memberUinOrUidStr)
|
||||
member = Array.from(members.values()).find(member => member.uin === memberUinOrUidStr)
|
||||
} else {
|
||||
member = members!.get(memberUinOrUidStr)
|
||||
member = members.get(memberUinOrUidStr)
|
||||
}
|
||||
return member
|
||||
}
|
||||
let member = getMember()
|
||||
if (!member) {
|
||||
members = await this.getGroupMembers(groupCodeStr)
|
||||
this.groupMembers.set(groupCodeStr, members)
|
||||
this.groupMembers.set(groupCodeStr, await this.getGroupMembers(groupCodeStr))
|
||||
members = this.groupMembers.get(groupCodeStr)!
|
||||
member = getMember()
|
||||
}
|
||||
return member
|
||||
@@ -115,32 +98,16 @@ export class NTQQGroupApi extends Service {
|
||||
}
|
||||
|
||||
async getSingleScreenNotifies(num: number) {
|
||||
if (NTEventDispatch.initialised) {
|
||||
const [_retData, _doubt, _seq, notifies] = await NTEventDispatch.CallNormalEvent
|
||||
<(arg1: boolean, arg2: string, arg3: number) => Promise<any>, (doubt: boolean, seq: string, notifies: GroupNotify[]) => void>
|
||||
(
|
||||
'NodeIKernelGroupService/getSingleScreenNotifies',
|
||||
'NodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
||||
1,
|
||||
5000,
|
||||
() => true,
|
||||
false,
|
||||
'',
|
||||
num,
|
||||
)
|
||||
return notifies
|
||||
} else {
|
||||
invoke(ReceiveCmdS.GROUP_NOTIFY, [], { classNameIsRegister: true })
|
||||
return (await invoke<GroupNotifies>(
|
||||
'nodeIKernelGroupService/getSingleScreenNotifies',
|
||||
[{ doubt: false, startSeq: '', number: num }, null],
|
||||
{
|
||||
invoke(ReceiveCmdS.GROUP_NOTIFY, [], { classNameIsRegister: true })
|
||||
return (await invoke<GroupNotifies>(
|
||||
'nodeIKernelGroupService/getSingleScreenNotifies',
|
||||
[{ doubt: false, startSeq: '', number: num }, null],
|
||||
{
|
||||
|
||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||
afterFirstCmd: false,
|
||||
}
|
||||
)).notifies
|
||||
}
|
||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||
afterFirstCmd: false,
|
||||
}
|
||||
)).notifies
|
||||
}
|
||||
|
||||
async handleGroupRequest(flag: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
||||
@@ -261,30 +228,30 @@ export class NTQQGroupApi extends Service {
|
||||
}
|
||||
|
||||
/** 27187 TODO */
|
||||
async removeGroupEssence(GroupCode: string, msgId: string) {
|
||||
async removeGroupEssence(groupCode: string, msgId: string) {
|
||||
const session = getSession()
|
||||
// 代码没测过
|
||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
||||
let param = {
|
||||
groupCode: GroupCode,
|
||||
msgRandom: parseInt(MsgData?.msgList[0].msgRandom!),
|
||||
msgSeq: parseInt(MsgData?.msgList[0].msgSeq!)
|
||||
const data = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: groupCode }, msgId, 1, false)
|
||||
const param = {
|
||||
groupCode: groupCode,
|
||||
msgRandom: Number(data?.msgList[0].msgRandom),
|
||||
msgSeq: Number(data?.msgList[0].msgSeq)
|
||||
}
|
||||
// GetMsgByShoretID(ShoretID) -> MsgService.getMsgs(Peer,MsgId,1,false) -> 组出参数
|
||||
return session?.getGroupService().removeGroupEssence(param)
|
||||
}
|
||||
|
||||
/** 27187 TODO */
|
||||
async addGroupEssence(GroupCode: string, msgId: string) {
|
||||
async addGroupEssence(groupCode: string, msgId: string) {
|
||||
const session = getSession()
|
||||
// 代码没测过
|
||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||
let MsgData = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: GroupCode }, msgId, 1, false)
|
||||
let param = {
|
||||
groupCode: GroupCode,
|
||||
msgRandom: parseInt(MsgData?.msgList[0].msgRandom!),
|
||||
msgSeq: parseInt(MsgData?.msgList[0].msgSeq!)
|
||||
const data = await session?.getMsgService().getMsgsIncludeSelf({ chatType: 2, guildId: '', peerUid: groupCode }, msgId, 1, false)
|
||||
const param = {
|
||||
groupCode: groupCode,
|
||||
msgRandom: Number(data?.msgList[0].msgRandom),
|
||||
msgSeq: Number(data?.msgList[0].msgSeq)
|
||||
}
|
||||
// GetMsgByShoretID(ShoretID) -> MsgService.getMsgs(Peer,MsgId,1,false) -> 组出参数
|
||||
return session?.getGroupService().addGroupEssence(param)
|
||||
|
@@ -2,7 +2,6 @@ import { invoke, NTMethod } from '../ntcall'
|
||||
import { GeneralCallResult } from '../services'
|
||||
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
||||
import { getSession } from '@/ntqqapi/wrapper'
|
||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||
import { Service, Context } from 'cordis'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
|
||||
@@ -102,62 +101,35 @@ export class NTQQMsgApi extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], timeout = 10000) {
|
||||
const msgId = generateMsgId()
|
||||
peer.guildId = msgId
|
||||
let msgList: RawMessage[]
|
||||
if (NTEventDispatch.initialised) {
|
||||
const data = await NTEventDispatch.CallNormalEvent<
|
||||
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||
(msgList: RawMessage[]) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/sendMsg',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
timeout,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||
'nodeIKernelMsgService/sendMsg',
|
||||
[
|
||||
{
|
||||
msgId: '0',
|
||||
peer,
|
||||
msgElements,
|
||||
msgAttributeInfos: new Map()
|
||||
},
|
||||
null
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => {
|
||||
for (const msgRecord of payload.msgList) {
|
||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
'0',
|
||||
peer,
|
||||
msgElements,
|
||||
new Map()
|
||||
)
|
||||
msgList = data[1]
|
||||
} else {
|
||||
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||
'nodeIKernelMsgService/sendMsg',
|
||||
[
|
||||
{
|
||||
msgId: '0',
|
||||
peer,
|
||||
msgElements,
|
||||
msgAttributeInfos: new Map()
|
||||
},
|
||||
null
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => {
|
||||
for (const msgRecord of payload.msgList) {
|
||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
timeout
|
||||
}
|
||||
)
|
||||
msgList = data.msgList
|
||||
}
|
||||
return msgList.find(msgRecord => msgRecord.guildId === msgId)
|
||||
timeout
|
||||
}
|
||||
)
|
||||
return data.msgList.find(msgRecord => msgRecord.guildId === msgId)
|
||||
}
|
||||
|
||||
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||
@@ -165,7 +137,7 @@ export class NTQQMsgApi extends Service {
|
||||
if (session) {
|
||||
return session.getMsgService().forwardMsg(msgIds, srcPeer, [destPeer], [])
|
||||
} else {
|
||||
return await invoke<GeneralCallResult>(NTMethod.FORWARD_MSG, [{
|
||||
return await invoke(NTMethod.FORWARD_MSG, [{
|
||||
msgIds,
|
||||
srcContact: srcPeer,
|
||||
dstContacts: [destPeer],
|
||||
@@ -181,65 +153,37 @@ export class NTQQMsgApi extends Service {
|
||||
return { msgId: id, senderShowName }
|
||||
})
|
||||
const selfUid = selfInfo.uid
|
||||
let msgList: RawMessage[]
|
||||
if (NTEventDispatch.initialised) {
|
||||
const data = await NTEventDispatch.CallNormalEvent<
|
||||
(msgInfo: typeof msgInfos, srcPeer: Peer, destPeer: Peer, comment: Array<any>, attr: Map<any, any>,) => Promise<unknown>,
|
||||
(msgList: RawMessage[]) => void
|
||||
>(
|
||||
'NodeIKernelMsgService/multiForwardMsgWithComment',
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
5000,
|
||||
(msgRecords: RawMessage[]) => {
|
||||
for (let msgRecord of msgRecords) {
|
||||
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||
'nodeIKernelMsgService/multiForwardMsgWithComment',
|
||||
[
|
||||
{
|
||||
msgInfos,
|
||||
srcContact: srcPeer,
|
||||
dstContact: destPeer,
|
||||
commentElements: [],
|
||||
msgAttributeInfos: new Map(),
|
||||
},
|
||||
null,
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => {
|
||||
for (const msgRecord of payload.msgList) {
|
||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == selfUid) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
msgInfos,
|
||||
srcPeer,
|
||||
destPeer,
|
||||
[],
|
||||
new Map()
|
||||
)
|
||||
msgList = data[1]
|
||||
} else {
|
||||
const data = await invoke<{ msgList: RawMessage[] }>(
|
||||
'nodeIKernelMsgService/multiForwardMsgWithComment',
|
||||
[
|
||||
{
|
||||
msgInfos,
|
||||
srcContact: srcPeer,
|
||||
dstContact: destPeer,
|
||||
commentElements: [],
|
||||
msgAttributeInfos: new Map(),
|
||||
},
|
||||
null,
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => {
|
||||
for (const msgRecord of payload.msgList) {
|
||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == selfUid) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
}
|
||||
)
|
||||
msgList = data.msgList
|
||||
}
|
||||
for (const msg of msgList) {
|
||||
}
|
||||
)
|
||||
for (const msg of data.msgList) {
|
||||
const arkElement = msg.elements.find(ele => ele.arkElement)
|
||||
if (!arkElement) {
|
||||
continue
|
||||
}
|
||||
const forwardData: any = JSON.parse(arkElement.arkElement.bytesData)
|
||||
const forwardData = JSON.parse(arkElement.arkElement.bytesData)
|
||||
if (forwardData.app != 'com.tencent.multimsg') {
|
||||
continue
|
||||
}
|
||||
@@ -272,4 +216,40 @@ export class NTQQMsgApi extends Service {
|
||||
return await invoke('nodeIKernelMsgService/getSingleMsg', [{ peer, msgSeq }, null])
|
||||
}
|
||||
}
|
||||
|
||||
async queryFirstMsgBySeq(peer: Peer, msgSeq: string) {
|
||||
return await invoke('nodeIKernelMsgService/queryMsgsWithFilterEx', [{
|
||||
msgId: '0',
|
||||
msgTime: '0',
|
||||
msgSeq,
|
||||
params: {
|
||||
chatInfo: peer,
|
||||
filterMsgType: [],
|
||||
filterSendersUid: [],
|
||||
filterMsgToTime: '0',
|
||||
filterMsgFromTime: '0',
|
||||
isReverseOrder: true,
|
||||
isIncludeCurrent: true,
|
||||
pageLimit: 1,
|
||||
}
|
||||
}, null])
|
||||
}
|
||||
|
||||
async queryMsgsWithFilterExBySeq(peer: Peer, msgSeq: string, filterMsgTime: string, filterSendersUid: string[]) {
|
||||
return await invoke('nodeIKernelMsgService/queryMsgsWithFilterEx', [{
|
||||
msgId: '0',
|
||||
msgTime: '0',
|
||||
msgSeq,
|
||||
params: {
|
||||
chatInfo: peer,
|
||||
filterMsgType: [],
|
||||
filterSendersUid,
|
||||
filterMsgToTime: filterMsgTime,
|
||||
filterMsgFromTime: filterMsgTime,
|
||||
isReverseOrder: true,
|
||||
isIncludeCurrent: true,
|
||||
pageLimit: 1,
|
||||
}
|
||||
}, null])
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
import { invoke, NTMethod } from '../ntcall'
|
||||
import { invoke } from '../ntcall'
|
||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
||||
import { getBuildVersion } from '@/common/utils'
|
||||
import { getSession } from '@/ntqqapi/wrapper'
|
||||
import { RequestUtil } from '@/common/utils/request'
|
||||
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
||||
import { NodeIKernelProfileListener } from '../listeners'
|
||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||
import { UserDetailSource, ProfileBizType } from '../services'
|
||||
import { Time } from 'cosmokit'
|
||||
import { Service, Context } from 'cordis'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
@@ -37,44 +35,24 @@ export class NTQQUserApi extends Service {
|
||||
}
|
||||
|
||||
async fetchUserDetailInfo(uid: string) {
|
||||
let info: UserDetailInfoListenerArg
|
||||
if (NTEventDispatch.initialised) {
|
||||
type EventService = NodeIKernelProfileService['fetchUserDetailInfo']
|
||||
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged']
|
||||
const [_retData, profile] = await NTEventDispatch.CallNormalEvent
|
||||
<EventService, EventListener>
|
||||
(
|
||||
'NodeIKernelProfileService/fetchUserDetailInfo',
|
||||
'NodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||
1,
|
||||
5000,
|
||||
(profile) => profile.uid === uid,
|
||||
'BuddyProfileStore',
|
||||
[uid],
|
||||
UserDetailSource.KSERVER,
|
||||
[ProfileBizType.KALL]
|
||||
)
|
||||
info = profile
|
||||
} else {
|
||||
const result = await invoke<{ info: UserDetailInfoListenerArg }>(
|
||||
'nodeIKernelProfileService/fetchUserDetailInfo',
|
||||
[
|
||||
{
|
||||
callFrom: 'BuddyProfileStore',
|
||||
uid: [uid],
|
||||
source: UserDetailSource.KSERVER,
|
||||
bizList: [ProfileBizType.KALL]
|
||||
},
|
||||
null
|
||||
],
|
||||
const result = await invoke<{ info: UserDetailInfoListenerArg }>(
|
||||
'nodeIKernelProfileService/fetchUserDetailInfo',
|
||||
[
|
||||
{
|
||||
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => payload.info.uid === uid,
|
||||
}
|
||||
)
|
||||
info = result.info
|
||||
}
|
||||
callFrom: 'BuddyProfileStore',
|
||||
uid: [uid],
|
||||
source: UserDetailSource.KSERVER,
|
||||
bizList: [ProfileBizType.KALL]
|
||||
},
|
||||
null
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: payload => payload.info.uid === uid,
|
||||
}
|
||||
)
|
||||
const { info } = result
|
||||
const ret: User = {
|
||||
...info.simpleInfo.coreInfo,
|
||||
...info.simpleInfo.status,
|
||||
@@ -87,43 +65,26 @@ export class NTQQUserApi extends Service {
|
||||
return ret
|
||||
}
|
||||
|
||||
async getUserDetailInfo(uid: string, getLevel = false, withBizInfo = true) {
|
||||
async getUserDetailInfo(uid: string, _getLevel = false) {
|
||||
if (getBuildVersion() >= 26702) {
|
||||
return this.fetchUserDetailInfo(uid)
|
||||
}
|
||||
if (NTEventDispatch.initialised) {
|
||||
type EventService = NodeIKernelProfileService['getUserDetailInfoWithBizInfo']
|
||||
type EventListener = NodeIKernelProfileListener['onProfileDetailInfoChanged']
|
||||
const [_retData, profile] = await NTEventDispatch.CallNormalEvent
|
||||
<EventService, EventListener>
|
||||
(
|
||||
'NodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
||||
'NodeIKernelProfileListener/onProfileDetailInfoChanged',
|
||||
2,
|
||||
5000,
|
||||
(profile) => profile.uid === uid,
|
||||
uid,
|
||||
[0]
|
||||
)
|
||||
return profile
|
||||
} else {
|
||||
const result = await invoke<{ info: User }>(
|
||||
'nodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
||||
[
|
||||
{
|
||||
uid,
|
||||
bizList: [0]
|
||||
},
|
||||
null,
|
||||
],
|
||||
const result = await invoke<{ info: User }>(
|
||||
'nodeIKernelProfileService/getUserDetailInfoWithBizInfo',
|
||||
[
|
||||
{
|
||||
cbCmd: 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: (payload) => payload.info.uid === uid,
|
||||
}
|
||||
)
|
||||
return result.info
|
||||
}
|
||||
uid,
|
||||
bizList: [0]
|
||||
},
|
||||
null,
|
||||
],
|
||||
{
|
||||
cbCmd: 'nodeIKernelProfileListener/onProfileDetailInfoChanged',
|
||||
afterFirstCmd: false,
|
||||
cmdCB: (payload) => payload.info.uid === uid,
|
||||
}
|
||||
)
|
||||
return result.info
|
||||
}
|
||||
|
||||
async getSkey(): Promise<string> {
|
||||
@@ -244,40 +205,27 @@ export class NTQQUserApi extends Service {
|
||||
}
|
||||
|
||||
async getUserDetailInfoByUinV2(uin: string) {
|
||||
if (NTEventDispatch.initialised) {
|
||||
return await NTEventDispatch.CallNoListenerEvent
|
||||
<(Uin: string) => Promise<UserDetailInfoByUinV2>>(
|
||||
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||
5000,
|
||||
uin
|
||||
)
|
||||
} else {
|
||||
return await invoke<UserDetailInfoByUinV2>(
|
||||
'nodeIKernelProfileService/getUserDetailInfoByUin',
|
||||
[
|
||||
{ uin },
|
||||
null,
|
||||
],
|
||||
)
|
||||
}
|
||||
return await invoke<UserDetailInfoByUinV2>(
|
||||
'nodeIKernelProfileService/getUserDetailInfoByUin',
|
||||
[
|
||||
{ uin },
|
||||
null,
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
async getUserDetailInfoByUin(uin: string) {
|
||||
return NTEventDispatch.CallNoListenerEvent
|
||||
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
||||
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||
5000,
|
||||
uin
|
||||
)
|
||||
return await invoke<UserDetailInfoByUin>(
|
||||
'nodeIKernelProfileService/getUserDetailInfoByUin',
|
||||
[
|
||||
{ uin },
|
||||
null,
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
async getUinByUidV1(uid: string) {
|
||||
const ret = await NTEventDispatch.CallNoListenerEvent
|
||||
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
||||
'NodeIKernelUixConvertService/getUin',
|
||||
5000,
|
||||
[uid]
|
||||
)
|
||||
const ret = await invoke('nodeIKernelUixConvertService/getUin', [{ uids: [uid] }])
|
||||
let uin = ret.uinInfo.get(uid)
|
||||
if (!uin) {
|
||||
uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换
|
||||
@@ -334,4 +282,14 @@ export class NTQQUserApi extends Service {
|
||||
}
|
||||
return selfInfo.nick
|
||||
}
|
||||
|
||||
async setSelfStatus(status: number, extStatus: number, batteryStatus: number) {
|
||||
return await invoke('nodeIKernelMsgService/setStatus', [{
|
||||
statusReq: {
|
||||
status,
|
||||
extStatus,
|
||||
batteryStatus,
|
||||
}
|
||||
}, null])
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { RequestUtil } from '@/common/utils/request'
|
||||
import { Service, Context } from 'cordis'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
declare module 'cordis' {
|
||||
interface Context {
|
||||
@@ -40,7 +41,7 @@ interface WebApiGroupMemberRet {
|
||||
em: string
|
||||
cache: number
|
||||
adm_num: number
|
||||
levelname: any
|
||||
levelname: unknown
|
||||
mems: WebApiGroupMember[]
|
||||
count: number
|
||||
svr_time: number
|
||||
@@ -49,56 +50,6 @@ interface WebApiGroupMemberRet {
|
||||
extmode: number
|
||||
}
|
||||
|
||||
export interface WebApiGroupNoticeFeed {
|
||||
u: number//发送者
|
||||
fid: string//fid
|
||||
pubt: number//时间
|
||||
msg: {
|
||||
text: string
|
||||
text_face: string
|
||||
title: string,
|
||||
pics?: {
|
||||
id: string,
|
||||
w: string,
|
||||
h: string
|
||||
}[]
|
||||
}
|
||||
type: number
|
||||
fn: number
|
||||
cn: number
|
||||
vn: number
|
||||
settings: {
|
||||
is_show_edit_card: number
|
||||
remind_ts: number
|
||||
tip_window_type: number
|
||||
confirm_required: number
|
||||
}
|
||||
read_num: number
|
||||
is_read: number
|
||||
is_all_confirm: number
|
||||
}
|
||||
|
||||
export interface WebApiGroupNoticeRet {
|
||||
ec: number
|
||||
em: string
|
||||
ltsm: number
|
||||
srv_code: number
|
||||
read_only: number
|
||||
role: number
|
||||
feeds: WebApiGroupNoticeFeed[]
|
||||
group: {
|
||||
group_id: number
|
||||
class_ext: number
|
||||
}
|
||||
sta: number,
|
||||
gln: number
|
||||
tst: number,
|
||||
ui: any
|
||||
server_time: number
|
||||
svrt: number
|
||||
ad: number
|
||||
}
|
||||
|
||||
interface GroupEssenceMsg {
|
||||
group_code: string
|
||||
msg_seq: number
|
||||
@@ -109,7 +60,7 @@ interface GroupEssenceMsg {
|
||||
add_digest_uin: string
|
||||
add_digest_nick: string
|
||||
add_digest_time: number
|
||||
msg_content: any[]
|
||||
msg_content: unknown[]
|
||||
can_be_removed: true
|
||||
}
|
||||
|
||||
@@ -124,6 +75,30 @@ export interface GroupEssenceMsgRet {
|
||||
}
|
||||
}
|
||||
|
||||
interface SetGroupNoticeParams {
|
||||
groupCode: string
|
||||
content: string
|
||||
pinned: number
|
||||
type: number
|
||||
isShowEditCard: number
|
||||
tipWindowType: number
|
||||
confirmRequired: number
|
||||
picId: string
|
||||
imgWidth?: number
|
||||
imgHeight?: number
|
||||
}
|
||||
|
||||
interface SetGroupNoticeRet {
|
||||
ec: number
|
||||
em: string
|
||||
id: number
|
||||
ltsm: number
|
||||
new_fid: string
|
||||
read_only: number
|
||||
role: number
|
||||
srv_code: number
|
||||
}
|
||||
|
||||
export class NTQQWebApi extends Service {
|
||||
static inject = ['ntUserApi']
|
||||
|
||||
@@ -131,16 +106,16 @@ export class NTQQWebApi extends Service {
|
||||
super(ctx, 'ntWebApi', true)
|
||||
}
|
||||
|
||||
async getGroupMembers(GroupCode: string, cached: boolean = true): Promise<WebApiGroupMember[]> {
|
||||
async getGroupMembers(groupCode: string): Promise<WebApiGroupMember[]> {
|
||||
const memberData: Array<WebApiGroupMember> = new Array<WebApiGroupMember>()
|
||||
const cookieObject = await this.ctx.ntUserApi.getCookies('qun.qq.com')
|
||||
const cookieStr = Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
||||
const cookieStr = this.cookieToString(cookieObject)
|
||||
const retList: Promise<WebApiGroupMemberRet>[] = []
|
||||
const params = new URLSearchParams({
|
||||
st: '0',
|
||||
end: '40',
|
||||
sort: '1',
|
||||
gc: GroupCode,
|
||||
gc: groupCode,
|
||||
bkn: this.genBkn(cookieObject.skey)
|
||||
})
|
||||
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${params}`, 'POST', '', { 'Cookie': cookieStr })
|
||||
@@ -173,132 +148,161 @@ export class NTQQWebApi extends Service {
|
||||
}
|
||||
|
||||
genBkn(sKey: string) {
|
||||
sKey = sKey || '';
|
||||
let hash = 5381;
|
||||
|
||||
sKey = sKey || ''
|
||||
let hash = 5381
|
||||
for (let i = 0; i < sKey.length; i++) {
|
||||
const code = sKey.charCodeAt(i);
|
||||
hash = hash + (hash << 5) + code;
|
||||
const code = sKey.charCodeAt(i)
|
||||
hash = hash + (hash << 5) + code
|
||||
}
|
||||
|
||||
return (hash & 0x7FFFFFFF).toString();
|
||||
return (hash & 0x7FFFFFFF).toString()
|
||||
}
|
||||
|
||||
//实现未缓存 考虑2h缓存
|
||||
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
||||
const getDataInternal = async (Internal_groupCode: string, Internal_type: number) => {
|
||||
let url = 'https://qun.qq.com/interactive/honorlist?gc=' + Internal_groupCode + '&type=' + Internal_type.toString();
|
||||
let res = '';
|
||||
let resJson;
|
||||
const url = 'https://qun.qq.com/interactive/honorlist?gc=' + Internal_groupCode + '&type=' + Internal_type.toString()
|
||||
let resJson
|
||||
try {
|
||||
res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': cookieStr });
|
||||
const match = res.match(/window\.__INITIAL_STATE__=(.*?);/);
|
||||
const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': cookieStr })
|
||||
const match = res.match(/window\.__INITIAL_STATE__=(.*?);/)
|
||||
if (match) {
|
||||
resJson = JSON.parse(match[1].trim());
|
||||
resJson = JSON.parse(match[1].trim())
|
||||
}
|
||||
if (Internal_type === 1) {
|
||||
return resJson?.talkativeList;
|
||||
return resJson?.talkativeList
|
||||
} else {
|
||||
return resJson?.actorList;
|
||||
return resJson?.actorList
|
||||
}
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('获取当前群荣耀失败', url, e);
|
||||
this.ctx.logger.error('获取当前群荣耀失败', url, e)
|
||||
}
|
||||
return undefined;
|
||||
return undefined
|
||||
}
|
||||
|
||||
let HonorInfo: any = { group_id: groupCode };
|
||||
const honorInfo: Dict = { group_id: groupCode }
|
||||
const cookieObject = await this.ctx.ntUserApi.getCookies('qun.qq.com')
|
||||
const cookieStr = Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
||||
const cookieStr = this.cookieToString(cookieObject)
|
||||
|
||||
if (getType === WebHonorType.TALKACTIVE || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
let RetInternal = await getDataInternal(groupCode, 1);
|
||||
const RetInternal = await getDataInternal(groupCode, 1)
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取龙王信息失败');
|
||||
throw new Error('获取龙王信息失败')
|
||||
}
|
||||
HonorInfo.current_talkative = {
|
||||
honorInfo.current_talkative = {
|
||||
user_id: RetInternal[0]?.uin,
|
||||
avatar: RetInternal[0]?.avatar,
|
||||
nickname: RetInternal[0]?.name,
|
||||
day_count: 0,
|
||||
description: RetInternal[0]?.desc
|
||||
}
|
||||
HonorInfo.talkative_list = [];
|
||||
honorInfo.talkative_list = [];
|
||||
for (const talkative_ele of RetInternal) {
|
||||
HonorInfo.talkative_list.push({
|
||||
honorInfo.talkative_list.push({
|
||||
user_id: talkative_ele?.uin,
|
||||
avatar: talkative_ele?.avatar,
|
||||
description: talkative_ele?.desc,
|
||||
day_count: 0,
|
||||
nickname: talkative_ele?.name
|
||||
});
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
this.ctx.logger.error(e);
|
||||
this.ctx.logger.error(e)
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.PERFROMER || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
let RetInternal = await getDataInternal(groupCode, 2);
|
||||
const RetInternal = await getDataInternal(groupCode, 2)
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取群聊之火失败');
|
||||
throw new Error('获取群聊之火失败')
|
||||
}
|
||||
HonorInfo.performer_list = [];
|
||||
honorInfo.performer_list = []
|
||||
for (const performer_ele of RetInternal) {
|
||||
HonorInfo.performer_list.push({
|
||||
honorInfo.performer_list.push({
|
||||
user_id: performer_ele?.uin,
|
||||
nickname: performer_ele?.name,
|
||||
avatar: performer_ele?.avatar,
|
||||
description: performer_ele?.desc
|
||||
});
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
this.ctx.logger.error(e);
|
||||
this.ctx.logger.error(e)
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.PERFROMER || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
let RetInternal = await getDataInternal(groupCode, 3);
|
||||
const RetInternal = await getDataInternal(groupCode, 3)
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取群聊炽焰失败');
|
||||
throw new Error('获取群聊炽焰失败')
|
||||
}
|
||||
HonorInfo.legend_list = [];
|
||||
honorInfo.legend_list = []
|
||||
for (const legend_ele of RetInternal) {
|
||||
HonorInfo.legend_list.push({
|
||||
honorInfo.legend_list.push({
|
||||
user_id: legend_ele?.uin,
|
||||
nickname: legend_ele?.name,
|
||||
avatar: legend_ele?.avatar,
|
||||
desc: legend_ele?.description
|
||||
});
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('获取群聊炽焰失败', e);
|
||||
this.ctx.logger.error('获取群聊炽焰失败', e)
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
let RetInternal = await getDataInternal(groupCode, 6);
|
||||
const RetInternal = await getDataInternal(groupCode, 6)
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取快乐源泉失败');
|
||||
throw new Error('获取快乐源泉失败')
|
||||
}
|
||||
HonorInfo.emotion_list = [];
|
||||
honorInfo.emotion_list = []
|
||||
for (const emotion_ele of RetInternal) {
|
||||
HonorInfo.emotion_list.push({
|
||||
honorInfo.emotion_list.push({
|
||||
user_id: emotion_ele?.uin,
|
||||
nickname: emotion_ele?.name,
|
||||
avatar: emotion_ele?.avatar,
|
||||
desc: emotion_ele?.description
|
||||
});
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('获取快乐源泉失败', e);
|
||||
this.ctx.logger.error('获取快乐源泉失败', e)
|
||||
}
|
||||
}
|
||||
//冒尖小春笋好像已经被tx扬了
|
||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||
HonorInfo.strong_newbie_list = [];
|
||||
honorInfo.strong_newbie_list = []
|
||||
}
|
||||
return HonorInfo;
|
||||
return honorInfo
|
||||
}
|
||||
|
||||
async setGroupNotice(params: SetGroupNoticeParams): Promise<SetGroupNoticeRet> {
|
||||
const cookieObject = await this.ctx.ntUserApi.getCookies('qun.qq.com')
|
||||
const settings = JSON.stringify({
|
||||
is_show_edit_card: params.isShowEditCard,
|
||||
tip_window_type: params.tipWindowType,
|
||||
confirm_required: params.confirmRequired
|
||||
})
|
||||
|
||||
return await RequestUtil.HttpGetJson<SetGroupNoticeRet>(
|
||||
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?${new URLSearchParams({
|
||||
bkn: this.genBkn(cookieObject.skey),
|
||||
qid: params.groupCode,
|
||||
text: params.content,
|
||||
pinned: params.pinned.toString(),
|
||||
type: params.type.toString(),
|
||||
settings: settings,
|
||||
...(params.picId !== '' && {
|
||||
pic: params.picId,
|
||||
imgWidth: params.imgWidth?.toString(),
|
||||
imgHeight: params.imgHeight?.toString(),
|
||||
})
|
||||
})}`,
|
||||
'POST',
|
||||
'',
|
||||
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||
)
|
||||
}
|
||||
|
||||
private cookieToString(cookieObject: Dict) {
|
||||
return Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ')
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ export class NTQQWindowApi extends Service {
|
||||
// 打开窗口并获取对应的下发事件
|
||||
async openWindow<R = GeneralCallResult>(
|
||||
ntQQWindow: NTQQWindow,
|
||||
args: any[],
|
||||
args: unknown[],
|
||||
cbCmd: ReceiveCmd | undefined,
|
||||
autoCloseSeconds: number = 2,
|
||||
) {
|
||||
|
@@ -37,7 +37,7 @@ declare module 'cordis' {
|
||||
}
|
||||
|
||||
class Core extends Service {
|
||||
static inject = ['ntMsgApi', 'ntFileApi', 'ntFileCacheApi', 'ntFriendApi', 'ntGroupApi', 'ntUserApi', 'ntWindowApi']
|
||||
static inject = ['ntMsgApi', 'ntFriendApi', 'ntGroupApi']
|
||||
|
||||
constructor(protected ctx: Context, public config: Core.Config) {
|
||||
super(ctx, 'app', true)
|
||||
@@ -52,6 +52,9 @@ class Core extends Service {
|
||||
MessageUnique.init(selfInfo.uin)
|
||||
this.registerListener()
|
||||
this.ctx.logger.info(`LLOneBot/${version}`)
|
||||
this.ctx.on('llonebot/config-updated', input => {
|
||||
Object.assign(this.config, input)
|
||||
})
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
@@ -59,8 +62,8 @@ class Core extends Service {
|
||||
data: CategoryFriend[]
|
||||
}>(ReceiveCmdS.FRIENDS, (payload) => {
|
||||
type V2data = { userSimpleInfos: Map<string, SimpleInfo> }
|
||||
let friendList: User[] = [];
|
||||
if ((payload as any).userSimpleInfos) {
|
||||
let friendList: User[] = []
|
||||
if ('userSimpleInfos' in payload) {
|
||||
friendList = Object.values((payload as unknown as V2data).userSimpleInfos).map((v: SimpleInfo) => {
|
||||
return {
|
||||
...v.coreInfo,
|
||||
@@ -86,11 +89,11 @@ class Core extends Service {
|
||||
for (const msgElement of message.elements) {
|
||||
setTimeout(() => {
|
||||
const picPath = msgElement.picElement?.sourcePath
|
||||
const picThumbPath = [...msgElement.picElement?.thumbPath.values()]
|
||||
const picThumbPath = [...(msgElement.picElement?.thumbPath ?? []).values()]
|
||||
const pttPath = msgElement.pttElement?.filePath
|
||||
const filePath = msgElement.fileElement?.filePath
|
||||
const videoPath = msgElement.videoElement?.filePath
|
||||
const videoThumbPath: string[] = [...msgElement.videoElement.thumbPath?.values()!]
|
||||
const videoThumbPath = [...(msgElement.videoElement?.thumbPath ?? []).values()]
|
||||
const pathList = [picPath, ...picThumbPath, pttPath, filePath, videoPath, ...videoThumbPath]
|
||||
if (msgElement.picElement) {
|
||||
pathList.push(...Object.values(msgElement.picElement.thumbPath))
|
||||
@@ -123,15 +126,15 @@ class Core extends Service {
|
||||
}[]
|
||||
}>(ReceiveCmdS.RECENT_CONTACT, async (payload) => {
|
||||
for (const recentContact of payload.changedRecentContactLists) {
|
||||
for (const changedContact of recentContact.changedList) {
|
||||
if (activatedPeerUids.includes(changedContact.id)) continue
|
||||
activatedPeerUids.push(changedContact.id)
|
||||
const peer = { peerUid: changedContact.id, chatType: changedContact.chatType }
|
||||
if (changedContact.chatType === ChatType.temp) {
|
||||
for (const contact of recentContact.changedList) {
|
||||
if (activatedPeerUids.includes(contact.id)) continue
|
||||
activatedPeerUids.push(contact.id)
|
||||
const peer = { peerUid: contact.id, chatType: contact.chatType }
|
||||
if (contact.chatType === ChatType.temp) {
|
||||
this.ctx.ntMsgApi.activateChatAndGetHistory(peer).then(() => {
|
||||
this.ctx.ntMsgApi.getMsgHistory(peer, '', 20).then(({ msgList }) => {
|
||||
const lastTempMsg = msgList.at(-1)
|
||||
if (Date.now() / 1000 - parseInt(lastTempMsg?.msgTime!) < 5) {
|
||||
if (Date.now() / 1000 - Number(lastTempMsg?.msgTime) < 5) {
|
||||
this.ctx.parallel('nt/message-created', [lastTempMsg!])
|
||||
}
|
||||
})
|
||||
|
@@ -99,7 +99,7 @@ export namespace SendElementEntities {
|
||||
}
|
||||
}
|
||||
|
||||
export async function file(ctx: Context, filePath: string, fileName: string = '', folderId: string = ''): Promise<SendFileElement> {
|
||||
export async function file(ctx: Context, filePath: string, fileName = '', folderId = ''): Promise<SendFileElement> {
|
||||
const { fileName: _fileName, path, fileSize } = await ctx.ntFileApi.uploadFile(filePath, ElementType.FILE)
|
||||
if (fileSize === 0) {
|
||||
throw '文件异常,大小为 0'
|
||||
@@ -117,14 +117,14 @@ export namespace SendElementEntities {
|
||||
return element
|
||||
}
|
||||
|
||||
export async function video(ctx: Context, filePath: string, fileName: string = '', diyThumbPath: string = ''): Promise<SendVideoElement> {
|
||||
export async function video(ctx: Context, filePath: string, fileName = '', diyThumbPath = ''): Promise<SendVideoElement> {
|
||||
try {
|
||||
await stat(filePath)
|
||||
} catch (e) {
|
||||
throw `文件${filePath}异常,不存在`
|
||||
}
|
||||
ctx.logger.info('复制视频到QQ目录', filePath)
|
||||
let { fileName: _fileName, path, fileSize, md5 } = await ctx.ntFileApi.uploadFile(filePath, ElementType.VIDEO)
|
||||
const { fileName: _fileName, path, fileSize, md5 } = await ctx.ntFileApi.uploadFile(filePath, ElementType.VIDEO)
|
||||
|
||||
ctx.logger.info('复制视频到QQ目录完成', path)
|
||||
if (fileSize === 0) {
|
||||
@@ -147,7 +147,7 @@ export namespace SendElementEntities {
|
||||
filePath,
|
||||
}
|
||||
try {
|
||||
videoInfo = await getVideoInfo(path)
|
||||
videoInfo = await getVideoInfo(ctx, path)
|
||||
ctx.logger.info('视频信息', videoInfo)
|
||||
} catch (e) {
|
||||
ctx.logger.info('获取视频信息失败', e)
|
||||
@@ -170,7 +170,7 @@ export namespace SendElementEntities {
|
||||
|
||||
setTimeout(useDefaultThumb, 5000)
|
||||
ffmpeg(filePath)
|
||||
.on('error', (err) => {
|
||||
.on('error', () => {
|
||||
if (diyThumbPath) {
|
||||
copyFile(diyThumbPath, thumbPath)
|
||||
.then(() => {
|
||||
@@ -194,7 +194,7 @@ export namespace SendElementEntities {
|
||||
resolve(thumbPath)
|
||||
})
|
||||
})
|
||||
let thumbPath = new Map()
|
||||
const thumbPath = new Map()
|
||||
const _thumbPath = await createThumb
|
||||
ctx.logger.info('生成视频缩略图', _thumbPath)
|
||||
const thumbSize = (await stat(_thumbPath)).size
|
||||
|
@@ -35,7 +35,7 @@ export class RkeyManager {
|
||||
return now > this.rkeyData.expired_time
|
||||
}
|
||||
|
||||
async refreshRkey(): Promise<any> {
|
||||
async refreshRkey() {
|
||||
//刷新rkey
|
||||
this.rkeyData = await this.fetchServerRkey()
|
||||
}
|
||||
|
@@ -2,8 +2,9 @@ import type { BrowserWindow } from 'electron'
|
||||
import { NTClass, NTMethod } from './ntcall'
|
||||
import { log } from '@/common/utils'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
export const hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||
export const hookApiCallbacks: Record<string, (res: any) => void> = {}
|
||||
|
||||
export const ReceiveCmdS = {
|
||||
RECENT_CONTACT: 'nodeIKernelRecentContactListener/onRecentContactListChangedVer2',
|
||||
@@ -26,11 +27,11 @@ export const ReceiveCmdS = {
|
||||
CACHE_SCAN_FINISH: 'nodeIKernelStorageCleanListener/onFinishScan',
|
||||
MEDIA_UPLOAD_COMPLETE: 'nodeIKernelMsgListener/onRichMediaUploadComplete',
|
||||
SKEY_UPDATE: 'onSkeyUpdate',
|
||||
}
|
||||
} as const
|
||||
|
||||
export type ReceiveCmd = string
|
||||
|
||||
interface NTQQApiReturnData<Payload = unknown> extends Array<any> {
|
||||
interface NTQQApiReturnData extends Array<unknown> {
|
||||
0: {
|
||||
type: 'request'
|
||||
eventName: NTClass
|
||||
@@ -39,7 +40,7 @@ interface NTQQApiReturnData<Payload = unknown> extends Array<any> {
|
||||
1: {
|
||||
cmdName: ReceiveCmd
|
||||
cmdType: 'event'
|
||||
payload: Payload
|
||||
payload: unknown
|
||||
}[]
|
||||
}
|
||||
|
||||
@@ -67,16 +68,16 @@ export function hookNTQQApiReceive(window: BrowserWindow, onlyLog: boolean) {
|
||||
} catch { }
|
||||
if (!onlyLog) {
|
||||
if (args?.[1] instanceof Array) {
|
||||
for (const receiveData of args?.[1]) {
|
||||
for (const receiveData of args[1]) {
|
||||
const ntQQApiMethodName = receiveData.cmdName
|
||||
// log(`received ntqq api message: ${channel} ${ntQQApiMethodName}`, JSON.stringify(receiveData))
|
||||
for (const hook of receiveHooks) {
|
||||
if (hook.method.includes(ntQQApiMethodName)) {
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise(resolve => {
|
||||
try {
|
||||
hook.hookFunc(receiveData.payload)
|
||||
} catch (e: any) {
|
||||
log('hook error', ntQQApiMethodName, e.stack.toString())
|
||||
} catch (e) {
|
||||
log('hook error', ntQQApiMethodName, (e as Error).stack?.toString())
|
||||
}
|
||||
resolve(undefined)
|
||||
}).then()
|
||||
@@ -88,8 +89,7 @@ export function hookNTQQApiReceive(window: BrowserWindow, onlyLog: boolean) {
|
||||
// log("hookApiCallback", hookApiCallbacks, args)
|
||||
const callbackId = args[0].callbackId
|
||||
if (hookApiCallbacks[callbackId]) {
|
||||
// log("callback found")
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise(resolve => {
|
||||
hookApiCallbacks[callbackId](args[1])
|
||||
resolve(undefined)
|
||||
}).then()
|
||||
@@ -104,7 +104,7 @@ export function hookNTQQApiReceive(window: BrowserWindow, onlyLog: boolean) {
|
||||
|
||||
export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
||||
// 监听调用NTQQApi
|
||||
let webContents = window.webContents as any
|
||||
const webContents = window.webContents as Dict
|
||||
const ipc_message_proxy = webContents._events['-ipc-message']?.[0] || webContents._events['-ipc-message']
|
||||
|
||||
const proxyIpcMsg = new Proxy(ipc_message_proxy, {
|
||||
@@ -125,10 +125,10 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
||||
const callParams = _args.slice(1)
|
||||
callHooks.forEach((hook) => {
|
||||
if (hook.method.includes(cmdName)) {
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise(resolve => {
|
||||
try {
|
||||
hook.hookFunc(callParams)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
log('hook call error', e, _args)
|
||||
}
|
||||
resolve(undefined)
|
||||
@@ -150,14 +150,13 @@ export function hookNTQQApiCall(window: BrowserWindow, onlyLog: boolean) {
|
||||
const ipc_invoke_proxy = webContents._events['-ipc-invoke']?.[0] || webContents._events['-ipc-invoke']
|
||||
const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
|
||||
apply(target, thisArg, args) {
|
||||
// console.log(args);
|
||||
//HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
|
||||
args[0]['_replyChannel']['sendReply'] = new Proxy(args[0]['_replyChannel']['sendReply'], {
|
||||
apply(sendtarget, sendthisArg, sendargs) {
|
||||
sendtarget.apply(sendthisArg, sendargs)
|
||||
},
|
||||
})
|
||||
let ret = target.apply(thisArg, args)
|
||||
const ret = target.apply(thisArg, args)
|
||||
/*try {
|
||||
HOOK_LOG && log('call NTQQ invoke api return', ret)
|
||||
} catch (e) { }*/
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/ntqqapi/types'
|
||||
|
||||
interface IGroupListener {
|
||||
export interface IGroupListener {
|
||||
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]): void
|
||||
|
||||
onGroupExtListUpdate(...args: unknown[]): void
|
||||
@@ -52,189 +52,7 @@ interface IGroupListener {
|
||||
onJoinGroupNoVerifyFlag(...args: unknown[]): void
|
||||
|
||||
onGroupArkInviteStateResult(...args: unknown[]): void
|
||||
|
||||
// 发现于Win 9.9.9 23159
|
||||
onGroupMemberLevelInfoChange(...args: unknown[]): void
|
||||
}
|
||||
|
||||
export interface NodeIKernelGroupListener extends IGroupListener {
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||
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)
|
||||
}
|
||||
}
|
@@ -265,290 +265,4 @@ export interface IKernelMsgListener {
|
||||
|
||||
// 第一次发现于Win 9.9.9 23159
|
||||
onBroadcastHelperProgerssUpdate(...args: unknown[]): void
|
||||
|
||||
}
|
||||
|
||||
export interface NodeIKernelMsgListener extends IKernelMsgListener {
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||
new(listener: IKernelMsgListener): NodeIKernelMsgListener
|
||||
}
|
||||
|
||||
|
||||
export class MsgListener implements IKernelMsgListener {
|
||||
onAddSendMsg(msgRecord: RawMessage) {
|
||||
|
||||
}
|
||||
|
||||
onBroadcastHelperDownloadComplete(broadcastHelperTransNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onBroadcastHelperProgressUpdate(broadcastHelperTransNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onChannelFreqLimitInfoUpdate(contact: unknown, z: unknown, freqLimitInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onContactUnreadCntUpdate(hashMap: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onCustomWithdrawConfigUpdate(customWithdrawConfig: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onDraftUpdate(contact: unknown, arrayList: unknown, j2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onEmojiDownloadComplete(emojiNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onEmojiResourceUpdate(emojiResourceInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onFeedEventUpdate(firstViewDirectMsgNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onFileMsgCome(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onFirstViewDirectMsgUpdate(firstViewDirectMsgNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onFirstViewGroupGuildMapping(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGrabPasswordRedBag(i2: unknown, str: unknown, i3: unknown, recvdOrder: unknown, msgRecord: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGroupFileInfoAdd(groupItem: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGroupFileInfoUpdate(groupFileListResult: OnGroupFileInfoUpdateParams) {
|
||||
|
||||
}
|
||||
|
||||
onGroupGuildUpdate(groupGuildNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
onGroupTransferInfoAdd(groupItem: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGroupTransferInfoUpdate(groupFileListResult: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGuildInteractiveUpdate(guildInteractiveNotificationItem: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGuildMsgAbFlagChanged(guildMsgAbFlag: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onGuildNotificationAbstractUpdate(guildNotificationAbstractInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onHitCsRelatedEmojiResult(downloadRelateEmojiResultInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onHitEmojiKeywordResult(hitRelatedEmojiWordsResult: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onHitRelatedEmojiResult(relatedWordEmojiInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onImportOldDbProgressUpdate(importOldDbMsgNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onInputStatusPush(inputStatusInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onKickedOffLine(kickedInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onLineDev(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onLogLevelChanged(j2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgAbstractUpdate(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgBoxChanged(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgDelete(contact: unknown, arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgEventListUpdate(hashMap: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgInfoListAdd(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgInfoListUpdate(msgList: RawMessage[]) {
|
||||
|
||||
}
|
||||
|
||||
onMsgQRCodeStatusChanged(i2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgRecall(i2: unknown, str: unknown, j2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgSecurityNotify(msgRecord: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onMsgSettingUpdate(msgSetting: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onNtFirstViewMsgSyncEnd() {
|
||||
|
||||
}
|
||||
|
||||
onNtMsgSyncEnd() {
|
||||
|
||||
}
|
||||
|
||||
onNtMsgSyncStart() {
|
||||
|
||||
}
|
||||
|
||||
onReadFeedEventUpdate(firstViewDirectMsgNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvGroupGuildFlag(i2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvMsg(arrayList: RawMessage[]) {
|
||||
|
||||
}
|
||||
|
||||
onRecvMsgSvrRspTransInfo(j2: unknown, contact: unknown, i2: unknown, i3: unknown, str: unknown, bArr: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvOnlineFileMsg(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvS2CMsg(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvSysMsg(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRecvUDCFlag(i2: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRichMediaDownloadComplete(fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) {
|
||||
}
|
||||
|
||||
onRichMediaProgerssUpdate(fileTransNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onRichMediaUploadComplete(fileTransNotifyInfo: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onSearchGroupFileInfoUpdate(searchGroupFileResult: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onSendMsgError(j2: unknown, contact: unknown, i2: unknown, str: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onSysMsgNotification(i2: unknown, j2: unknown, j3: unknown, arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onTempChatInfoUpdate(tempChatInfo: TempOnRecvParams) {
|
||||
|
||||
}
|
||||
|
||||
onUnreadCntAfterFirstView(hashMap: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onUnreadCntUpdate(hashMap: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onUserChannelTabStatusChanged(z: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onUserOnlineStatusChanged(z: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onUserTabStatusChanged(arrayList: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onlineStatusBigIconDownloadPush(i2: unknown, j2: unknown, str: unknown) {
|
||||
|
||||
}
|
||||
|
||||
onlineStatusSmallIconDownloadPush(i2: unknown, j2: unknown, str: unknown) {
|
||||
|
||||
}
|
||||
|
||||
// 第一次发现于Linux
|
||||
onUserSecQualityChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
||||
onMsgWithRichLinkInfoUpdate(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
||||
onRedTouchChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
// 第一次发现于Win 9.9.9-23159
|
||||
onBroadcastHelperProgerssUpdate(...args: unknown[]) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import { User, UserDetailInfoListenerArg } from '@/ntqqapi/types'
|
||||
|
||||
interface IProfileListener {
|
||||
export interface IProfileListener {
|
||||
onProfileSimpleChanged(...args: unknown[]): void
|
||||
|
||||
onUserDetailInfoChanged(arg: UserDetailInfoListenerArg): void
|
||||
@@ -12,33 +12,4 @@ interface IProfileListener {
|
||||
onSelfStatusChanged(...args: unknown[]): void
|
||||
|
||||
onStrangerRemarkChanged(...args: unknown[]): void
|
||||
}
|
||||
|
||||
export interface NodeIKernelProfileListener extends IProfileListener {
|
||||
new(listener: IProfileListener): NodeIKernelProfileListener
|
||||
}
|
||||
|
||||
export class ProfileListener implements IProfileListener {
|
||||
onUserDetailInfoChanged(arg: UserDetailInfoListenerArg): void {
|
||||
|
||||
}
|
||||
onProfileSimpleChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
||||
onProfileDetailInfoChanged(profile: User) {
|
||||
|
||||
}
|
||||
|
||||
onStatusUpdate(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
||||
onSelfStatusChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
||||
onStrangerRemarkChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
}
|
@@ -108,7 +108,7 @@ interface InvokeOptions<ReturnType> {
|
||||
}
|
||||
|
||||
export function invoke<
|
||||
R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => any>>>,
|
||||
R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => unknown>>>,
|
||||
S extends keyof NTService = any,
|
||||
M extends keyof NTService[S] & string = any
|
||||
>(method: Extract<unknown, `${S}/${M}`> | string, args: unknown[], options: InvokeOptions<R> = {}) {
|
||||
@@ -137,7 +137,7 @@ export function invoke<
|
||||
const secondCallback = () => {
|
||||
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)) {
|
||||
removeReceiveHook(hookId)
|
||||
success = true
|
||||
@@ -174,7 +174,7 @@ export function invoke<
|
||||
channel,
|
||||
{
|
||||
sender: {
|
||||
send: (..._args: unknown[]) => {
|
||||
send: () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -29,7 +29,7 @@ export interface NodeIKernelBuddyService {
|
||||
buddyUids: Array<string>//Uids
|
||||
}>>
|
||||
|
||||
addKernelBuddyListener(listener: any): number
|
||||
addKernelBuddyListener(listener: unknown): number
|
||||
|
||||
getAllBuddyCount(): number
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { NodeIKernelGroupListener } from '@/ntqqapi/listeners'
|
||||
import {
|
||||
GroupExtParam,
|
||||
GroupMember,
|
||||
@@ -7,8 +6,7 @@ import {
|
||||
GroupRequestOperateTypes,
|
||||
} from '@/ntqqapi/types'
|
||||
import { GeneralCallResult } from './common'
|
||||
|
||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
export interface NodeIKernelGroupService {
|
||||
getMemberCommonInfo(Req: {
|
||||
@@ -29,8 +27,10 @@ export interface NodeIKernelGroupService {
|
||||
onlineFlag: string,
|
||||
realSpecialTitleFlag: number
|
||||
}): Promise<unknown>
|
||||
|
||||
//26702
|
||||
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>
|
||||
|
||||
//26702
|
||||
getGroupHonorList(groupCodes: Array<string>): unknown
|
||||
|
||||
@@ -45,6 +45,7 @@ export interface NodeIKernelGroupService {
|
||||
errMsg: string,
|
||||
uids: Map<string, string>
|
||||
}>
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>
|
||||
|
||||
@@ -70,12 +71,16 @@ export interface NodeIKernelGroupService {
|
||||
brief: string
|
||||
}
|
||||
}): Promise<unknown>
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>
|
||||
|
||||
//26702
|
||||
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||
errCode: number,
|
||||
@@ -85,7 +90,7 @@ export interface NodeIKernelGroupService {
|
||||
uid: string,
|
||||
index: number//0
|
||||
}>,
|
||||
infos: {},
|
||||
infos: Dict,
|
||||
finish: true,
|
||||
hasRobot: false
|
||||
}
|
||||
@@ -93,7 +98,7 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
setHeader(uid: string, path: string): unknown
|
||||
|
||||
addKernelGroupListener(listener: NodeIKernelGroupListener): number
|
||||
addKernelGroupListener(listener: unknown): number
|
||||
|
||||
removeKernelGroupListener(listenerId: unknown): void
|
||||
|
||||
@@ -171,7 +176,7 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
clearGroupNotifies(groupCode: string): void
|
||||
|
||||
getGroupNotifiesUnreadCount(unknown: Boolean): Promise<GeneralCallResult>
|
||||
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>
|
||||
|
||||
clearGroupNotifiesUnreadCount(groupCode: string): void
|
||||
|
||||
@@ -193,7 +198,7 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
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
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { ElementType, MessageElement, Peer, RawMessage, SendMessageElement } from '@/ntqqapi/types'
|
||||
import { NodeIKernelMsgListener } from '@/ntqqapi/listeners/NodeIKernelMsgListener'
|
||||
import { GeneralCallResult } from './common'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
export interface QueryMsgsParams {
|
||||
chatInfo: Peer,
|
||||
@@ -29,16 +29,15 @@ export interface TmpChatInfo {
|
||||
}
|
||||
|
||||
export interface NodeIKernelMsgService {
|
||||
|
||||
generateMsgUniqueId(chatType: number, time: string): string
|
||||
|
||||
addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number
|
||||
addKernelMsgListener(nodeIKernelMsgListener: unknown): number
|
||||
|
||||
sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>): Promise<GeneralCallResult>
|
||||
sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<unknown, unknown>): Promise<GeneralCallResult>
|
||||
|
||||
recallMsg(peer: Peer, msgIds: string[]): Promise<GeneralCallResult>
|
||||
|
||||
addKernelMsgImportToolListener(arg: Object): unknown
|
||||
addKernelMsgImportToolListener(arg: Dict): unknown
|
||||
|
||||
removeKernelMsgListener(args: unknown): unknown
|
||||
|
||||
@@ -52,7 +51,7 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
getOnLineDev(): void
|
||||
|
||||
kickOffLine(DevInfo: Object): unknown
|
||||
kickOffLine(DevInfo: Dict): unknown
|
||||
|
||||
setStatus(args: { status: number, extStatus: number, batteryStatus: number }): Promise<GeneralCallResult>
|
||||
|
||||
@@ -81,11 +80,11 @@ export interface NodeIKernelMsgService {
|
||||
// this.voipToken = bArr2
|
||||
// this.profileId = str
|
||||
|
||||
setToken(arg: Object): unknown
|
||||
setToken(arg: Dict): unknown
|
||||
|
||||
switchForeGround(): unknown
|
||||
|
||||
switchBackGround(arg: Object): unknown
|
||||
switchBackGround(arg: Dict): unknown
|
||||
|
||||
//hex
|
||||
setTokenForMqq(token: string): unknown
|
||||
@@ -111,10 +110,11 @@ export interface NodeIKernelMsgService {
|
||||
resendMsg(...args: unknown[]): unknown
|
||||
|
||||
reeditRecallMsg(...args: unknown[]): unknown
|
||||
|
||||
//调用请检查除开commentElements其余参数不能为null
|
||||
forwardMsg(msgIds: string[], srcContact: Peer, dstContacts: Peer[], commentElements: MessageElement[]): Promise<GeneralCallResult>
|
||||
|
||||
forwardMsgWithComment(...args: unknown[]): unknown
|
||||
forwardMsgWithComment(...args: unknown[]): Promise<GeneralCallResult>
|
||||
|
||||
forwardSubMsgWithComment(...args: unknown[]): unknown
|
||||
|
||||
@@ -142,9 +142,9 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
addLocalTofuRecordMsg(...args: unknown[]): unknown
|
||||
|
||||
addLocalRecordMsg(Peer: Peer, msgId: string, ele: MessageElement, attr: Array<any> | number, front: boolean): Promise<unknown>
|
||||
addLocalRecordMsg(Peer: Peer, msgId: string, ele: MessageElement, attr: Array<unknown> | number, front: boolean): Promise<unknown>
|
||||
|
||||
deleteMsg(Peer: Peer, msgIds: Array<string>): Promise<any>
|
||||
deleteMsg(Peer: Peer, msgIds: Array<string>): Promise<unknown>
|
||||
|
||||
updateElementExtBufForUI(...args: unknown[]): unknown
|
||||
|
||||
@@ -370,8 +370,9 @@ export interface NodeIKernelMsgService {
|
||||
getFileThumbSavePathForSend(...args: unknown[]): unknown
|
||||
|
||||
getFileThumbSavePath(...args: unknown[]): unknown
|
||||
|
||||
//猜测居多
|
||||
translatePtt2Text(MsgId: string, Peer: {}, MsgElement: {}): unknown
|
||||
translatePtt2Text(MsgId: string, Peer: Dict, MsgElement: Dict): unknown
|
||||
|
||||
setPttPlayedState(...args: unknown[]): unknown
|
||||
// NodeIQQNTWrapperSession fetchFavEmojiList [
|
||||
@@ -448,7 +449,7 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
getEmojiResourcePath(...args: unknown[]): unknown
|
||||
|
||||
JoinDragonGroupEmoji(JoinDragonGroupEmojiReq: any/*joinDragonGroupEmojiReq*/): unknown
|
||||
JoinDragonGroupEmoji(JoinDragonGroupEmojiReq: unknown): unknown
|
||||
|
||||
getMsgAbstracts(...args: unknown[]): unknown
|
||||
|
||||
@@ -623,7 +624,6 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>
|
||||
|
||||
//chattype,uid->Promise<any>
|
||||
getTempChatInfo(ChatType: number, Uid: string): Promise<TmpChatInfoApi>
|
||||
|
||||
setContactLocalTop(...args: unknown[]): unknown
|
||||
@@ -654,7 +654,7 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
recordEmoji(...args: unknown[]): unknown
|
||||
|
||||
fetchGetHitEmotionsByWord(args: Object): Promise<unknown>//表情推荐?
|
||||
fetchGetHitEmotionsByWord(args: Dict): Promise<unknown>//表情推荐?
|
||||
|
||||
deleteAllRoamMsgs(...args: unknown[]): unknown//漫游消息?
|
||||
|
||||
|
@@ -9,10 +9,10 @@ export interface NodeIKernelProfileLikeService {
|
||||
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number }
|
||||
|
||||
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
||||
'info': {
|
||||
'userLikeInfos': Array<any>,
|
||||
'friendMaxVotes': number,
|
||||
'start': number
|
||||
info: {
|
||||
userLikeInfos: Array<unknown>,
|
||||
friendMaxVotes: number,
|
||||
start: number
|
||||
}
|
||||
}>
|
||||
|
||||
|
@@ -33,7 +33,7 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>
|
||||
|
||||
addKernelProfileListener(listener: any): number
|
||||
addKernelProfileListener(listener: unknown): number
|
||||
|
||||
removeKernelProfileListener(listenerId: number): void
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
modifySelfProfile(...args: unknown[]): Promise<unknown>
|
||||
|
||||
modifyDesktopMiniProfile(param: any): Promise<GeneralCallResult>
|
||||
modifyDesktopMiniProfile(param: unknown): Promise<GeneralCallResult>
|
||||
|
||||
setNickName(NickName: string): Promise<unknown>
|
||||
|
||||
@@ -82,9 +82,9 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
getUserDetailInfo(uid: string): Promise<unknown>
|
||||
|
||||
getUserDetailInfoWithBizInfo(uid: string, Biz: any[]): Promise<GeneralCallResult>
|
||||
getUserDetailInfoWithBizInfo(uid: string, Biz: unknown[]): Promise<GeneralCallResult>
|
||||
|
||||
getUserDetailInfoByUin(uin: string): Promise<any>
|
||||
getUserDetailInfoByUin(uin: string): Promise<unknown>
|
||||
|
||||
getZplanAvatarInfos(args: string[]): Promise<unknown>
|
||||
|
||||
@@ -99,7 +99,7 @@ export interface NodeIKernelProfileService {
|
||||
getProfileQzonePicInfo(uid: string, type: number, force: boolean): Promise<unknown>
|
||||
|
||||
//profileService.getCoreInfo("UserRemarkServiceImpl::getStrangerRemarkByUid", arrayList)
|
||||
getCoreInfo(name: string, arg: any[]): unknown
|
||||
getCoreInfo(name: string, arg: unknown[]): unknown
|
||||
|
||||
//m429253e12.getOtherFlag("FriendListInfoCache_getKernelDataAndPutCache", new ArrayList<>())
|
||||
isNull(): boolean
|
||||
|
@@ -169,7 +169,7 @@ export interface NodeIKernelRichMediaService {
|
||||
|
||||
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
|
||||
|
||||
@@ -222,9 +222,9 @@ export interface NodeIKernelRichMediaService {
|
||||
|
||||
deleteGroupFile(GroupCode: string, params: Array<number>, Files: Array<string>): Promise<GeneralCallResult & {
|
||||
transGroupFileResult: {
|
||||
result: any
|
||||
successFileIdList: Array<any>
|
||||
failFileIdList: Array<any>
|
||||
result: unknown
|
||||
successFileIdList: Array<unknown>
|
||||
failFileIdList: Array<unknown>
|
||||
}
|
||||
}>
|
||||
|
||||
|
@@ -1,75 +1,75 @@
|
||||
import { ChatType } from '../types'
|
||||
|
||||
export interface NodeIKernelSearchService {
|
||||
addKernelSearchListener(...args: any[]): unknown// needs 1 arguments
|
||||
addKernelSearchListener(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
removeKernelSearchListener(...args: any[]): unknown// needs 1 arguments
|
||||
removeKernelSearchListener(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
searchStranger(...args: any[]): unknown// needs 3 arguments
|
||||
searchStranger(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchGroup(...args: any[]): unknown// needs 1 arguments
|
||||
searchGroup(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
searchLocalInfo(keywords: string, unknown: number/*4*/): unknown
|
||||
|
||||
cancelSearchLocalInfo(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchLocalInfo(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchBuddyChatInfo(...args: any[]): unknown// needs 2 arguments
|
||||
searchBuddyChatInfo(...args: unknown[]): unknown// needs 2 arguments
|
||||
|
||||
searchMoreBuddyChatInfo(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreBuddyChatInfo(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchBuddyChatInfo(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchBuddyChatInfo(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchContact(...args: any[]): unknown// needs 2 arguments
|
||||
searchContact(...args: unknown[]): unknown// needs 2 arguments
|
||||
|
||||
searchMoreContact(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreContact(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchContact(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchContact(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchGroupChatInfo(...args: any[]): unknown// needs 3 arguments
|
||||
searchGroupChatInfo(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
resetSearchGroupChatInfoSortType(...args: any[]): unknown// needs 3 arguments
|
||||
resetSearchGroupChatInfoSortType(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
resetSearchGroupChatInfoFilterMembers(...args: any[]): unknown// needs 3 arguments
|
||||
resetSearchGroupChatInfoFilterMembers(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchMoreGroupChatInfo(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreGroupChatInfo(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchGroupChatInfo(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchGroupChatInfo(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchChatsWithKeywords(...args: any[]): unknown// needs 3 arguments
|
||||
searchChatsWithKeywords(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchMoreChatsWithKeywords(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreChatsWithKeywords(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchChatsWithKeywords(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchChatsWithKeywords(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchChatMsgs(...args: any[]): unknown// needs 2 arguments
|
||||
searchChatMsgs(...args: unknown[]): unknown// needs 2 arguments
|
||||
|
||||
searchMoreChatMsgs(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreChatMsgs(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchChatMsgs(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchChatMsgs(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchMsgWithKeywords(...args: any[]): unknown// needs 2 arguments
|
||||
searchMsgWithKeywords(...args: unknown[]): unknown// needs 2 arguments
|
||||
|
||||
searchMoreMsgWithKeywords(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreMsgWithKeywords(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchMsgWithKeywords(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchMsgWithKeywords(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchFileWithKeywords(keywords: string[], source: number): Promise<string>// needs 2 arguments
|
||||
|
||||
searchMoreFileWithKeywords(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreFileWithKeywords(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchFileWithKeywords(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchFileWithKeywords(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchAtMeChats(...args: any[]): unknown// needs 3 arguments
|
||||
searchAtMeChats(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchMoreAtMeChats(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreAtMeChats(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchAtMeChats(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchAtMeChats(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
searchChatAtMeMsgs(...args: any[]): unknown// needs 1 arguments
|
||||
searchChatAtMeMsgs(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
searchMoreChatAtMeMsgs(...args: any[]): unknown// needs 1 arguments
|
||||
searchMoreChatAtMeMsgs(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
cancelSearchChatAtMeMsgs(...args: any[]): unknown// needs 3 arguments
|
||||
cancelSearchChatAtMeMsgs(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
addSearchHistory(param: {
|
||||
type: number,//4
|
||||
@@ -120,9 +120,9 @@ export interface NodeIKernelSearchService {
|
||||
id?: number
|
||||
}>
|
||||
|
||||
removeSearchHistory(...args: any[]): unknown// needs 1 arguments
|
||||
removeSearchHistory(...args: unknown[]): unknown// needs 1 arguments
|
||||
|
||||
searchCache(...args: any[]): unknown// needs 3 arguments
|
||||
searchCache(...args: unknown[]): unknown// needs 3 arguments
|
||||
|
||||
clearSearchCache(...args: any[]): unknown// needs 1 arguments
|
||||
clearSearchCache(...args: unknown[]): unknown// needs 1 arguments
|
||||
}
|
@@ -36,6 +36,7 @@ export interface Group {
|
||||
memberUid: string //"u_fbf8N7aeuZEnUiJAbQ9R8Q"
|
||||
}
|
||||
members: GroupMember[] // 原始数据是没有这个的,为了方便自己加了这个字段
|
||||
createTime: string
|
||||
}
|
||||
|
||||
export enum GroupMemberRole {
|
||||
|
@@ -352,7 +352,7 @@ export interface VideoElement {
|
||||
thumbHeight?: number
|
||||
busiType?: 0 // 未知
|
||||
subBusiType?: 0 // 未知
|
||||
thumbPath?: Map<number, any>
|
||||
thumbPath?: Map<number, string>
|
||||
transferStatus?: 0 // 未知
|
||||
progress?: 0 // 下载进度?
|
||||
invalidState?: 0 // 未知
|
||||
@@ -480,6 +480,8 @@ export interface RawMessage {
|
||||
sourceMsgIsIncPic: boolean // 原消息是否有图片
|
||||
sourceMsgText: string
|
||||
replayMsgSeq: string // 源消息的msgSeq,可以通过这个找到源消息的msgId
|
||||
senderUidStr: string
|
||||
replyMsgTime: string
|
||||
}
|
||||
textElement: {
|
||||
atType: AtType
|
||||
@@ -521,22 +523,22 @@ export interface MessageElement {
|
||||
grayTipElement?: GrayTipElement
|
||||
arkElement?: ArkElement
|
||||
fileElement?: FileElement
|
||||
liveGiftElement?: null
|
||||
liveGiftElement?: unknown
|
||||
markdownElement?: MarkdownElement
|
||||
structLongMsgElement?: any
|
||||
structLongMsgElement?: unknown
|
||||
multiForwardMsgElement?: MultiForwardMsgElement
|
||||
giphyElement?: any
|
||||
walletElement?: null
|
||||
giphyElement?: unknown
|
||||
walletElement?: unknown
|
||||
inlineKeyboardElement?: InlineKeyboardElement
|
||||
textGiftElement?: null //????
|
||||
calendarElement?: any
|
||||
yoloGameResultElement?: any
|
||||
avRecordElement?: any
|
||||
structMsgElement?: null
|
||||
faceBubbleElement?: any
|
||||
shareLocationElement?: any
|
||||
tofuRecordElement?: any
|
||||
taskTopMsgElement?: any
|
||||
recommendedMsgElement?: any
|
||||
actionBarElement?: any
|
||||
textGiftElement?: unknown //????
|
||||
calendarElement?: unknown
|
||||
yoloGameResultElement?: unknown
|
||||
avRecordElement?: unknown
|
||||
structMsgElement?: unknown
|
||||
faceBubbleElement?: unknown
|
||||
shareLocationElement?: unknown
|
||||
tofuRecordElement?: unknown
|
||||
taskTopMsgElement?: unknown
|
||||
recommendedMsgElement?: unknown
|
||||
actionBarElement?: unknown
|
||||
}
|
@@ -124,7 +124,7 @@ interface VideoInfo {
|
||||
|
||||
interface ExtOnlineBusinessInfo {
|
||||
buf: string
|
||||
customStatus: any
|
||||
customStatus: unknown
|
||||
videoBizInfo: VideoBizInfo
|
||||
videoInfo: VideoInfo
|
||||
}
|
||||
@@ -142,7 +142,7 @@ interface UserStatus {
|
||||
termType: number
|
||||
netType: number
|
||||
iconType: number
|
||||
customStatus: any
|
||||
customStatus: unknown
|
||||
setTime: string
|
||||
specialFlag: number
|
||||
abiFlag: number
|
||||
@@ -156,8 +156,8 @@ interface UserStatus {
|
||||
|
||||
interface PrivilegeIcon {
|
||||
jumpUrl: string
|
||||
openIconList: any[]
|
||||
closeIconList: any[]
|
||||
openIconList: unknown[]
|
||||
closeIconList: unknown[]
|
||||
}
|
||||
|
||||
interface VasInfo {
|
||||
@@ -180,7 +180,7 @@ interface VasInfo {
|
||||
fontEffect: number
|
||||
newLoverDiamondFlag: number
|
||||
extendNameplateId: number
|
||||
diyNameplateIDs: any[]
|
||||
diyNameplateIDs: unknown[]
|
||||
vipStartFlag: number
|
||||
vipDataFlag: number
|
||||
gameNameplateId: string
|
||||
@@ -200,8 +200,8 @@ export interface SimpleInfo {
|
||||
status: UserStatus | null
|
||||
vasInfo: VasInfo | null
|
||||
relationFlags: RelationFlags | null
|
||||
otherFlags: any | null
|
||||
intimate: any | null
|
||||
otherFlags: unknown | null
|
||||
intimate: unknown | null
|
||||
}
|
||||
|
||||
interface RelationFlags {
|
||||
@@ -241,7 +241,7 @@ interface CommonExt {
|
||||
address: string
|
||||
regTime: number
|
||||
interest: string
|
||||
labels: any[]
|
||||
labels: string[]
|
||||
qqLevel: QQLevel
|
||||
}
|
||||
|
||||
@@ -323,12 +323,12 @@ export interface UserDetailInfoByUin {
|
||||
regTime: number
|
||||
interest: string
|
||||
termType: number
|
||||
labels: any[]
|
||||
labels: unknown[]
|
||||
qqLevel: { crownNum: number, sunNum: number, moonNum: number, starNum: number }
|
||||
isHideQQLevel: number
|
||||
privilegeIcon: { jumpUrl: string, openIconList: any[], closeIconList: any[] }
|
||||
privilegeIcon: { jumpUrl: string, openIconList: unknown[], closeIconList: unknown[] }
|
||||
isHidePrivilegeIcon: number
|
||||
photoWall: { picList: any[] }
|
||||
photoWall: { picList: unknown[] }
|
||||
vipFlag: boolean
|
||||
yearVipFlag: boolean
|
||||
svipFlag: boolean
|
||||
|
@@ -16,7 +16,6 @@ import { Dict } from 'cosmokit'
|
||||
const Process = require('node:process')
|
||||
|
||||
export interface NodeIQQNTWrapperSession {
|
||||
[key: string]: any
|
||||
getBuddyService(): NodeIKernelBuddyService
|
||||
getGroupService(): NodeIKernelGroupService
|
||||
getProfileService(): NodeIKernelProfileService
|
||||
@@ -36,19 +35,6 @@ export interface WrapperApi {
|
||||
|
||||
export interface WrapperConstructor {
|
||||
[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 = {}
|
||||
@@ -75,9 +61,9 @@ Process.dlopenOrig = Process.dlopen
|
||||
|
||||
Process.dlopen = function (module: Dict, filename: string, flags = constants.dlopen.RTLD_LAZY) {
|
||||
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], {
|
||||
construct: (target, args, _newTarget) => {
|
||||
construct: (target, args) => {
|
||||
const ret = new target(...args)
|
||||
if (export_name === 'NodeIQQNTWrapperSession') wrapperApi.NodeIQQNTWrapperSession = ret
|
||||
return ret
|
||||
|
@@ -26,13 +26,13 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
|
||||
try {
|
||||
const resData = await this._handle(payload)
|
||||
return OB11Response.ok(resData)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('发生错误', e)
|
||||
return OB11Response.error(e?.toString() || e?.stack?.toString() || '未知错误,可能操作超时', 200)
|
||||
return OB11Response.error(e?.toString() || (e as Error)?.stack?.toString() || '未知错误,可能操作超时', 200)
|
||||
}
|
||||
}
|
||||
|
||||
public async websocketHandle(payload: PayloadType, echo: any): Promise<OB11Return<ReturnDataType | null>> {
|
||||
public async websocketHandle(payload: PayloadType, echo: unknown): Promise<OB11Return<ReturnDataType | null>> {
|
||||
const result = await this.check(payload)
|
||||
if (!result.valid) {
|
||||
return OB11Response.error(result.message, 1400)
|
||||
@@ -40,9 +40,9 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
|
||||
try {
|
||||
const resData = await this._handle(payload)
|
||||
return OB11Response.ok(resData, echo)
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('发生错误', e)
|
||||
return OB11Response.error(e.stack?.toString() || e.toString(), 1200, echo)
|
||||
return OB11Response.error((e as Error)?.stack?.toString() || String(e), 1200, echo)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,16 +13,16 @@ export class OB11Response {
|
||||
}
|
||||
}
|
||||
|
||||
static ok<T>(data: T, echo: any = null) {
|
||||
let res = OB11Response.res<T>(data, 'ok', 0)
|
||||
static ok<T>(data: T, echo?: unknown) {
|
||||
const res = OB11Response.res<T>(data, 'ok', 0)
|
||||
if (!isNullable(echo)) {
|
||||
res.echo = echo
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
static error(err: string, retcode: number, echo: any = null) {
|
||||
let res = OB11Response.res(null, 'failed', retcode, err)
|
||||
static error(err: string, retcode: number, echo?: unknown) {
|
||||
const res = OB11Response.res(null, 'failed', retcode, err)
|
||||
if (!isNullable(echo)) {
|
||||
res.echo = echo
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import BaseAction from '../BaseAction'
|
||||
import fsPromise from 'node:fs/promises'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import { ActionName } from '../types'
|
||||
import { Peer, ElementType } from '@/ntqqapi/types'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
@@ -20,7 +19,7 @@ export interface GetFileResponse {
|
||||
export abstract class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/onebot11/action/file/GetFile.ts#L44
|
||||
protected async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||
const { enableLocalFile2Url } = getConfigUtil().getConfig()
|
||||
const { enableLocalFile2Url } = this.adapter.config
|
||||
|
||||
let fileCache = await MessageUnique.getFileCacheById(String(payload.file))
|
||||
if (!fileCache?.length) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { GetFileBase, GetFilePayload, GetFileResponse } from './GetFile'
|
||||
import { ActionName } from '../types'
|
||||
import { decodeSilk } from '@/common/utils/audio'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
@@ -13,11 +12,11 @@ export default class GetRecord extends GetFileBase {
|
||||
actionName = ActionName.GetRecord
|
||||
|
||||
protected async _handle(payload: Payload): Promise<GetFileResponse> {
|
||||
let res = await super._handle(payload)
|
||||
const res = await super._handle(payload)
|
||||
res.file = await decodeSilk(this.ctx, res.file!, payload.out_format)
|
||||
res.file_name = path.basename(res.file)
|
||||
res.file_size = fs.statSync(res.file).size.toString()
|
||||
if (getConfigUtil().getConfig().enableLocalFile2Url) {
|
||||
if (this.adapter.config.enableLocalFile2Url) {
|
||||
res.base64 = fs.readFileSync(res.file, 'base64')
|
||||
}
|
||||
return res
|
||||
|
@@ -6,10 +6,10 @@ interface Payload {
|
||||
message_id: number | string
|
||||
}
|
||||
|
||||
export class DelEssenceMsg extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_DelEssenceMsg;
|
||||
export class DelEssenceMsg extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GoCQHTTP_DelEssenceMsg
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('message_id不能为空')
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseAction from '../BaseAction'
|
||||
import { OB11ForwardMessage, OB11Message, OB11MessageData } from '../../types'
|
||||
import { OB11ForwardMessage } from '../../types'
|
||||
import { OB11Entities } from '../../entities'
|
||||
import { ActionName } from '../types'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
@@ -10,12 +10,12 @@ interface Payload {
|
||||
}
|
||||
|
||||
interface Response {
|
||||
messages: (OB11Message & { content: OB11MessageData })[]
|
||||
messages: OB11ForwardMessage[]
|
||||
}
|
||||
|
||||
export class GetForwardMsg extends BaseAction<Payload, Response> {
|
||||
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
const msgId = payload.id || payload.message_id
|
||||
if (!msgId) {
|
||||
throw Error('message_id不能为空')
|
||||
@@ -36,15 +36,16 @@ export class GetForwardMsg extends BaseAction<Payload, Response> {
|
||||
resMsg.message_id = MessageUnique.createMsg({
|
||||
chatType: msg.chatType,
|
||||
peerUid: msg.peerUid,
|
||||
}, msg.msgId)!
|
||||
}, msg.msgId)
|
||||
return resMsg
|
||||
}),
|
||||
)
|
||||
messages.map(v => {
|
||||
const forwardMessages = messages.map(v => {
|
||||
const msg = v as Partial<OB11ForwardMessage>
|
||||
msg.content = msg.message
|
||||
delete msg.message
|
||||
return msg as OB11ForwardMessage
|
||||
})
|
||||
return { messages }
|
||||
return { messages: forwardMessages }
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ interface Response {
|
||||
export class GetGroupSystemMsg extends BaseAction<void, Response> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupSystemMsg
|
||||
|
||||
async _handle(payload: void) {
|
||||
async _handle() {
|
||||
const singleScreenNotifies = await this.ctx.ntGroupApi.getSingleScreenNotifies(10)
|
||||
const data: Response = { invited_requests: [], join_requests: [] }
|
||||
for (const notify of singleScreenNotifies) {
|
||||
|
@@ -8,7 +8,7 @@ interface Payload {
|
||||
export class MarkMsgAsRead extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
protected async _handle() {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
37
src/onebot11/action/go-cqhttp/SendGroupNotice.ts
Normal file
37
src/onebot11/action/go-cqhttp/SendGroupNotice.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
group_id: number | string
|
||||
content: string
|
||||
image?: string
|
||||
pinned?: number | string //扩展
|
||||
confirm_required?: number | string //扩展
|
||||
}
|
||||
|
||||
export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_SendGroupNotice
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const type = 1
|
||||
const isShowEditCard = 0
|
||||
const tipWindowType = 0
|
||||
const pinned = Number(payload.pinned ?? 0)
|
||||
const confirmRequired = Number(payload.confirm_required ?? 1)
|
||||
|
||||
const result = await this.ctx.ntWebApi.setGroupNotice({
|
||||
groupCode: payload.group_id.toString(),
|
||||
content: payload.content,
|
||||
pinned,
|
||||
type,
|
||||
isShowEditCard,
|
||||
tipWindowType,
|
||||
confirmRequired,
|
||||
picId: ''
|
||||
})
|
||||
if (result.ec !== 0) {
|
||||
throw new Error(`设置群公告失败, 错误信息: ${result.em}`)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
@@ -6,10 +6,10 @@ interface Payload {
|
||||
message_id: number | string
|
||||
}
|
||||
|
||||
export class SetEssenceMsg extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_SetEssenceMsg;
|
||||
export class SetEssenceMsg extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GoCQHTTP_SetEssenceMsg
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
if (!payload.message_id) {
|
||||
throw Error('message_id不能为空')
|
||||
}
|
||||
|
@@ -2,24 +2,22 @@ import fs from 'node:fs'
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
import { SendElementEntities } from '@/ntqqapi/entities'
|
||||
import { ChatType, SendFileElement } from '@/ntqqapi/types'
|
||||
import { SendFileElement } from '@/ntqqapi/types'
|
||||
import { uri2local } from '@/common/utils'
|
||||
import { Peer } from '@/ntqqapi/types'
|
||||
import { sendMsg } from '../../helper/createMessage'
|
||||
import { sendMsg, createPeer, CreatePeerMode } from '../../helper/createMessage'
|
||||
|
||||
interface Payload {
|
||||
user_id: number | string
|
||||
group_id?: number | string
|
||||
interface UploadGroupFilePayload {
|
||||
group_id: number | string
|
||||
file: string
|
||||
name: string
|
||||
folder?: string
|
||||
folder_id?: string
|
||||
}
|
||||
|
||||
export class UploadGroupFile extends BaseAction<Payload, null> {
|
||||
export class UploadGroupFile extends BaseAction<UploadGroupFilePayload, null> {
|
||||
actionName = ActionName.GoCQHTTP_UploadGroupFile
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
protected async _handle(payload: UploadGroupFilePayload): Promise<null> {
|
||||
let file = payload.file
|
||||
if (fs.existsSync(file)) {
|
||||
file = `file://${file}`
|
||||
@@ -29,31 +27,23 @@ export class UploadGroupFile extends BaseAction<Payload, null> {
|
||||
throw new Error(downloadResult.errMsg)
|
||||
}
|
||||
const sendFileEle = await SendElementEntities.file(this.ctx, downloadResult.path, payload.name, payload.folder_id)
|
||||
await sendMsg(this.ctx, {
|
||||
chatType: ChatType.group,
|
||||
peerUid: payload.group_id?.toString()!,
|
||||
}, [sendFileEle], [], true)
|
||||
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Group)
|
||||
await sendMsg(this.ctx, peer, [sendFileEle], [], true)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export class UploadPrivateFile extends BaseAction<Payload, null> {
|
||||
interface UploadPrivateFilePayload {
|
||||
user_id: number | string
|
||||
file: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export class UploadPrivateFile extends BaseAction<UploadPrivateFilePayload, null> {
|
||||
actionName = ActionName.GoCQHTTP_UploadPrivateFile
|
||||
|
||||
async getPeer(payload: Payload): Promise<Peer> {
|
||||
if (payload.user_id) {
|
||||
const peerUid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!peerUid) {
|
||||
throw `私聊${payload.user_id}不存在`
|
||||
}
|
||||
const isBuddy = await this.ctx.ntFriendApi.isBuddy(peerUid)
|
||||
return { chatType: isBuddy ? ChatType.friend : ChatType.temp, peerUid }
|
||||
}
|
||||
throw '缺少参数 user_id'
|
||||
}
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const peer = await this.getPeer(payload)
|
||||
protected async _handle(payload: UploadPrivateFilePayload): Promise<null> {
|
||||
const peer = await createPeer(this.ctx, payload, CreatePeerMode.Private)
|
||||
let file = payload.file
|
||||
if (fs.existsSync(file)) {
|
||||
file = `file://${file}`
|
||||
|
@@ -10,7 +10,7 @@ interface PayloadType {
|
||||
export class GetGroupEssence extends BaseAction<PayloadType, GroupEssenceMsgRet | void> {
|
||||
actionName = ActionName.GoCQHTTP_GetEssenceMsg
|
||||
|
||||
protected async _handle(payload: PayloadType) {
|
||||
protected async _handle() {
|
||||
throw '此 api 暂不支持'
|
||||
}
|
||||
}
|
||||
|
@@ -7,11 +7,10 @@ interface Payload {
|
||||
type?: WebHonorType
|
||||
}
|
||||
|
||||
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
||||
export class GetGroupHonorInfo extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.GetGroupHonorInfo
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
// console.log(await NTQQUserApi.getRobotUinRange())
|
||||
if (!payload.group_id) {
|
||||
throw '缺少参数group_id'
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import { ActionName } from '../types'
|
||||
export default class GetGuildList extends BaseAction<null, null> {
|
||||
actionName = ActionName.GetGuildList
|
||||
|
||||
protected async _handle(payload: null): Promise<null> {
|
||||
protected async _handle() {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@@ -6,10 +6,10 @@ interface Payload {
|
||||
is_dismiss: boolean
|
||||
}
|
||||
|
||||
export default class SetGroupLeave extends BaseAction<Payload, any> {
|
||||
export default class SetGroupLeave extends BaseAction<Payload, void> {
|
||||
actionName = ActionName.SetGroupLeave
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
try {
|
||||
await this.ctx.ntGroupApi.quitGroup(payload.group_id.toString())
|
||||
} catch (e) {
|
||||
|
@@ -60,6 +60,8 @@ import { CreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder'
|
||||
import { DelGroupFolder } from './go-cqhttp/DelGroupFolder'
|
||||
import { GetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain'
|
||||
import { GetGroupRootFiles } from './go-cqhttp/GetGroupRootFiles'
|
||||
import { SetOnlineStatus } from './llonebot/SetOnlineStatus'
|
||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice'
|
||||
|
||||
export function initActionMap(adapter: Adapter) {
|
||||
const actionHandlers = [
|
||||
@@ -71,6 +73,7 @@ export function initActionMap(adapter: Adapter) {
|
||||
new SetQQAvatar(adapter),
|
||||
new GetFriendWithCategory(adapter),
|
||||
new GetEvent(adapter),
|
||||
new SetOnlineStatus(adapter),
|
||||
// onebot11
|
||||
new SendLike(adapter),
|
||||
new GetMsg(adapter),
|
||||
@@ -126,9 +129,10 @@ export function initActionMap(adapter: Adapter) {
|
||||
new CreateGroupFileFolder(adapter),
|
||||
new DelGroupFolder(adapter),
|
||||
new GetGroupAtAllRemain(adapter),
|
||||
new GetGroupRootFiles(adapter)
|
||||
new GetGroupRootFiles(adapter),
|
||||
new SendGroupNotice(adapter)
|
||||
]
|
||||
const actionMap = new Map<string, BaseAction<any, any>>()
|
||||
const actionMap = new Map<string, BaseAction<unknown, unknown>>()
|
||||
for (const action of actionHandlers) {
|
||||
actionMap.set(action.actionName, action)
|
||||
actionMap.set(action.actionName + '_async', action)
|
||||
|
@@ -5,13 +5,15 @@ import { getConfigUtil } from '@/common/config'
|
||||
|
||||
export class GetConfigAction extends BaseAction<null, Config> {
|
||||
actionName = ActionName.GetConfig
|
||||
protected async _handle(payload: null): Promise<Config> {
|
||||
|
||||
protected async _handle(): Promise<Config> {
|
||||
return getConfigUtil().getConfig()
|
||||
}
|
||||
}
|
||||
|
||||
export class SetConfigAction extends BaseAction<Config, void> {
|
||||
actionName = ActionName.SetConfig
|
||||
|
||||
protected async _handle(payload: Config): Promise<void> {
|
||||
getConfigUtil().setConfig(payload)
|
||||
}
|
||||
|
@@ -3,13 +3,13 @@ import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
method: string
|
||||
args: any[]
|
||||
args: unknown[]
|
||||
}
|
||||
|
||||
export default class Debug extends BaseAction<Payload, any> {
|
||||
export default class Debug extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.Debug
|
||||
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
protected async _handle(payload: Payload) {
|
||||
this.ctx.logger.info('debug call ntqq api', payload)
|
||||
const { ntMsgApi, ntFileApi, ntFileCacheApi, ntFriendApi, ntGroupApi, ntUserApi, ntWindowApi } = this.ctx
|
||||
const ntqqApi = [ntMsgApi, ntFriendApi, ntGroupApi, ntUserApi, ntFileApi, ntFileCacheApi, ntWindowApi]
|
||||
|
@@ -13,13 +13,14 @@ interface Payload {
|
||||
|
||||
export default class GetEvent extends BaseAction<Payload, PostEventType[]> {
|
||||
actionName = ActionName.GetEvent
|
||||
|
||||
protected async _handle(payload: Payload): Promise<PostEventType[]> {
|
||||
let key = ''
|
||||
if (payload.key) {
|
||||
key = payload.key
|
||||
}
|
||||
let timeout = parseInt(payload.timeout?.toString()) || 0
|
||||
let evts = await getHttpEvent(key, timeout)
|
||||
const timeout = parseInt(payload.timeout?.toString()) || 0
|
||||
const evts = await getHttpEvent(key, timeout)
|
||||
return evts
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ interface OB11GroupRequestNotify {
|
||||
export default class GetGroupAddRequest extends BaseAction<null, OB11GroupRequestNotify[]> {
|
||||
actionName = ActionName.GetGroupIgnoreAddRequest
|
||||
|
||||
protected async _handle(payload: null): Promise<OB11GroupRequestNotify[]> {
|
||||
protected async _handle(): Promise<OB11GroupRequestNotify[]> {
|
||||
const data = await this.ctx.ntGroupApi.getGroupIgnoreNotifies()
|
||||
const notifies: GroupNotify[] = data.notifies.filter((notify) => notify.status === GroupNotifyStatus.KUNHANDLE)
|
||||
const returnData: OB11GroupRequestNotify[] = []
|
||||
|
25
src/onebot11/action/llonebot/SetOnlineStatus.ts
Normal file
25
src/onebot11/action/llonebot/SetOnlineStatus.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName } from '../types'
|
||||
|
||||
interface Payload {
|
||||
status: number | string
|
||||
ext_status: number | string
|
||||
battery_status: number | string
|
||||
}
|
||||
|
||||
export class SetOnlineStatus extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.SetOnlineStatus
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const ret = await this.ctx.ntUserApi.setSelfStatus(
|
||||
Number(payload.status),
|
||||
Number(payload.ext_status),
|
||||
Number(payload.battery_status),
|
||||
)
|
||||
if (ret.result !== 0) {
|
||||
this.ctx.logger.error(ret)
|
||||
throw new Error('设置在线状态失败')
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
@@ -13,53 +13,22 @@ import {
|
||||
OB11MessageNode,
|
||||
OB11PostSendMsg,
|
||||
} from '../../types'
|
||||
import fs from 'node:fs'
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName, BaseCheckResult } from '../types'
|
||||
import fs from 'node:fs'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import { CustomMusicSignPostData, IdMusicSignPostData, MusicSign, MusicSignPostData } from '@/common/utils/sign'
|
||||
import { Peer } from '@/ntqqapi/types/msg'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
import { convertMessage2List, createSendElements, sendMsg } from '../../helper/createMessage'
|
||||
import { convertMessage2List, createSendElements, sendMsg, createPeer, CreatePeerMode } from '../../helper/createMessage'
|
||||
|
||||
export interface ReturnDataType {
|
||||
interface ReturnData {
|
||||
message_id: number
|
||||
}
|
||||
|
||||
export enum ContextMode {
|
||||
Normal = 0,
|
||||
Private = 1,
|
||||
Group = 2
|
||||
}
|
||||
|
||||
export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnData> {
|
||||
actionName = ActionName.SendMsg
|
||||
|
||||
private async createContext(payload: OB11PostSendMsg, contextMode: ContextMode): Promise<Peer> {
|
||||
// This function determines the type of message by the existence of user_id / group_id,
|
||||
// not message_type.
|
||||
// This redundant design of Ob11 here should be blamed.
|
||||
|
||||
if ((contextMode === ContextMode.Group || contextMode === ContextMode.Normal) && payload.group_id) {
|
||||
return {
|
||||
chatType: ChatType.group,
|
||||
peerUid: payload.group_id.toString(),
|
||||
}
|
||||
}
|
||||
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
||||
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!uid) throw new Error('无法获取用户信息')
|
||||
const isBuddy = await this.ctx.ntFriendApi.isBuddy(uid)
|
||||
return {
|
||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||
peerUid: uid,
|
||||
guildId: isBuddy ? '' : payload.group_id?.toString() || ''
|
||||
}
|
||||
}
|
||||
throw new Error('请指定 group_id 或 user_id')
|
||||
}
|
||||
|
||||
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||
const messages = convertMessage2List(payload.message)
|
||||
const fmNum = this.getSpecialMsgNum(messages, OB11MessageDataType.node)
|
||||
@@ -76,21 +45,19 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
message: '音乐消息不可以和其他消息混在一起发送',
|
||||
}
|
||||
}
|
||||
if (payload.user_id && payload.message_type !== 'group') {
|
||||
}
|
||||
return {
|
||||
valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
protected async _handle(payload: OB11PostSendMsg) {
|
||||
let contextMode = ContextMode.Normal
|
||||
let contextMode = CreatePeerMode.Normal
|
||||
if (payload.message_type === 'group') {
|
||||
contextMode = ContextMode.Group
|
||||
contextMode = CreatePeerMode.Group
|
||||
} else if (payload.message_type === 'private') {
|
||||
contextMode = ContextMode.Private
|
||||
contextMode = CreatePeerMode.Private
|
||||
}
|
||||
const peer = await this.createContext(payload, contextMode)
|
||||
const peer = await createPeer(this.ctx, payload, contextMode)
|
||||
const messages = convertMessage2List(
|
||||
payload.message,
|
||||
payload.auto_escape === true || payload.auto_escape === 'true',
|
||||
@@ -98,15 +65,15 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (this.getSpecialMsgNum(messages, OB11MessageDataType.node)) {
|
||||
try {
|
||||
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[])
|
||||
return { message_id: returnMsg?.msgShortId! }
|
||||
} catch (e: any) {
|
||||
throw '发送转发消息失败 ' + e.toString()
|
||||
return { message_id: returnMsg.msgShortId! }
|
||||
} catch (e) {
|
||||
throw '发送转发消息失败 ' + e
|
||||
}
|
||||
}
|
||||
else if (this.getSpecialMsgNum(messages, OB11MessageDataType.music)) {
|
||||
const music = messages[0] as OB11MessageMusic
|
||||
if (music) {
|
||||
const { musicSignUrl } = getConfigUtil().getConfig()
|
||||
const { musicSignUrl } = this.adapter.config
|
||||
if (!musicSignUrl) {
|
||||
throw '音乐签名地址未配置'
|
||||
}
|
||||
@@ -175,26 +142,20 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
|
||||
private async cloneMsg(msg: RawMessage): Promise<RawMessage | undefined> {
|
||||
this.ctx.logger.info('克隆的目标消息', msg)
|
||||
let sendElements: SendMessageElement[] = []
|
||||
const sendElements: SendMessageElement[] = []
|
||||
for (const ele of msg.elements) {
|
||||
sendElements.push(ele as SendMessageElement)
|
||||
// Object.keys(ele).forEach((eleKey) => {
|
||||
// if (eleKey.endsWith("Element")) {
|
||||
// }
|
||||
}
|
||||
if (sendElements.length === 0) {
|
||||
this.ctx.logger.warn('需要clone的消息无法解析,将会忽略掉', msg)
|
||||
}
|
||||
this.ctx.logger.info('克隆消息', sendElements)
|
||||
try {
|
||||
const nodeMsg = await this.ctx.ntMsgApi.sendMsg(
|
||||
{
|
||||
chatType: ChatType.friend,
|
||||
peerUid: selfInfo.uid,
|
||||
},
|
||||
sendElements,
|
||||
true,
|
||||
)
|
||||
const peer = {
|
||||
chatType: ChatType.friend,
|
||||
peerUid: selfInfo.uid
|
||||
}
|
||||
const nodeMsg = await this.ctx.ntMsgApi.sendMsg(peer, sendElements)
|
||||
await this.ctx.sleep(400)
|
||||
return nodeMsg
|
||||
} catch (e) {
|
||||
@@ -212,7 +173,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
// 先判断一遍是不是id和自定义混用
|
||||
for (const messageNode of messageNodes) {
|
||||
// 一个node表示一个人的消息
|
||||
let nodeId = messageNode.data.id
|
||||
const nodeId = messageNode.data.id
|
||||
// 有nodeId表示一个子转发消息卡片
|
||||
if (nodeId) {
|
||||
const nodeMsg = await MessageUnique.getMsgIdAndPeerByShortId(+nodeId) || await MessageUnique.getPeerByMsgId(nodeId)
|
||||
@@ -232,7 +193,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
destPeer
|
||||
)
|
||||
this.ctx.logger.info('开始生成转发节点', sendElements)
|
||||
let sendElementsSplit: SendMessageElement[][] = []
|
||||
const sendElementsSplit: SendMessageElement[][] = []
|
||||
let splitIndex = 0
|
||||
for (const ele of sendElements) {
|
||||
if (!sendElementsSplit[splitIndex]) {
|
||||
|
@@ -7,7 +7,7 @@ interface Payload {
|
||||
emoji_id: number | string
|
||||
}
|
||||
|
||||
export class SetMsgEmojiLike extends BaseAction<Payload, any> {
|
||||
export class SetMsgEmojiLike extends BaseAction<Payload, unknown> {
|
||||
actionName = ActionName.SetMsgEmojiLike
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
|
@@ -8,7 +8,7 @@ interface ReturnType {
|
||||
export default class CanSendRecord extends BaseAction<any, ReturnType> {
|
||||
actionName = ActionName.CanSendRecord
|
||||
|
||||
protected async _handle(payload: void): Promise<ReturnType> {
|
||||
protected async _handle() {
|
||||
return {
|
||||
yes: true,
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import { selfInfo } from '@/common/globalVars'
|
||||
class GetLoginInfo extends BaseAction<null, OB11User> {
|
||||
actionName = ActionName.GetLoginInfo
|
||||
|
||||
protected async _handle(payload: null) {
|
||||
protected async _handle() {
|
||||
let nickname = selfInfo.nick
|
||||
try {
|
||||
nickname = await this.ctx.ntUserApi.getSelfNick(true)
|
||||
|
@@ -3,10 +3,10 @@ import { OB11Status } from '../../types'
|
||||
import { ActionName } from '../types'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
|
||||
export default class GetStatus extends BaseAction<any, OB11Status> {
|
||||
export default class GetStatus extends BaseAction<null, OB11Status> {
|
||||
actionName = ActionName.GetStatus
|
||||
|
||||
protected async _handle(payload: any): Promise<OB11Status> {
|
||||
protected async _handle(): Promise<OB11Status> {
|
||||
return {
|
||||
online: selfInfo.online!,
|
||||
good: true,
|
||||
|
@@ -3,10 +3,10 @@ import { OB11Version } from '../../types'
|
||||
import { ActionName } from '../types'
|
||||
import { version } from '../../../version'
|
||||
|
||||
export default class GetVersionInfo extends BaseAction<any, OB11Version> {
|
||||
export default class GetVersionInfo extends BaseAction<null, OB11Version> {
|
||||
actionName = ActionName.GetVersionInfo
|
||||
|
||||
protected async _handle(payload: any): Promise<OB11Version> {
|
||||
protected async _handle(): Promise<OB11Version> {
|
||||
return {
|
||||
app_name: 'LLOneBot',
|
||||
protocol_version: 'v11',
|
||||
|
@@ -2,15 +2,11 @@ export type BaseCheckResult = ValidCheckResult | InvalidCheckResult
|
||||
|
||||
export interface ValidCheckResult {
|
||||
valid: true
|
||||
|
||||
[k: string | number]: any
|
||||
}
|
||||
|
||||
export interface InvalidCheckResult {
|
||||
valid: false
|
||||
message: string
|
||||
|
||||
[k: string | number]: any
|
||||
}
|
||||
|
||||
export enum ActionName {
|
||||
@@ -23,6 +19,7 @@ export enum ActionName {
|
||||
GetFile = 'get_file',
|
||||
GetFriendsWithCategory = 'get_friends_with_category',
|
||||
GetEvent = 'get_event',
|
||||
SetOnlineStatus = 'set_online_status',
|
||||
// onebot 11
|
||||
SendLike = 'send_like',
|
||||
GetLoginInfo = 'get_login_info',
|
||||
@@ -78,5 +75,6 @@ export enum ActionName {
|
||||
GoCQHTTP_CreateGroupFileFolder = 'create_group_file_folder',
|
||||
GoCQHTTP_DelGroupFolder = 'delete_group_folder',
|
||||
GoCQHTTP_GetGroupAtAllRemain = 'get_group_at_all_remain',
|
||||
GoCQHTTP_GetGroupRootFiles = 'get_group_root_files'
|
||||
GoCQHTTP_GetGroupRootFiles = 'get_group_root_files',
|
||||
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
||||
}
|
||||
|
@@ -21,10 +21,10 @@ export class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
}
|
||||
|
||||
// extend
|
||||
export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
export class GetFriendWithCategory extends BaseAction<void, OB11User[]> {
|
||||
actionName = ActionName.GetFriendsWithCategory
|
||||
|
||||
protected async _handle(payload: void) {
|
||||
protected async _handle() {
|
||||
if (getBuildVersion() >= 26702) {
|
||||
//全新逻辑
|
||||
return OB11Entities.friendsV2(await this.ctx.ntFriendApi.getBuddyV2ExWithCate(true))
|
||||
|
@@ -35,7 +35,7 @@ declare module 'cordis' {
|
||||
}
|
||||
|
||||
class OneBot11Adapter extends Service {
|
||||
static inject = ['ntMsgApi', 'ntFileApi', 'ntFileCacheApi', 'ntFriendApi', 'ntGroupApi', 'ntUserApi', 'ntWindowApi']
|
||||
static inject = ['ntMsgApi', 'ntFileApi', 'ntFileCacheApi', 'ntFriendApi', 'ntGroupApi', 'ntUserApi', 'ntWindowApi', 'ntWebApi']
|
||||
|
||||
public messages: Map<string, RawMessage> = new Map()
|
||||
public startTime = 0
|
||||
@@ -50,7 +50,8 @@ class OneBot11Adapter extends Service {
|
||||
this.ob11Http = new OB11Http(ctx, {
|
||||
port: config.httpPort,
|
||||
token: config.token,
|
||||
actionMap
|
||||
actionMap,
|
||||
listenLocalhost: config.listenLocalhost
|
||||
})
|
||||
this.ob11HttpPost = new OB11HttpPost(ctx, {
|
||||
hosts: config.httpHosts,
|
||||
@@ -62,7 +63,8 @@ class OneBot11Adapter extends Service {
|
||||
port: config.wsPort,
|
||||
heartInterval: config.heartInterval,
|
||||
token: config.token,
|
||||
actionMap
|
||||
actionMap,
|
||||
listenLocalhost: config.listenLocalhost
|
||||
})
|
||||
this.ob11WebSocketReverseManager = new OB11WebSocketReverseManager(ctx, {
|
||||
hosts: config.wsHosts,
|
||||
@@ -110,10 +112,10 @@ class OneBot11Adapter extends Service {
|
||||
for (const notify of notifies) {
|
||||
try {
|
||||
const notifyTime = parseInt(notify.seq) / 1000
|
||||
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
|
||||
if (notifyTime < this.startTime) {
|
||||
continue
|
||||
}
|
||||
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
|
||||
if ([GroupNotifyType.MEMBER_LEAVE_NOTIFY_ADMIN, GroupNotifyType.KICK_MEMBER_NOTIFY_ADMIN].includes(notify.type)) {
|
||||
this.ctx.logger.info('有成员退出通知', notify)
|
||||
const member1Uin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
|
||||
@@ -170,14 +172,14 @@ class OneBot11Adapter extends Service {
|
||||
)
|
||||
this.dispatch(event)
|
||||
}
|
||||
} catch (e: any) {
|
||||
this.ctx.logger.error('解析群通知失败', e.stack)
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('解析群通知失败', (e as Error).stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleMsg(msgList: RawMessage[]) {
|
||||
for (let message of msgList) {
|
||||
for (const message of msgList) {
|
||||
// 过滤启动之前的消息
|
||||
if (parseInt(message.msgTime) < this.startTime / 1000) {
|
||||
continue
|
||||
@@ -292,7 +294,7 @@ class OneBot11Adapter extends Service {
|
||||
}
|
||||
}
|
||||
// HTTP 端口变化,重启服务
|
||||
if (config.ob11.httpPort !== old.httpPort) {
|
||||
if ((config.ob11.httpPort !== old.httpPort || config.ob11.listenLocalhost !== old.listenLocalhost) && config.ob11.enableHttp) {
|
||||
await this.ob11Http.stop()
|
||||
this.ob11Http.start()
|
||||
}
|
||||
@@ -305,7 +307,7 @@ class OneBot11Adapter extends Service {
|
||||
}
|
||||
}
|
||||
// 正向 WebSocket 端口变化,重启服务
|
||||
if (config.ob11.wsPort !== old.wsPort) {
|
||||
if ((config.ob11.wsPort !== old.wsPort || config.ob11.listenLocalhost !== old.listenLocalhost) && config.ob11.enableWs) {
|
||||
await this.ob11WebSocket.stop()
|
||||
this.ob11WebSocket.start()
|
||||
llonebotError.wsServerError = ''
|
||||
@@ -340,10 +342,13 @@ class OneBot11Adapter extends Service {
|
||||
Object.assign(this.config, {
|
||||
...config.ob11,
|
||||
heartInterval: config.heartInterval,
|
||||
token: config.token!,
|
||||
debug: config.debug!,
|
||||
reportSelfMessage: config.reportSelfMessage!,
|
||||
msgCacheExpire: config.msgCacheExpire!,
|
||||
token: config.token,
|
||||
debug: config.debug,
|
||||
reportSelfMessage: config.reportSelfMessage,
|
||||
msgCacheExpire: config.msgCacheExpire,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url,
|
||||
ffmpeg: config.ffmpeg
|
||||
})
|
||||
}
|
||||
|
||||
@@ -351,12 +356,12 @@ class OneBot11Adapter extends Service {
|
||||
for (const member of members) {
|
||||
const existMember = await this.ctx.ntGroupApi.getGroupMember(groupCode, member.uin)
|
||||
if (existMember) {
|
||||
if (member.cardName != existMember.cardName) {
|
||||
if (member.cardName !== existMember.cardName) {
|
||||
this.ctx.logger.info('群成员名片变动', `${groupCode}: ${existMember.uin}`, existMember.cardName, '->', member.cardName)
|
||||
this.dispatch(
|
||||
new OB11GroupCardEvent(parseInt(groupCode), parseInt(member.uin), member.cardName, existMember.cardName),
|
||||
)
|
||||
} else if (member.role != existMember.role) {
|
||||
} else if (member.role !== existMember.role) {
|
||||
this.ctx.logger.info('有管理员变动通知')
|
||||
const groupAdminNoticeEvent = new OB11GroupAdminNoticeEvent(
|
||||
member.role == GroupMemberRole.admin ? 'set' : 'unset',
|
||||
@@ -415,6 +420,9 @@ namespace OneBot11Adapter {
|
||||
debug: boolean
|
||||
reportSelfMessage: boolean
|
||||
msgCacheExpire: number
|
||||
musicSignUrl?: string
|
||||
enableLocalFile2Url: boolean
|
||||
ffmpeg?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import { handleQuickOperation, QuickOperationEvent } from '../helper/quickOperat
|
||||
import { OB11HeartbeatEvent } from '../event/meta/OB11HeartbeatEvent'
|
||||
import { Dict } from 'cosmokit'
|
||||
|
||||
type RegisterHandler = (res: Response, payload: any) => Promise<any>
|
||||
type RegisterHandler = (res: Response, payload: unknown) => Promise<unknown>
|
||||
|
||||
class OB11Http {
|
||||
private readonly expressAPP: Express
|
||||
@@ -51,13 +51,14 @@ class OB11Http {
|
||||
this.expressAPP.get('/', (req: Request, res: Response) => {
|
||||
res.send(`LLOneBot server 已启动`)
|
||||
})
|
||||
this.server = this.expressAPP.listen(this.config.port, '0.0.0.0', () => {
|
||||
this.ctx.logger.info(`HTTP server started 0.0.0.0:${this.config.port}`)
|
||||
const host = this.config.listenLocalhost ? '127.0.0.1' : '0.0.0.0'
|
||||
this.server = this.expressAPP.listen(this.config.port, host, () => {
|
||||
this.ctx.logger.info(`HTTP server started ${host}:${this.config.port}`)
|
||||
})
|
||||
llonebotError.httpServerError = ''
|
||||
} catch (e: any) {
|
||||
this.ctx.logger.error('HTTP服务启动失败', e.toString())
|
||||
llonebotError.httpServerError = 'HTTP服务启动失败, ' + e.toString()
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('HTTP服务启动失败', e)
|
||||
llonebotError.httpServerError = 'HTTP服务启动失败, ' + e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ class OB11Http {
|
||||
}
|
||||
|
||||
private authorize(req: Request, res: Response, next: () => void) {
|
||||
let serverToken = this.config.token
|
||||
const serverToken = this.config.token
|
||||
let clientToken = ''
|
||||
const authHeader = req.get('authorization')
|
||||
if (authHeader) {
|
||||
@@ -98,7 +99,7 @@ class OB11Http {
|
||||
this.ctx.logger.info('receive http url token', clientToken)
|
||||
}
|
||||
|
||||
if (serverToken && clientToken != serverToken) {
|
||||
if (serverToken && clientToken !== serverToken) {
|
||||
return res.status(403).send(JSON.stringify({ message: 'token verify failed!' }))
|
||||
}
|
||||
next()
|
||||
@@ -124,8 +125,8 @@ class OB11Http {
|
||||
this.ctx.logger.info('收到 HTTP 请求', url, payload)
|
||||
try {
|
||||
res.send(await handler(res, payload))
|
||||
} catch (e: any) {
|
||||
res.send(OB11Response.error(e.stack.toString(), 200))
|
||||
} catch (e) {
|
||||
res.send(OB11Response.error((e as Error).stack!.toString(), 200))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -135,7 +136,8 @@ namespace OB11Http {
|
||||
export interface Config {
|
||||
port: number
|
||||
token?: string
|
||||
actionMap: Map<string, BaseAction<any, any>>
|
||||
actionMap: Map<string, BaseAction<unknown, unknown>>
|
||||
listenLocalhost: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +190,7 @@ class OB11HttpPost {
|
||||
//log(`新消息事件HTTP上报没有返回快速操作,不需要处理`)
|
||||
}
|
||||
},
|
||||
(err: any) => {
|
||||
(err) => {
|
||||
this.ctx.logger.error(`HTTP 事件上报失败: ${host}`, err, event)
|
||||
},
|
||||
).catch(e => this.ctx.logger.error(e))
|
||||
|
@@ -21,12 +21,17 @@ class OB11WebSocket {
|
||||
|
||||
public start() {
|
||||
if (this.wsServer) return
|
||||
this.ctx.logger.info(`WebSocket server started 0.0.0.0:${this.config.port}`)
|
||||
const host = this.config.listenLocalhost ? '127.0.0.1' : '0.0.0.0'
|
||||
this.ctx.logger.info(`WebSocket server started ${host}:${this.config.port}`)
|
||||
try {
|
||||
this.wsServer = new WebSocketServer({ port: this.config.port, maxPayload: 1024 * 1024 * 1024 })
|
||||
this.wsServer = new WebSocketServer({
|
||||
host,
|
||||
port: this.config.port,
|
||||
maxPayload: 1024 * 1024 * 1024
|
||||
})
|
||||
llonebotError.wsServerError = ''
|
||||
} catch (e: any) {
|
||||
llonebotError.wsServerError = '正向 WebSocket 服务启动失败, ' + e.toString()
|
||||
} catch (e) {
|
||||
llonebotError.wsServerError = '正向 WebSocket 服务启动失败, ' + e
|
||||
return
|
||||
}
|
||||
this.wsServer?.on('connection', (socket, req) => {
|
||||
@@ -65,7 +70,7 @@ class OB11WebSocket {
|
||||
Object.assign(this.config, config)
|
||||
}
|
||||
|
||||
private reply(socket: WebSocket, data: OB11Return<any> | OB11BaseEvent | OB11Message) {
|
||||
private reply(socket: WebSocket, data: OB11Return<unknown> | OB11BaseEvent | OB11Message) {
|
||||
if (socket.readyState !== WebSocket.OPEN) {
|
||||
return
|
||||
}
|
||||
@@ -102,14 +107,14 @@ class OB11WebSocket {
|
||||
}
|
||||
|
||||
private async handleAction(socket: WebSocket, msg: string) {
|
||||
let receive: { action: ActionName | null; params: any; echo?: any } = { action: null, params: {} }
|
||||
let receive: { action: ActionName | null; params: unknown; echo?: unknown } = { action: null, params: {} }
|
||||
try {
|
||||
receive = JSON.parse(msg.toString())
|
||||
this.ctx.logger.info('收到正向 Websocket 消息', receive)
|
||||
} catch (e) {
|
||||
return this.reply(socket, OB11Response.error('json解析失败,请检查数据格式', 1400))
|
||||
}
|
||||
const action: BaseAction<any, any> = this.config.actionMap.get(receive.action!)!
|
||||
const action = this.config.actionMap.get(receive.action!)!
|
||||
if (!action) {
|
||||
return this.reply(socket, OB11Response.error('不支持的api ' + receive.action, 1404, receive.echo))
|
||||
}
|
||||
@@ -117,8 +122,8 @@ class OB11WebSocket {
|
||||
const handleResult = await action.websocketHandle(receive.params, receive.echo)
|
||||
handleResult.echo = receive.echo
|
||||
this.reply(socket, handleResult)
|
||||
} catch (e: any) {
|
||||
this.reply(socket, OB11Response.error(`api处理出错:${e.stack}`, 1200, receive.echo))
|
||||
} catch (e) {
|
||||
this.reply(socket, OB11Response.error(`api处理出错:${(e as Error).stack}`, 1200, receive.echo))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +169,8 @@ namespace OB11WebSocket {
|
||||
port: number
|
||||
heartInterval: number
|
||||
token?: string
|
||||
actionMap: Map<string, BaseAction<any, any>>
|
||||
actionMap: Map<string, BaseAction<unknown, unknown>>
|
||||
listenLocalhost: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +200,7 @@ class OB11WebSocketReverse {
|
||||
}
|
||||
}
|
||||
|
||||
private reply(socket: WebSocket, data: OB11Return<any> | OB11BaseEvent | OB11Message) {
|
||||
private reply(socket: WebSocket, data: OB11Return<unknown> | OB11BaseEvent | OB11Message) {
|
||||
if (socket.readyState !== WebSocket.OPEN) {
|
||||
return
|
||||
}
|
||||
@@ -205,19 +211,19 @@ class OB11WebSocketReverse {
|
||||
}
|
||||
|
||||
private async handleAction(msg: string) {
|
||||
let receive: { action: ActionName | null; params: any; echo?: any } = { action: null, params: {} }
|
||||
let receive: { action: ActionName | null; params: unknown; echo?: unknown } = { action: null, params: {} }
|
||||
try {
|
||||
receive = JSON.parse(msg.toString())
|
||||
this.ctx.logger.info('收到反向Websocket消息', receive)
|
||||
} catch (e) {
|
||||
return this.reply(this.wsClient!, OB11Response.error('json解析失败,请检查数据格式', 1400, receive.echo))
|
||||
}
|
||||
const action: BaseAction<any, any> = this.config.actionMap.get(receive.action!)!
|
||||
const action = this.config.actionMap.get(receive.action!)!
|
||||
if (!action) {
|
||||
return this.reply(this.wsClient!, OB11Response.error('不支持的api ' + receive.action, 1404, receive.echo))
|
||||
}
|
||||
try {
|
||||
let handleResult = await action.websocketHandle(receive.params, receive.echo)
|
||||
const handleResult = await action.websocketHandle(receive.params, receive.echo)
|
||||
this.reply(this.wsClient!, handleResult)
|
||||
} catch (e) {
|
||||
this.reply(this.wsClient!, OB11Response.error(`api处理出错:${e}`, 1200, receive.echo))
|
||||
@@ -281,7 +287,7 @@ namespace OB11WebSocketReverse {
|
||||
url: string
|
||||
heartInterval: number
|
||||
token?: string
|
||||
actionMap: Map<string, BaseAction<any, any>>
|
||||
actionMap: Map<string, BaseAction<unknown, unknown>>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,8 +312,8 @@ class OB11WebSocketReverseManager {
|
||||
for (const ws of this.list) {
|
||||
try {
|
||||
ws.stop()
|
||||
} catch (e: any) {
|
||||
this.ctx.logger.error('反向 WebSocket 关闭:', e.stack)
|
||||
} catch (e) {
|
||||
this.ctx.logger.error('反向 WebSocket 关闭:', (e as Error).stack)
|
||||
}
|
||||
}
|
||||
this.list.length = 0
|
||||
@@ -329,7 +335,7 @@ namespace OB11WebSocketReverseManager {
|
||||
hosts: string[]
|
||||
heartInterval: number
|
||||
token?: string
|
||||
actionMap: Map<string, BaseAction<any, any>>
|
||||
actionMap: Map<string, BaseAction<unknown, unknown>>
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ function from(source: string) {
|
||||
const capture = pattern.exec(source)
|
||||
if (!capture) return null
|
||||
const [, type, attrs] = capture
|
||||
const data: Record<string, any> = {}
|
||||
const data: Record<string, unknown> = {}
|
||||
attrs &&
|
||||
attrs
|
||||
.slice(1)
|
||||
@@ -22,7 +22,7 @@ function from(source: string) {
|
||||
return { type, data, capture }
|
||||
}
|
||||
|
||||
function h(type: string, data: any) {
|
||||
function h(type: string, data: unknown) {
|
||||
return {
|
||||
type,
|
||||
data,
|
||||
@@ -30,7 +30,7 @@ function h(type: string, data: any) {
|
||||
}
|
||||
|
||||
export function decodeCQCode(source: string): OB11MessageData[] {
|
||||
const elements: any[] = []
|
||||
const elements: unknown[] = []
|
||||
let result: ReturnType<typeof from>
|
||||
while ((result = from(source))) {
|
||||
const { type, data, capture } = result
|
||||
@@ -41,7 +41,7 @@ export function decodeCQCode(source: string): OB11MessageData[] {
|
||||
source = source.slice(capture.index + capture[0].length)
|
||||
}
|
||||
if (source) elements.push(h('text', { text: unescape(source) }))
|
||||
return elements
|
||||
return elements as OB11MessageData[]
|
||||
}
|
||||
|
||||
export function encodeCQCode(input: OB11MessageData) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import fastXmlParser from 'fast-xml-parser'
|
||||
import { XMLParser } from 'fast-xml-parser'
|
||||
import {
|
||||
OB11Group,
|
||||
OB11GroupMember,
|
||||
@@ -32,7 +32,6 @@ import { OB11GroupBanEvent } from './event/notice/OB11GroupBanEvent'
|
||||
import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNoticeEvent'
|
||||
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
||||
import { calcQQLevel } from '../common/utils/misc'
|
||||
import { getConfigUtil } from '../common/config'
|
||||
import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent'
|
||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'
|
||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
|
||||
@@ -43,18 +42,18 @@ import { OB11GroupRecallNoticeEvent } from './event/notice/OB11GroupRecallNotice
|
||||
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
|
||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'
|
||||
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'
|
||||
import { omit, isNullable } from 'cosmokit'
|
||||
import { omit, isNullable, pick, Dict } from 'cosmokit'
|
||||
import { Context } from 'cordis'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import OneBot11Adapter from './adapter'
|
||||
|
||||
export namespace OB11Entities {
|
||||
export async function message(ctx: Context, msg: RawMessage): Promise<OB11Message> {
|
||||
let config = getConfigUtil().getConfig()
|
||||
const {
|
||||
debug,
|
||||
ob11: { messagePostFormat },
|
||||
} = config
|
||||
messagePostFormat,
|
||||
} = ctx.config as OneBot11Adapter.Config
|
||||
const selfUin = selfInfo.uin
|
||||
const resMsg: OB11Message = {
|
||||
self_id: parseInt(selfUin),
|
||||
@@ -67,7 +66,7 @@ export namespace OB11Entities {
|
||||
sender: {
|
||||
user_id: parseInt(msg.senderUin!),
|
||||
nickname: msg.sendNickName,
|
||||
card: msg.sendMemberName || '',
|
||||
card: msg.sendMemberName ?? '',
|
||||
},
|
||||
raw_message: '',
|
||||
font: 14,
|
||||
@@ -79,32 +78,33 @@ export namespace OB11Entities {
|
||||
if (debug) {
|
||||
resMsg.raw = msg
|
||||
}
|
||||
if (msg.chatType == ChatType.group) {
|
||||
if (msg.chatType === ChatType.group) {
|
||||
resMsg.sub_type = 'normal'
|
||||
resMsg.group_id = parseInt(msg.peerUin)
|
||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUin, msg.senderUin!)
|
||||
if (member) {
|
||||
resMsg.sender.role = groupMemberRole(member.role)
|
||||
resMsg.sender.nickname = member.nick
|
||||
resMsg.sender.title = member.memberSpecialTitle ?? ''
|
||||
}
|
||||
}
|
||||
else if (msg.chatType == ChatType.friend) {
|
||||
else if (msg.chatType === ChatType.friend) {
|
||||
resMsg.sub_type = 'friend'
|
||||
resMsg.sender.nickname = (await ctx.ntUserApi.getUserDetailInfo(msg.senderUid)).nick
|
||||
}
|
||||
else if (msg.chatType as unknown as ChatType2 == ChatType2.KCHATTYPETEMPC2CFROMGROUP) {
|
||||
else if (msg.chatType as unknown as ChatType2 === ChatType2.KCHATTYPETEMPC2CFROMGROUP) {
|
||||
resMsg.sub_type = 'group'
|
||||
resMsg.temp_source = 0 //群聊
|
||||
resMsg.sender.nickname = (await ctx.ntUserApi.getUserDetailInfo(msg.senderUid)).nick
|
||||
const ret = await ctx.ntMsgApi.getTempChatInfo(ChatType2.KCHATTYPETEMPC2CFROMGROUP, msg.senderUid)
|
||||
if (ret?.result === 0) {
|
||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode)
|
||||
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick
|
||||
resMsg.sender.group_id = Number(ret.tmpChatInfo?.groupCode)
|
||||
} else {
|
||||
resMsg.group_id = 284840486 //兜底数据
|
||||
resMsg.sender.nickname = '临时会话'
|
||||
resMsg.sender.group_id = 284840486 //兜底数据
|
||||
}
|
||||
}
|
||||
|
||||
for (let element of msg.elements) {
|
||||
for (const element of msg.elements) {
|
||||
let messageSegment: OB11MessageData | undefined
|
||||
if (element.textElement && element.textElement?.atType !== AtType.notAt) {
|
||||
let qq: string
|
||||
@@ -154,15 +154,18 @@ export namespace OB11Entities {
|
||||
guildId: ''
|
||||
}
|
||||
try {
|
||||
const { replayMsgSeq, replyMsgTime, senderUidStr } = replyElement
|
||||
const records = msg.records.find(msgRecord => msgRecord.msgId === replyElement.sourceMsgIdInRecords)
|
||||
if (!records) throw new Error('找不到回复消息')
|
||||
let replyMsg = (await ctx.ntMsgApi.getMsgsBySeqAndCount(peer, replyElement.replayMsgSeq, 1, true, true)).msgList[0]
|
||||
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
||||
replyMsg = (await ctx.ntMsgApi.getSingleMsg(peer, replyElement.replayMsgSeq)).msgList[0]
|
||||
if (!records || !replyMsgTime || !senderUidStr) {
|
||||
throw new Error('找不到回复消息')
|
||||
}
|
||||
const { msgList } = await ctx.ntMsgApi.queryMsgsWithFilterExBySeq(peer, replayMsgSeq, replyMsgTime, [senderUidStr])
|
||||
const replyMsg = msgList.find(msg => msg.msgRandom === records.msgRandom)
|
||||
|
||||
// 284840486: 合并消息内侧 消息具体定位不到
|
||||
if ((!replyMsg || records.msgRandom !== replyMsg.msgRandom) && msg.peerUin !== '284840486') {
|
||||
throw new Error('回复消息消息验证失败')
|
||||
if (!replyMsg && msg.peerUin !== '284840486') {
|
||||
ctx.logger.info('queryMsgs', msgList.map(e => pick(e, ['msgSeq', 'msgRandom'])))
|
||||
throw new Error('回复消息验证失败')
|
||||
}
|
||||
messageSegment = {
|
||||
type: OB11MessageDataType.reply,
|
||||
@@ -171,7 +174,7 @@ export namespace OB11Entities {
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
ctx.logger.error('获取不到引用的消息', replyElement.replayMsgSeq, e.stack)
|
||||
ctx.logger.error('获取不到引用的消息', replyElement, e.stack)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -402,7 +405,7 @@ export namespace OB11Entities {
|
||||
return
|
||||
}
|
||||
if (msg.senderUin) {
|
||||
let member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin)
|
||||
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin)
|
||||
if (member && member.cardName !== msg.sendMemberName) {
|
||||
const event = new OB11GroupCardEvent(
|
||||
parseInt(msg.peerUid),
|
||||
@@ -414,12 +417,10 @@ export namespace OB11Entities {
|
||||
return event
|
||||
}
|
||||
}
|
||||
// log("group msg", msg)
|
||||
for (let element of msg.elements) {
|
||||
for (const element of msg.elements) {
|
||||
const grayTipElement = element.grayTipElement
|
||||
const groupElement = grayTipElement?.groupElement
|
||||
if (groupElement) {
|
||||
// log("收到群提示消息", groupElement)
|
||||
if (groupElement.type === TipGroupElementType.memberIncrease) {
|
||||
ctx.logger.info('收到群成员增加消息', groupElement)
|
||||
await ctx.sleep(1000)
|
||||
@@ -428,14 +429,10 @@ export namespace OB11Entities {
|
||||
if (!memberUin) {
|
||||
memberUin = (await ctx.ntUserApi.getUserDetailInfo(groupElement.memberUid)).uin
|
||||
}
|
||||
// log("获取新群成员QQ", memberUin)
|
||||
const adminMember = await ctx.ntGroupApi.getGroupMember(msg.peerUid, groupElement.adminUid)
|
||||
// log("获取同意新成员入群的管理员", adminMember)
|
||||
if (memberUin) {
|
||||
const operatorUin = adminMember?.uin || memberUin
|
||||
let event = new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(operatorUin))
|
||||
// log("构造群增加事件", event)
|
||||
return event
|
||||
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(memberUin), parseInt(operatorUin))
|
||||
}
|
||||
}
|
||||
else if (groupElement.type === TipGroupElementType.ban) {
|
||||
@@ -443,8 +440,8 @@ export namespace OB11Entities {
|
||||
const memberUid = groupElement.shutUp?.member.uid
|
||||
const adminUid = groupElement.shutUp?.admin.uid
|
||||
let memberUin: string = ''
|
||||
let duration = parseInt(groupElement.shutUp?.duration!)
|
||||
let sub_type: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban'
|
||||
let duration = Number(groupElement.shutUp?.duration)
|
||||
const subType = duration > 0 ? 'ban' : 'lift_ban'
|
||||
if (memberUid) {
|
||||
memberUin =
|
||||
(await ctx.ntGroupApi.getGroupMember(msg.peerUid, memberUid))?.uin ||
|
||||
@@ -464,7 +461,7 @@ export namespace OB11Entities {
|
||||
parseInt(memberUin),
|
||||
parseInt(adminUin),
|
||||
duration,
|
||||
sub_type,
|
||||
subType,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -512,38 +509,36 @@ export namespace OB11Entities {
|
||||
// <url jp= \"\" msgseq=\"74711\" col=\"3\" txt=\"消息:\"/>
|
||||
// <face type=\"1\" id=\"76\"> </face>
|
||||
// </gtip>",
|
||||
const emojiLikeData = new fastXmlParser.XMLParser({
|
||||
const emojiLikeData = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: '',
|
||||
}).parse(xmlElement.content)
|
||||
ctx.logger.info('收到表情回应我的消息', emojiLikeData)
|
||||
try {
|
||||
const senderUin = emojiLikeData.gtip.qq.jp
|
||||
const msgSeq = emojiLikeData.gtip.url.msgseq
|
||||
const emojiId = emojiLikeData.gtip.face.id
|
||||
const replyMsgList = (await ctx.ntMsgApi.getMsgsBySeqAndCount({
|
||||
const senderUin: string = emojiLikeData.gtip.qq.jp
|
||||
const msgSeq: string = emojiLikeData.gtip.url.msgseq
|
||||
const emojiId: string = emojiLikeData.gtip.face.id
|
||||
const peer = {
|
||||
chatType: ChatType.group,
|
||||
guildId: '',
|
||||
peerUid: msg.peerUid,
|
||||
}, msgSeq, 1, true, true))?.msgList
|
||||
}
|
||||
const replyMsgList = (await ctx.ntMsgApi.queryFirstMsgBySeq(peer, msgSeq)).msgList
|
||||
if (!replyMsgList?.length) {
|
||||
return
|
||||
}
|
||||
const likes = [
|
||||
{
|
||||
emoji_id: emojiId,
|
||||
count: 1,
|
||||
},
|
||||
]
|
||||
const shortId = MessageUnique.getShortIdByMsgId(replyMsgList[0].msgId)
|
||||
return new OB11GroupMsgEmojiLikeEvent(
|
||||
parseInt(msg.peerUid),
|
||||
parseInt(senderUin),
|
||||
shortId!,
|
||||
likes
|
||||
[{
|
||||
emoji_id: emojiId,
|
||||
count: 1,
|
||||
}]
|
||||
)
|
||||
} catch (e: any) {
|
||||
ctx.logger.error('解析表情回应消息失败', e.stack)
|
||||
} catch (e) {
|
||||
ctx.logger.error('解析表情回应消息失败', (e as Error).stack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,14 +592,14 @@ export namespace OB11Entities {
|
||||
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||
//判断业务类型
|
||||
//Poke事件
|
||||
const pokedetail: any[] = json.items
|
||||
const pokedetail: Dict[] = json.items
|
||||
//筛选item带有uid的元素
|
||||
const poke_uid = pokedetail.filter(item => item.uid)
|
||||
if (poke_uid.length == 2) {
|
||||
return new OB11GroupPokeEvent(
|
||||
parseInt(msg.peerUid),
|
||||
parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[0].uid)),
|
||||
parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[1].uid)),
|
||||
parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[0].uid) ?? 0),
|
||||
parseInt(await ctx.ntUserApi.getUinByUid(poke_uid[1].uid) ?? 0),
|
||||
pokedetail
|
||||
)
|
||||
}
|
||||
@@ -768,6 +763,8 @@ export namespace OB11Entities {
|
||||
return {
|
||||
group_id: parseInt(group.groupCode),
|
||||
group_name: group.groupName,
|
||||
group_memo: group.remarkName,
|
||||
group_create_time: +group.createTime,
|
||||
member_count: group.memberCount,
|
||||
max_member_count: group.maxMember,
|
||||
}
|
||||
|
@@ -5,14 +5,13 @@ abstract class OB11PokeEvent extends OB11BaseNoticeEvent {
|
||||
sub_type = 'poke'
|
||||
target_id = 0
|
||||
abstract user_id: number
|
||||
raw_message: any
|
||||
}
|
||||
|
||||
export class OB11FriendPokeEvent extends OB11PokeEvent {
|
||||
user_id: number
|
||||
raw_info: any
|
||||
raw_info: unknown
|
||||
|
||||
constructor(user_id: number, target_id: number, raw_message: any) {
|
||||
constructor(user_id: number, target_id: number, raw_message: unknown) {
|
||||
super()
|
||||
this.target_id = target_id
|
||||
this.user_id = user_id
|
||||
@@ -24,9 +23,9 @@ export class OB11FriendPokeEvent extends OB11PokeEvent {
|
||||
export class OB11GroupPokeEvent extends OB11PokeEvent {
|
||||
user_id: number
|
||||
group_id: number
|
||||
raw_info: any
|
||||
raw_info: unknown
|
||||
|
||||
constructor(group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) {
|
||||
constructor(group_id: number, user_id: number, target_id: number, raw_message: unknown) {
|
||||
super()
|
||||
this.group_id = group_id
|
||||
this.target_id = target_id
|
||||
|
@@ -27,9 +27,9 @@ export async function createSendElements(
|
||||
peer: Peer,
|
||||
ignoreTypes: OB11MessageDataType[] = [],
|
||||
) {
|
||||
let sendElements: SendMessageElement[] = []
|
||||
let deleteAfterSentFiles: string[] = []
|
||||
for (let sendMsg of messageData) {
|
||||
const sendElements: SendMessageElement[] = []
|
||||
const deleteAfterSentFiles: string[] = []
|
||||
for (const sendMsg of messageData) {
|
||||
if (ignoreTypes.includes(sendMsg.type)) {
|
||||
continue
|
||||
}
|
||||
@@ -164,10 +164,6 @@ export async function createSendElements(
|
||||
sendElements.push(SendElementEntities.ark(sendMsg.data.data))
|
||||
}
|
||||
break
|
||||
case OB11MessageDataType.poke: {
|
||||
let qq = sendMsg.data?.qq || sendMsg.data?.id
|
||||
}
|
||||
break
|
||||
case OB11MessageDataType.dice: {
|
||||
const resultId = sendMsg.data?.result
|
||||
sendElements.push(SendElementEntities.dice(resultId))
|
||||
@@ -269,11 +265,41 @@ export async function sendMsg(
|
||||
//log('发送消息总大小', totalSize, 'bytes')
|
||||
const timeout = 10000 + (totalSize / 1024 / 256 * 1000) // 10s Basic Timeout + PredictTime( For File 512kb/s )
|
||||
//log('设置消息超时时间', timeout)
|
||||
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
||||
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, timeout)
|
||||
if (returnMsg) {
|
||||
returnMsg.msgShortId = MessageUnique.createMsg(peer, returnMsg.msgId)
|
||||
ctx.logger.info('消息发送', returnMsg.msgShortId)
|
||||
deleteAfterSentFiles.map(path => fsPromise.unlink(path))
|
||||
return returnMsg
|
||||
}
|
||||
}
|
||||
|
||||
export interface CreatePeerPayload {
|
||||
group_id?: string | number
|
||||
user_id?: string | number
|
||||
}
|
||||
|
||||
export enum CreatePeerMode {
|
||||
Normal = 0,
|
||||
Private = 1,
|
||||
Group = 2
|
||||
}
|
||||
|
||||
export async function createPeer(ctx: Context, payload: CreatePeerPayload, mode: CreatePeerMode): Promise<Peer> {
|
||||
if ((mode === CreatePeerMode.Group || mode === CreatePeerMode.Normal) && payload.group_id) {
|
||||
return {
|
||||
chatType: ChatType.group,
|
||||
peerUid: payload.group_id.toString(),
|
||||
}
|
||||
}
|
||||
if ((mode === CreatePeerMode.Private || mode === CreatePeerMode.Normal) && payload.user_id) {
|
||||
const uid = await ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||
if (!uid) throw new Error('无法获取用户信息')
|
||||
const isBuddy = await ctx.ntFriendApi.isBuddy(uid)
|
||||
return {
|
||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||
peerUid: uid,
|
||||
}
|
||||
}
|
||||
throw new Error('请指定 group_id 或 user_id')
|
||||
}
|
@@ -4,13 +4,13 @@ import { OB11BaseEvent } from '../event/OB11BaseEvent'
|
||||
type PostEventType = OB11Message | OB11BaseEvent
|
||||
|
||||
interface HttpEventType {
|
||||
seq: number
|
||||
event: PostEventType
|
||||
seq: number
|
||||
event: PostEventType
|
||||
}
|
||||
|
||||
interface HttpUserType {
|
||||
lastAccessTime: number
|
||||
userSeq: number
|
||||
lastAccessTime: number
|
||||
userSeq: number
|
||||
}
|
||||
|
||||
let curentSeq: number = 0
|
||||
@@ -18,51 +18,51 @@ const eventList: HttpEventType[] = []
|
||||
const httpUser: Record<string, HttpUserType> = {}
|
||||
|
||||
export function postHttpEvent(event: PostEventType) {
|
||||
curentSeq += 1
|
||||
eventList.push({
|
||||
seq: curentSeq,
|
||||
event: event
|
||||
})
|
||||
while (eventList.length > 100) {
|
||||
eventList.shift()
|
||||
}
|
||||
curentSeq += 1
|
||||
eventList.push({
|
||||
seq: curentSeq,
|
||||
event: event
|
||||
})
|
||||
while (eventList.length > 100) {
|
||||
eventList.shift()
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHttpEvent(userKey: string, timeout = 0) {
|
||||
const toRetEvent: PostEventType[] = []
|
||||
const toRetEvent: PostEventType[] = []
|
||||
|
||||
// 清除过时的user,5分钟没访问过的user将被删除
|
||||
const now = Date.now()
|
||||
for (let key in httpUser) {
|
||||
let user = httpUser[key]
|
||||
if (now - user.lastAccessTime > 1000 * 60 * 5) {
|
||||
delete httpUser[key]
|
||||
}
|
||||
// 清除过时的user,5分钟没访问过的user将被删除
|
||||
const now = Date.now()
|
||||
for (const key in httpUser) {
|
||||
const user = httpUser[key]
|
||||
if (now - user.lastAccessTime > 1000 * 60 * 5) {
|
||||
delete httpUser[key]
|
||||
}
|
||||
}
|
||||
|
||||
// 增加新的user
|
||||
if (!httpUser[userKey]) {
|
||||
httpUser[userKey] = {
|
||||
lastAccessTime: now,
|
||||
userSeq: curentSeq
|
||||
}
|
||||
// 增加新的user
|
||||
if (!httpUser[userKey]) {
|
||||
httpUser[userKey] = {
|
||||
lastAccessTime: now,
|
||||
userSeq: curentSeq
|
||||
}
|
||||
}
|
||||
|
||||
const user = httpUser[userKey]
|
||||
// 等待数据到来,暂时先这么写吧......
|
||||
while (curentSeq == user.userSeq && Date.now() - now < timeout) {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
}
|
||||
// 取数据
|
||||
for (let i = 0; i < eventList.length; i++) {
|
||||
let evt = eventList[i]
|
||||
if (evt.seq > user.userSeq) {
|
||||
toRetEvent.push(evt.event)
|
||||
}
|
||||
const user = httpUser[userKey]
|
||||
// 等待数据到来,暂时先这么写吧......
|
||||
while (curentSeq == user.userSeq && Date.now() - now < timeout) {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
}
|
||||
// 取数据
|
||||
for (let i = 0; i < eventList.length; i++) {
|
||||
const evt = eventList[i]
|
||||
if (evt.seq > user.userSeq) {
|
||||
toRetEvent.push(evt.event)
|
||||
}
|
||||
}
|
||||
|
||||
// 更新user数据
|
||||
user.lastAccessTime = Date.now()
|
||||
user.userSeq = curentSeq
|
||||
return toRetEvent
|
||||
// 更新user数据
|
||||
user.lastAccessTime = Date.now()
|
||||
user.userSeq = curentSeq
|
||||
return toRetEvent
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { OB11Message, OB11MessageAt, OB11MessageData, OB11MessageDataType } from '../types'
|
||||
import { OB11FriendRequestEvent } from '../event/request/OB11FriendRequest'
|
||||
import { OB11GroupRequestEvent } from '../event/request/OB11GroupRequest'
|
||||
import { ChatType, GroupRequestOperateTypes, Peer } from '@/ntqqapi/types'
|
||||
import { convertMessage2List, createSendElements, sendMsg } from '../helper/createMessage'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import { GroupRequestOperateTypes } from '@/ntqqapi/types'
|
||||
import { convertMessage2List, createSendElements, sendMsg, createPeer, CreatePeerMode } from '../helper/createMessage'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
import { isNullable } from 'cosmokit'
|
||||
import { Context } from 'cordis'
|
||||
import { OB11Config } from '@/common/types'
|
||||
|
||||
interface QuickOperationPrivateMessage {
|
||||
reply?: string
|
||||
@@ -57,21 +57,14 @@ export async function handleQuickOperation(ctx: Context, event: QuickOperationEv
|
||||
|
||||
async function handleMsg(ctx: Context, msg: OB11Message, quickAction: QuickOperationPrivateMessage | QuickOperationGroupMessage) {
|
||||
const reply = quickAction.reply
|
||||
const ob11Config = getConfigUtil().getConfig().ob11
|
||||
const peer: Peer = {
|
||||
chatType: ChatType.friend,
|
||||
peerUid: msg.user_id.toString(),
|
||||
}
|
||||
if (msg.message_type == 'private') {
|
||||
peer.peerUid = (await ctx.ntUserApi.getUidByUin(msg.user_id.toString()))!
|
||||
if (msg.sub_type === 'group') {
|
||||
peer.chatType = ChatType.temp
|
||||
}
|
||||
}
|
||||
else {
|
||||
peer.chatType = ChatType.group
|
||||
peer.peerUid = msg.group_id?.toString()!
|
||||
const ob11Config: OB11Config = ctx.config
|
||||
let contextMode = CreatePeerMode.Normal
|
||||
if (msg.message_type === 'group') {
|
||||
contextMode = CreatePeerMode.Group
|
||||
} else if (msg.message_type === 'private') {
|
||||
contextMode = CreatePeerMode.Private
|
||||
}
|
||||
const peer = await createPeer(ctx, msg, contextMode)
|
||||
if (reply) {
|
||||
let replyMessage: OB11MessageData[] = []
|
||||
if (ob11Config.enableQOAutoQuote) {
|
||||
|
@@ -54,8 +54,10 @@ export interface OB11GroupMember {
|
||||
export interface OB11Group {
|
||||
group_id: number
|
||||
group_name: string
|
||||
member_count?: number
|
||||
max_member_count?: number
|
||||
group_memo: string
|
||||
group_create_time: number
|
||||
member_count: number
|
||||
max_member_count: number
|
||||
}
|
||||
|
||||
interface OB11Sender {
|
||||
@@ -66,6 +68,8 @@ interface OB11Sender {
|
||||
card?: string // 群名片
|
||||
level?: string // 群等级
|
||||
role?: OB11GroupMemberRole
|
||||
group_id?: number // 当私聊 sub_type 为 group 时
|
||||
title?: string // 群聊专属头衔
|
||||
}
|
||||
|
||||
export enum OB11MessageType {
|
||||
@@ -91,6 +95,7 @@ export interface OB11Message {
|
||||
font: number
|
||||
post_type?: EventType
|
||||
raw?: RawMessage
|
||||
temp_source?: 0 | 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9
|
||||
}
|
||||
|
||||
export interface OB11ForwardMessage extends OB11Message {
|
||||
@@ -102,7 +107,7 @@ export interface OB11Return<DataType> {
|
||||
retcode: number
|
||||
data: DataType
|
||||
message: string
|
||||
echo?: any // ws调用api才有此字段
|
||||
echo?: unknown // ws调用api才有此字段
|
||||
wording?: string // go-cqhttp字段,错误信息
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@ const { contextBridge } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const llonebot = {
|
||||
log: (data: any) => {
|
||||
log: (data: unknown) => {
|
||||
ipcRenderer.send(CHANNEL_LOG, data)
|
||||
},
|
||||
checkVersion: async (): Promise<CheckVersion> => {
|
||||
|
@@ -32,14 +32,14 @@ window.customElements.define(
|
||||
this.attachShadow({ mode: 'open' })
|
||||
this.shadowRoot?.append(SelectTemplate.content.cloneNode(true))
|
||||
|
||||
this._button = this.shadowRoot?.querySelector('div[part="button"]')!
|
||||
this._text = this.shadowRoot?.querySelector('input[part="current-text"]')!
|
||||
this._context = this.shadowRoot?.querySelector('ul[part="option-list"]')!
|
||||
this._button = this.shadowRoot?.querySelector('div[part="button"]') as HTMLDivElement
|
||||
this._text = this.shadowRoot?.querySelector('input[part="current-text"]') as HTMLInputElement
|
||||
this._context = this.shadowRoot?.querySelector('ul[part="option-list"]') as HTMLUListElement
|
||||
|
||||
const buttonClick = () => {
|
||||
const isHidden = this._context.classList.toggle('hidden')
|
||||
window[`${isHidden ? 'remove' : 'add'}EventListener`]('pointerdown', ({ target }) => {
|
||||
if (!this.contains(target as any)) buttonClick()
|
||||
if (!this.contains(target as Node)) buttonClick()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,12 +67,12 @@ window.customElements.define(
|
||||
)
|
||||
})
|
||||
|
||||
this._text.value = this.querySelector('setting-option[is-selected]')?.textContent!
|
||||
this._text.value = this.querySelector('setting-option[is-selected]')?.textContent as string
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
export const SettingSelect = (items: Array<{ text: string; value: string }>, configKey?: string, configValue?: any) => {
|
||||
export const SettingSelect = (items: Array<{ text: string; value: string }>, configKey?: string, configValue?: unknown) => {
|
||||
return `<ob-setting-select ${configKey ? `data-config-key="${configKey}"` : ''}>
|
||||
${items
|
||||
.map((e, i) => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { CheckVersion, Config } from '../common/types'
|
||||
import { SettingButton, SettingItem, SettingList, SettingSwitch, SettingSelect } from './components'
|
||||
import { version } from '../version'
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
import StyleRaw from './style.css?raw'
|
||||
|
||||
type HostsType = 'httpHosts' | 'wsHosts'
|
||||
@@ -15,7 +15,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
const config = await window.llonebot.getConfig()
|
||||
const ob11Config = { ...config.ob11 }
|
||||
|
||||
const setConfig = (key: string, value: any) => {
|
||||
const setConfig = (key: string, value: unknown) => {
|
||||
const configKey = key.split('.')
|
||||
if (key.startsWith('ob11')) {
|
||||
if (configKey.length === 2) Object.assign(ob11Config, { [configKey[1]]: value })
|
||||
@@ -87,9 +87,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
<setting-text>HTTP 事件上报密钥</setting-text>
|
||||
</div>
|
||||
<div class="q-input">
|
||||
<input id="config-ob11-httpSecret" class="q-input__inner" data-config-key="ob11.httpSecret" type="text" value="${
|
||||
config.ob11.httpSecret
|
||||
}" placeholder="未设置" />
|
||||
<input id="config-ob11-httpSecret" class="q-input__inner" data-config-key="ob11.httpSecret" type="text" value="${config.ob11.httpSecret}" placeholder="未设置" />
|
||||
</div>
|
||||
</setting-item>
|
||||
<setting-item data-direction="row">
|
||||
@@ -152,8 +150,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
),
|
||||
SettingItem(
|
||||
'FFmpeg 路径,发送语音、视频需要',
|
||||
`<a href="javascript:LiteLoader.api.openExternal(\'https://llonebot.github.io/zh-CN/guide/ffmpeg\');">可点此下载</a>, 路径: <span id="config-ffmpeg-path-text">${
|
||||
!isEmpty(config.ffmpeg) ? config.ffmpeg : '未指定'
|
||||
`<a href="javascript:LiteLoader.api.openExternal(\'https://llonebot.github.io/zh-CN/guide/ffmpeg\');">可点此下载</a>, 路径: <span id="config-ffmpeg-path-text">${!isEmpty(config.ffmpeg) ? config.ffmpeg : '未指定'
|
||||
}</span>, 需保证 FFprobe 和 FFmpeg 在一起`,
|
||||
SettingButton('选择 FFmpeg', 'config-ffmpeg-select'),
|
||||
),
|
||||
@@ -166,7 +163,12 @@ async function onSettingWindowCreated(view: Element) {
|
||||
SettingItem(
|
||||
'快速操作回复自动引用原消息',
|
||||
null,
|
||||
SettingSwitch('ob11.enableQOAutoQuote', config.ob11.enableQOAutoQuote, { 'control-display-id': 'config-ob11-enableQOAutoQuote' }),
|
||||
SettingSwitch('ob11.enableQOAutoQuote', config.ob11.enableQOAutoQuote),
|
||||
),
|
||||
SettingItem(
|
||||
'HTTP、正向 WebSocket 服务仅监听 127.0.0.1',
|
||||
'而不是 0.0.0.0',
|
||||
SettingSwitch('ob11.listenLocalhost', config.ob11.listenLocalhost),
|
||||
),
|
||||
SettingItem('', null, SettingButton('保存', 'config-ob11-save', 'primary')),
|
||||
]),
|
||||
@@ -249,7 +251,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
window.LiteLoader.api.openExternal('https://llonebot.github.io/')
|
||||
})
|
||||
// 生成反向地址列表
|
||||
const buildHostListItem = (type: HostsType, host: string, index: number, inputAttrs: any = {}) => {
|
||||
const buildHostListItem = (type: HostsType, host: string, index: number, inputAttrs = {}) => {
|
||||
const dom = {
|
||||
container: document.createElement('setting-item'),
|
||||
input: document.createElement('input'),
|
||||
@@ -281,7 +283,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
|
||||
return dom.container
|
||||
}
|
||||
const buildHostList = (hosts: string[], type: HostsType, inputAttr: any = {}) => {
|
||||
const buildHostList = (hosts: string[], type: HostsType, inputAttr = {}) => {
|
||||
const result: HTMLElement[] = []
|
||||
|
||||
hosts.forEach((host, index) => {
|
||||
@@ -290,14 +292,15 @@ async function onSettingWindowCreated(view: Element) {
|
||||
|
||||
return result
|
||||
}
|
||||
const addReverseHost = (type: HostsType, doc: Document = document, inputAttr: any = {}) => {
|
||||
const addReverseHost = (type: HostsType, doc: Document = document, inputAttr = {}) => {
|
||||
const hostContainerDom = doc.body.querySelector(`#config-ob11-${type}-list`)
|
||||
hostContainerDom?.appendChild(buildHostListItem(type, '', ob11Config[type].length, inputAttr))
|
||||
ob11Config[type].push('')
|
||||
}
|
||||
const initReverseHost = (type: HostsType, doc: Document = document) => {
|
||||
const hostContainerDom = doc.body.querySelector(`#config-ob11-${type}-list`)
|
||||
;[...hostContainerDom?.childNodes!].forEach((dom) => dom.remove())
|
||||
const hostContainerDom = doc.body.querySelector(`#config-ob11-${type}-list`)!
|
||||
const nodes = [...hostContainerDom.childNodes]
|
||||
nodes.forEach((dom) => dom.remove())
|
||||
buildHostList(ob11Config[type], type).forEach((dom) => {
|
||||
hostContainerDom?.appendChild(dom)
|
||||
})
|
||||
@@ -422,14 +425,14 @@ async function onSettingWindowCreated(view: Element) {
|
||||
}
|
||||
}
|
||||
window.llonebot.checkVersion().then(checkVersionFunc)
|
||||
window.addEventListener('beforeunload', (event) => {
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (JSON.stringify(ob11Config) === JSON.stringify(config.ob11)) return
|
||||
config.ob11 = ob11Config
|
||||
window.llonebot.setConfig(true, config)
|
||||
})
|
||||
}
|
||||
|
||||
function init() {
|
||||
/**function init() {
|
||||
const hash = location.hash
|
||||
if (hash === '#/blank') {
|
||||
}
|
||||
@@ -439,6 +442,6 @@ if (location.hash === '#/blank') {
|
||||
globalThis.navigation?.addEventListener('navigatesuccess', init, { once: true })
|
||||
} else {
|
||||
init()
|
||||
}
|
||||
}*/
|
||||
|
||||
export { onSettingWindowCreated }
|
||||
|
@@ -1 +1 @@
|
||||
export const version = '3.31.6'
|
||||
export const version = '3.31.9'
|
||||
|
Reference in New Issue
Block a user