mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: get pskey & skey
This commit is contained in:
parent
aae10181b5
commit
235328e4fe
@ -1,10 +1,10 @@
|
||||
{
|
||||
"manifest_version": 4,
|
||||
"type": "extension",
|
||||
"name": "LLOneBot v3.16.0",
|
||||
"name": "LLOneBot v3.17.0",
|
||||
"slug": "LLOneBot",
|
||||
"description": "LiteLoaderQQNT的OneBotApi,不支持商店在线更新",
|
||||
"version": "3.16.0",
|
||||
"version": "3.17.0",
|
||||
"icon": "./icon.jpg",
|
||||
"authors": [
|
||||
{
|
||||
|
@ -6,11 +6,12 @@ import util from "util";
|
||||
import {encode, getDuration, isWav} from "silk-wasm";
|
||||
import path from "node:path";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {DATA_DIR, log, TEMP_DIR} from "./index";
|
||||
import {checkFfmpeg, DATA_DIR, log, TEMP_DIR} from "./index";
|
||||
import {getConfigUtil} from "../config";
|
||||
import {dbUtil} from "../db";
|
||||
import * as fileType from "file-type";
|
||||
import {net} from "electron";
|
||||
import config from "../../../electron.vite.config";
|
||||
|
||||
|
||||
export function isGIF(path: string) {
|
||||
@ -66,28 +67,6 @@ export async function file2base64(path: string) {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function checkFfmpeg(newPath: string = null): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
log("开始检查ffmpeg", newPath);
|
||||
if (newPath) {
|
||||
ffmpeg.setFfmpegPath(newPath);
|
||||
}
|
||||
try {
|
||||
ffmpeg.getAvailableFormats((err, formats) => {
|
||||
if (err) {
|
||||
log('ffmpeg is not installed or not found in PATH:', err);
|
||||
resolve(false)
|
||||
} else {
|
||||
log('ffmpeg is installed.');
|
||||
resolve(true);
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function encodeSilk(filePath: string) {
|
||||
const fsp = require("fs").promises
|
||||
|
||||
|
@ -13,4 +13,5 @@ export const PLUGIN_DIR = global.LiteLoader.plugins["LLOneBot"].path.plugin;
|
||||
if (!fs.existsSync(TEMP_DIR)) {
|
||||
fs.mkdirSync(TEMP_DIR);
|
||||
}
|
||||
export {getVideoInfo} from "./video";
|
||||
export {getVideoInfo} from "./video";
|
||||
export {checkFfmpeg} from "./video";
|
File diff suppressed because one or more lines are too long
@ -42,9 +42,9 @@ import {NTQQGroupApi} from "../ntqqapi/api/group";
|
||||
import {registerPokeHandler} from "../ntqqapi/external/ccpoke";
|
||||
import {OB11FriendPokeEvent, OB11GroupPokeEvent} from "../onebot11/event/notice/OB11PokeEvent";
|
||||
import {checkVersion, upgradeLLOneBot} from "../common/utils/upgrade";
|
||||
import {checkFfmpeg} from "../common/utils/file";
|
||||
import {log} from "../common/utils/log";
|
||||
import {getConfigUtil} from "../common/config";
|
||||
import {checkFfmpeg} from "../common/utils/video";
|
||||
|
||||
|
||||
let running = false;
|
||||
|
@ -4,6 +4,7 @@ import {ob11WebsocketServer} from "../onebot11/server/ws/WebsocketServer";
|
||||
import {ob11ReverseWebsockets} from "../onebot11/server/ws/ReverseWebsocket";
|
||||
import {llonebotError} from "../common/data";
|
||||
import {getConfigUtil} from "../common/config";
|
||||
import {checkFfmpeg} from "../common/utils";
|
||||
|
||||
export async function setConfig(config: Config) {
|
||||
let oldConfig = getConfigUtil().getConfig();
|
||||
@ -51,4 +52,5 @@ export async function setConfig(config: Config) {
|
||||
}
|
||||
}
|
||||
}
|
||||
checkFfmpeg(config.ffmpeg).then()
|
||||
}
|
@ -5,6 +5,7 @@ import {uidMaps} from "../../common/data";
|
||||
import {BrowserWindow} from "electron";
|
||||
import {dbUtil} from "../../common/db";
|
||||
import {log} from "../../common/utils/log";
|
||||
import {NTQQWindowApi, NTQQWindows} from "./window";
|
||||
|
||||
export class NTQQGroupApi{
|
||||
static async getGroups(forced = false) {
|
||||
@ -74,25 +75,7 @@ export class NTQQGroupApi{
|
||||
}
|
||||
static async getGroupIgnoreNotifies() {
|
||||
await NTQQGroupApi.getGroupNotifies();
|
||||
const result = callNTQQApi<GroupNotifies>({
|
||||
className: NTQQApiClass.WINDOW_API,
|
||||
methodName: NTQQApiMethod.OPEN_EXTRA_WINDOW,
|
||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||
afterFirstCmd: false,
|
||||
args: [
|
||||
"GroupNotifyFilterWindow"
|
||||
]
|
||||
})
|
||||
// 关闭窗口
|
||||
setTimeout(() => {
|
||||
for (const w of BrowserWindow.getAllWindows()) {
|
||||
// log("close window", w.webContents.getURL())
|
||||
if (w.webContents.getURL().indexOf("#/notify-filter/") != -1) {
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
return result;
|
||||
return await NTQQWindowApi.openWindow(NTQQWindows.GroupNotifyFilterWindow, ReceiveCmdS.GROUP_NOTIFY);
|
||||
}
|
||||
static async handleGroupRequest(seq: string, operateType: GroupRequestOperateTypes, reason?: string) {
|
||||
const notify: GroupNotify = await dbUtil.getGroupNotify(seq)
|
||||
|
@ -53,5 +53,4 @@ export class NTQQUserApi{
|
||||
return info
|
||||
}
|
||||
|
||||
|
||||
}
|
45
src/ntqqapi/api/window.ts
Normal file
45
src/ntqqapi/api/window.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import {callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod} from "../ntcall";
|
||||
import {ReceiveCmd} from "../hook";
|
||||
import {BrowserWindow} from "electron";
|
||||
|
||||
interface NTQQWindow{
|
||||
windowName: string,
|
||||
windowUrlHash: string,
|
||||
}
|
||||
|
||||
export class NTQQWindows{
|
||||
static GroupHomeWorkWindow: NTQQWindow = {
|
||||
windowName: "GroupHomeWorkWindow",
|
||||
windowUrlHash: "#/group-home-work"
|
||||
}
|
||||
static GroupNotifyFilterWindow: NTQQWindow = {
|
||||
windowName: "GroupNotifyFilterWindow",
|
||||
windowUrlHash: "#/group-notify-filter"
|
||||
}
|
||||
}
|
||||
|
||||
export class NTQQWindowApi{
|
||||
|
||||
// 打开窗口并获取对应的下发事件
|
||||
static async openWindow(ntQQWindow: NTQQWindow, args: any[], cbCmd: ReceiveCmd=null, autoCloseSeconds: number=2){
|
||||
const result = await callNTQQApi<GeneralCallResult>({
|
||||
className: NTQQApiClass.WINDOW_API,
|
||||
methodName: NTQQApiMethod.OPEN_EXTRA_WINDOW,
|
||||
cbCmd,
|
||||
afterFirstCmd: false,
|
||||
args: [
|
||||
ntQQWindow.windowName,
|
||||
...args
|
||||
]
|
||||
})
|
||||
setTimeout(() => {
|
||||
for (const w of BrowserWindow.getAllWindows()) {
|
||||
// log("close window", w.webContents.getURL())
|
||||
if (w.webContents.getURL().indexOf(ntQQWindow.windowUrlHash) != -1) {
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
}, autoCloseSeconds * 1000);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ export let ReceiveCmdS = {
|
||||
SELF_STATUS: 'nodeIKernelProfileListener/onSelfStatusChanged',
|
||||
CACHE_SCAN_FINISH: "nodeIKernelStorageCleanListener/onFinishScan",
|
||||
MEDIA_UPLOAD_COMPLETE: "nodeIKernelMsgListener/onRichMediaUploadComplete",
|
||||
SKEY_UPDATE: "onSkeyUpdate"
|
||||
}
|
||||
|
||||
export type ReceiveCmd = typeof ReceiveCmdS[keyof typeof ReceiveCmdS]
|
||||
|
@ -1,8 +1,9 @@
|
||||
import {ipcMain} from "electron";
|
||||
import {hookApiCallbacks, ReceiveCmd, registerReceiveHook, removeReceiveHook} from "./hook";
|
||||
import {hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeReceiveHook} from "./hook";
|
||||
|
||||
import {v4 as uuidv4} from "uuid"
|
||||
import {log} from "../common/utils/log";
|
||||
import {NTQQWindowApi, NTQQWindows} from "./api/window";
|
||||
|
||||
export enum NTQQApiClass {
|
||||
NT_API = "ns-ntApi",
|
||||
@ -11,7 +12,9 @@ export enum NTQQApiClass {
|
||||
WINDOW_API = "ns-WindowApi",
|
||||
HOTUPDATE_API = "ns-HotUpdateApi",
|
||||
BUSINESS_API = "ns-BusinessApi",
|
||||
GLOBAL_DATA = "ns-GlobalDataApi"
|
||||
GLOBAL_DATA = "ns-GlobalDataApi",
|
||||
SKEY_API = "ns-SkeyApi",
|
||||
HOME_WORK = "ns-GroupHomeWork"
|
||||
}
|
||||
|
||||
export enum NTQQApiMethod {
|
||||
@ -65,7 +68,9 @@ export enum NTQQApiMethod {
|
||||
|
||||
OPEN_EXTRA_WINDOW = 'openExternalWindow',
|
||||
|
||||
SET_QQ_AVATAR = 'nodeIKernelProfileService/setHeader'
|
||||
SET_QQ_AVATAR = 'nodeIKernelProfileService/setHeader',
|
||||
GET_SKEY = "nodeIKernelTipOffService/getPskey",
|
||||
UPDATE_SKEY = "updatePskey"
|
||||
}
|
||||
|
||||
enum NTQQApiChannel {
|
||||
@ -178,4 +183,51 @@ export class NTQQApi {
|
||||
})
|
||||
}
|
||||
|
||||
static async getSkey(groupCode: string, groupName: string) {
|
||||
await NTQQWindowApi.openWindow(NTQQWindows.GroupHomeWorkWindow, [{
|
||||
groupName,
|
||||
groupCode,
|
||||
"source": "funcbar"
|
||||
}], ReceiveCmdS.SKEY_UPDATE, 1);
|
||||
return await callNTQQApi<GeneralCallResult>({
|
||||
className: NTQQApiClass.HOME_WORK,
|
||||
methodName: NTQQApiMethod.UPDATE_SKEY,
|
||||
args: [
|
||||
{
|
||||
domain: "qun.qq.com"
|
||||
}
|
||||
]
|
||||
})
|
||||
// return await callNTQQApi<GeneralCallResult>({
|
||||
// methodName: NTQQApiMethod.GET_SKEY,
|
||||
// args: [
|
||||
// {
|
||||
// "domains": [
|
||||
// "qzone.qq.com",
|
||||
// "qlive.qq.com",
|
||||
// "qun.qq.com",
|
||||
// "gamecenter.qq.com",
|
||||
// "vip.qq.com",
|
||||
// "qianbao.qq.com",
|
||||
// "qidian.qq.com"
|
||||
// ],
|
||||
// "isForNewPCQQ": false
|
||||
// },
|
||||
// null
|
||||
// ]
|
||||
// })
|
||||
}
|
||||
|
||||
static async updateSkey() {
|
||||
return await callNTQQApi<GeneralCallResult>({
|
||||
className: NTQQApiClass.HOME_WORK,
|
||||
methodName: NTQQApiMethod.UPDATE_SKEY,
|
||||
args: [
|
||||
{
|
||||
domain: "qun.qq.com"
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user