mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix config path
This commit is contained in:
parent
6d33fb8b14
commit
907c9053c7
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 4,
|
||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "LiteLoaderQQNT的OneBotApi",
|
"description": "LiteLoaderQQNT的OneBotApi",
|
||||||
"version": "1.2.6",
|
"version": "2.0.0",
|
||||||
"thumbnail": "./icon.png",
|
"thumbnail": "./icon.png",
|
||||||
"author": {
|
"authors": [{
|
||||||
"name": "linyuchen",
|
"name": "linyuchen",
|
||||||
"link": "https://github.com/linyuchen"
|
"link": "https://github.com/linyuchen"
|
||||||
},
|
}],
|
||||||
"repository": {
|
"repository": {
|
||||||
"repo": "linyuchen/LLOneBot",
|
"repo": "linyuchen/LLOneBot",
|
||||||
"branch": "main",
|
"branch": "main",
|
||||||
"use_release": {
|
"release": {
|
||||||
"tag": "latest",
|
"tag": "latest",
|
||||||
"name": "LLOneBot.zip"
|
"name": "LLOneBot.zip"
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import {ConfigUtil} from "./config";
|
|||||||
import {startExpress} from "./HttpServer";
|
import {startExpress} from "./HttpServer";
|
||||||
import {isGIF, log} from "./utils";
|
import {isGIF, log} from "./utils";
|
||||||
import {friends, groups, selfInfo} from "./data";
|
import {friends, groups, selfInfo} from "./data";
|
||||||
|
import {} from "../global";
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
@ -26,15 +27,17 @@ let running = false;
|
|||||||
|
|
||||||
|
|
||||||
// 加载插件时触发
|
// 加载插件时触发
|
||||||
function onLoad(plugin: any) {
|
function onLoad() {
|
||||||
log("main onLoaded");
|
log("main onLoaded");
|
||||||
|
// const config_dir = browserWindow.LiteLoader.plugins["LLOneBot"].path.data;
|
||||||
|
const config_dir = global.LiteLoader.plugins["LLOneBot"].path.data;
|
||||||
function getConfigUtil() {
|
function getConfigUtil() {
|
||||||
const configFilePath = path.join(plugin.path.data, `config_${selfInfo.user_id}.json`)
|
const configFilePath = path.join(config_dir, `config_${selfInfo.user_id}.json`)
|
||||||
return new ConfigUtil(configFilePath)
|
return new ConfigUtil(configFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(plugin.path.data)) {
|
if (!fs.existsSync(config_dir)) {
|
||||||
fs.mkdirSync(plugin.path.data, {recursive: true});
|
fs.mkdirSync(config_dir, {recursive: true});
|
||||||
}
|
}
|
||||||
ipcMain.handle(CHANNEL_GET_CONFIG, (event: any, arg: any) => {
|
ipcMain.handle(CHANNEL_GET_CONFIG, (event: any, arg: any) => {
|
||||||
return getConfigUtil().getConfig()
|
return getConfigUtil().getConfig()
|
||||||
@ -143,12 +146,17 @@ function onLoad(plugin: any) {
|
|||||||
|
|
||||||
|
|
||||||
// 创建窗口时触发
|
// 创建窗口时触发
|
||||||
function onBrowserWindowCreated(window: any, plugin: any) {
|
function onBrowserWindowCreated(window: any) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
onLoad();
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(e.toString())
|
||||||
|
}
|
||||||
|
|
||||||
// 这两个函数都是可选的
|
// 这两个函数都是可选的
|
||||||
export {
|
export {
|
||||||
onLoad, onBrowserWindowCreated
|
onBrowserWindowCreated
|
||||||
}
|
}
|
@ -31,8 +31,6 @@ async function getFriends() {
|
|||||||
}
|
}
|
||||||
window.llonebot.updateFriends(friends)
|
window.llonebot.updateFriends(friends)
|
||||||
return friends
|
return friends
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFriend(qq: string) {
|
async function getFriend(qq: string) {
|
||||||
@ -272,13 +270,7 @@ function recallMessage(msgId: string) {
|
|||||||
|
|
||||||
let chatListEle: HTMLCollectionOf<Element>
|
let chatListEle: HTMLCollectionOf<Element>
|
||||||
|
|
||||||
async function onLoad(arg: any) {
|
async function getGroupsMembers(groupsArg: Group[]) {
|
||||||
let runningStatus = await window.llonebot.getRunningStatus();
|
|
||||||
if (runningStatus) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getGroupsMembers(groupsArg: Group[]) {
|
|
||||||
// 批量获取群成员列表
|
// 批量获取群成员列表
|
||||||
let failedGroups: Group[] = []
|
let failedGroups: Group[] = []
|
||||||
for (const group of groupsArg) {
|
for (const group of groupsArg) {
|
||||||
@ -295,12 +287,9 @@ async function onLoad(arg: any) {
|
|||||||
} else {
|
} else {
|
||||||
window.llonebot.log("全部群成员获取完毕")
|
window.llonebot.log("全部群成员获取完毕")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await getFriends();
|
|
||||||
await getGroups();
|
|
||||||
await getGroupsMembers(groups);
|
|
||||||
|
|
||||||
function onNewMessages(messages: MessageElement[]) {
|
function onNewMessages(messages: MessageElement[]) {
|
||||||
async function func(messages: MessageElement[]) {
|
async function func(messages: MessageElement[]) {
|
||||||
console.log("收到新消息", messages)
|
console.log("收到新消息", messages)
|
||||||
if (!self_qq) {
|
if (!self_qq) {
|
||||||
@ -312,10 +301,9 @@ async function onLoad(arg: any) {
|
|||||||
func(messages).then(() => {
|
func(messages).then(() => {
|
||||||
})
|
})
|
||||||
// console.log("chatListEle", chatListEle)
|
// console.log("chatListEle", chatListEle)
|
||||||
}
|
}
|
||||||
window.LLAPI.on("new-messages", onNewMessages);
|
|
||||||
window.LLAPI.on("new-send-messages", onNewMessages);
|
|
||||||
|
|
||||||
|
async function initAccountInfo(){
|
||||||
let accountInfo = await window.LLAPI.getAccountInfo();
|
let accountInfo = await window.LLAPI.getAccountInfo();
|
||||||
window.llonebot.log("getAccountInfo " + JSON.stringify(accountInfo));
|
window.llonebot.log("getAccountInfo " + JSON.stringify(accountInfo));
|
||||||
if (!accountInfo.uid) {
|
if (!accountInfo.uid) {
|
||||||
@ -326,7 +314,28 @@ async function onLoad(arg: any) {
|
|||||||
user_id: accountInfo.uin,
|
user_id: accountInfo.uin,
|
||||||
nickname: selfInfo.nickName
|
nickname: selfInfo.nickName
|
||||||
});
|
});
|
||||||
window.llonebot.log("selfInfo " + JSON.stringify(selfInfo))
|
window.llonebot.log("selfInfo " + JSON.stringify(selfInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLoad() {
|
||||||
|
window.llonebot.log("llonebot render onLoad");
|
||||||
|
window.llonebot.getRunningStatus().then(running=>{
|
||||||
|
if (running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initAccountInfo().then(
|
||||||
|
()=>{
|
||||||
|
if (friends.length == 0) {
|
||||||
|
getFriends().then(()=>{});
|
||||||
|
}
|
||||||
|
if (groups.length == 0) {
|
||||||
|
getGroups().then(()=>{
|
||||||
|
getGroupsMembers(groups).then(()=>{});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
window.LLAPI.on("new-messages", onNewMessages);
|
||||||
|
window.LLAPI.on("new-send-messages", onNewMessages);
|
||||||
|
window.llonebot.log("llonebot render start");
|
||||||
window.llonebot.startExpress();
|
window.llonebot.startExpress();
|
||||||
|
|
||||||
window.llonebot.listenSendMessage((postData: PostDataSendMsg) => {
|
window.llonebot.listenSendMessage((postData: PostDataSendMsg) => {
|
||||||
@ -336,7 +345,6 @@ async function onLoad(arg: any) {
|
|||||||
recallMessage(arg.message_id)
|
recallMessage(arg.message_id)
|
||||||
})
|
})
|
||||||
window.llonebot.log("llonebot loaded");
|
window.llonebot.log("llonebot loaded");
|
||||||
|
|
||||||
window.LLAPI.add_qmenu((qContextMenu: Node) => {
|
window.LLAPI.add_qmenu((qContextMenu: Node) => {
|
||||||
let btn = document.createElement("a")
|
let btn = document.createElement("a")
|
||||||
btn.className = "q-context-menu-item q-context-menu-item--normal vue-component"
|
btn.className = "q-context-menu-item q-context-menu-item--normal vue-component"
|
||||||
@ -417,10 +425,14 @@ async function onLoad(arg: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getChatListEle();
|
// getChatListEle();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开设置界面时触发
|
// 打开设置界面时触发
|
||||||
async function onConfigView(view: any) {
|
async function onSettingWindowCreated (view: any) {
|
||||||
|
window.llonebot.log("setting window created");
|
||||||
const {port, hosts} = await window.llonebot.getConfig()
|
const {port, hosts} = await window.llonebot.getConfig()
|
||||||
|
|
||||||
function creatHostEleStr(host: string) {
|
function creatHostEleStr(host: string) {
|
||||||
@ -494,7 +506,11 @@ async function onConfigView(view: any) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onLoad()
|
||||||
|
|
||||||
export {
|
export {
|
||||||
onLoad,
|
onSettingWindowCreated
|
||||||
onConfigView
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user