mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0cd41a8a52 | ||
![]() |
d339a778df | ||
![]() |
dc843f77a3 | ||
![]() |
b103f2015c | ||
![]() |
baf35d5496 |
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"manifest_version": 4,
|
||||
"type": "extension",
|
||||
"name": "LLOneBot v3.18.0",
|
||||
"name": "LLOneBot v3.18.3",
|
||||
"slug": "LLOneBot",
|
||||
"description": "LiteLoaderQQNT的OneBotApi,不支持商店在线更新",
|
||||
"version": "3.18.0",
|
||||
"version": "3.18.3",
|
||||
"icon": "./icon.jpg",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -8,3 +8,5 @@ type QQPkgInfo = {
|
||||
}
|
||||
|
||||
export const qqPkgInfo: QQPkgInfo = require(path.join(process.resourcesPath, "app/package.json"))
|
||||
|
||||
export const isQQ998: boolean = qqPkgInfo.buildVersion >= "22106"
|
@@ -49,11 +49,13 @@ import {checkFfmpeg} from "../common/utils/video";
|
||||
|
||||
let running = false;
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
// 加载插件时触发
|
||||
function onLoad() {
|
||||
log("llonebot main onLoad");
|
||||
ipcMain.handle(CHANNEL_CHECK_VERSION, async (event, arg) => {
|
||||
|
||||
return checkNewVersion();
|
||||
});
|
||||
ipcMain.handle(CHANNEL_UPDATE, async (event, arg) => {
|
||||
@@ -105,8 +107,26 @@ function onLoad() {
|
||||
const config = getConfigUtil().getConfig()
|
||||
return config;
|
||||
})
|
||||
ipcMain.on(CHANNEL_SET_CONFIG, (event, config: Config) => {
|
||||
ipcMain.on(CHANNEL_SET_CONFIG, (event, ask:boolean, config: Config) => {
|
||||
if (!ask){
|
||||
setConfig(config).then();
|
||||
return
|
||||
}
|
||||
dialog.showMessageBox(mainWindow, {
|
||||
type: 'question',
|
||||
buttons: ['确认', '取消'],
|
||||
defaultId: 0, // 默认选中的按钮,0 代表第一个按钮,即 "确认"
|
||||
title: '确认保存',
|
||||
message: '是否保存?',
|
||||
detail: 'LLOneBot配置已更改,是否保存?'
|
||||
}).then(result => {
|
||||
if (result.response === 0) {
|
||||
setConfig(config).then();
|
||||
} else {
|
||||
}
|
||||
}).catch(err => {
|
||||
log("保存设置询问弹窗错误", err);
|
||||
});
|
||||
})
|
||||
|
||||
ipcMain.on(CHANNEL_LOG, (event, arg) => {
|
||||
@@ -402,6 +422,7 @@ function onBrowserWindowCreated(window: BrowserWindow) {
|
||||
if (selfInfo.uid) {
|
||||
return
|
||||
}
|
||||
mainWindow = window;
|
||||
log("window create", window.webContents.getURL().toString())
|
||||
try {
|
||||
hookNTQQApiCall(window);
|
||||
@@ -417,6 +438,7 @@ try {
|
||||
console.log(e.toString())
|
||||
}
|
||||
|
||||
|
||||
// 这两个函数都是可选的
|
||||
export {
|
||||
onBrowserWindowCreated
|
||||
|
@@ -5,6 +5,7 @@ import {selfInfo} from "../../common/data";
|
||||
import {ReceiveCmdS, registerReceiveHook} from "../hook";
|
||||
import {log} from "../../common/utils/log";
|
||||
import {sleep} from "../../common/utils/helper";
|
||||
import {isQQ998} from "../../common/utils";
|
||||
|
||||
export let sendMessagePool: Record<string, ((sendSuccessMsg: RawMessage) => void) | null> = {}// peerUid: callbackFunnc
|
||||
|
||||
@@ -25,7 +26,7 @@ export class NTQQMsgApi {
|
||||
}
|
||||
static async getMsgHistory(peer: Peer, msgId: string, count: number) {
|
||||
return await callNTQQApi<GeneralCallResult & {msgList: RawMessage[]}>({
|
||||
methodName: NTQQApiMethod.HISTORY_MSG,
|
||||
methodName: isQQ998 ? NTQQApiMethod.HISTORY_MSG_998 : NTQQApiMethod.HISTORY_MSG,
|
||||
args: [{
|
||||
peer,
|
||||
msgId,
|
||||
|
@@ -23,7 +23,8 @@ export enum NTQQApiClass {
|
||||
export enum NTQQApiMethod {
|
||||
RECENT_CONTACT = "nodeIKernelRecentContactService/fetchAndSubscribeABatchOfRecentContact",
|
||||
ADD_ACTIVE_CHAT = "nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat", // 激活群助手内的聊天窗口,这样才能收到消息
|
||||
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
||||
HISTORY_MSG_998 = "nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat",
|
||||
HISTORY_MSG = "nodeIKernelMsgService/getMsgsIncludeSelf",
|
||||
LIKE_FRIEND = "nodeIKernelProfileLikeService/setBuddyProfileLike",
|
||||
SELF_INFO = "fetchAuthData",
|
||||
FRIENDS = "nodeIKernelBuddyService/getBuddyList",
|
||||
|
@@ -11,24 +11,29 @@ import {log} from "../../../common/utils";
|
||||
|
||||
interface Payload {
|
||||
group_id: number
|
||||
message_seq: number
|
||||
message_seq: number,
|
||||
count: number
|
||||
}
|
||||
|
||||
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, OB11Message[]> {
|
||||
interface Response{
|
||||
messages: OB11Message[]
|
||||
}
|
||||
|
||||
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory
|
||||
|
||||
protected async _handle(payload: Payload): Promise<OB11Message[]> {
|
||||
protected async _handle(payload: Payload): Promise<Response> {
|
||||
const group = groups.find(group => group.groupCode === payload.group_id.toString())
|
||||
if (!group) {
|
||||
throw `群${payload.group_id}不存在`
|
||||
}
|
||||
const startMsgId = (await dbUtil.getMsgByShortId(payload.message_seq))?.msgId || "0"
|
||||
// log("startMsgId", startMsgId)
|
||||
let msgList = (await NTQQMsgApi.getMsgHistory({chatType: ChatType.group, peerUid: group.groupCode}, startMsgId, 20)).msgList
|
||||
let msgList = (await NTQQMsgApi.getMsgHistory({chatType: ChatType.group, peerUid: group.groupCode}, startMsgId, parseInt(payload.count?.toString()) || 20)).msgList
|
||||
await Promise.all(msgList.map(async msg => {
|
||||
msg.msgShortId = await dbUtil.addMsg(msg)
|
||||
}))
|
||||
const ob11MsgList = await Promise.all(msgList.map(msg=>OB11Constructor.message(msg)))
|
||||
return ob11MsgList
|
||||
return {"messages": ob11MsgList}
|
||||
}
|
||||
}
|
@@ -24,8 +24,8 @@ const llonebot = {
|
||||
updateLLOneBot:async (): Promise<boolean> => {
|
||||
return ipcRenderer.invoke(CHANNEL_UPDATE);
|
||||
},
|
||||
setConfig: (config: Config) => {
|
||||
ipcRenderer.send(CHANNEL_SET_CONFIG, config);
|
||||
setConfig: (ask: boolean, config: Config) => {
|
||||
ipcRenderer.send(CHANNEL_SET_CONFIG, ask, config);
|
||||
},
|
||||
getConfig: async (): Promise<Config> => {
|
||||
return ipcRenderer.invoke(CHANNEL_GET_CONFIG);
|
||||
|
@@ -21,7 +21,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
else config[key] = value;
|
||||
|
||||
if (!['heartInterval', 'token', 'ffmpeg'].includes(key)) {
|
||||
window.llonebot.setConfig(config);
|
||||
window.llonebot.setConfig(false, config);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -324,7 +324,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
doc.querySelector('#config-ob11-save').addEventListener('click', () => {
|
||||
config.ob11 = ob11Config;
|
||||
|
||||
window.llonebot.setConfig(config);
|
||||
window.llonebot.setConfig(false, config);
|
||||
// window.location.reload();
|
||||
showError().then()
|
||||
alert('保存成功');
|
||||
@@ -363,8 +363,14 @@ async function onSettingWindowCreated(view: Element) {
|
||||
}
|
||||
view.querySelector(".llonebot-update-button").addEventListener("click", update);
|
||||
}
|
||||
};
|
||||
}
|
||||
window.llonebot.checkVersion().then(checkVersionFunc);
|
||||
window.addEventListener('beforeunload', (event) => {
|
||||
if (JSON.stringify(ob11Config) === JSON.stringify(config.ob11)) return;
|
||||
config.ob11 = ob11Config;
|
||||
window.llonebot.setConfig(true, config);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
export const version = "3.18.0"
|
||||
export const version = "3.18.3"
|
Reference in New Issue
Block a user