This commit is contained in:
idranme 2024-10-19 15:57:58 +08:00
parent 364dfe8b93
commit 5b90a25f8f
5 changed files with 18 additions and 8 deletions

View File

@ -44,6 +44,7 @@ export class ConfigUtil {
token: '' token: ''
} }
const defaultConfig: Config = { const defaultConfig: Config = {
enableLLOB: true,
satori: satoriDefault, satori: satoriDefault,
ob11: ob11Default, ob11: ob11Default,
heartInterval: 60000, heartInterval: 60000,

View File

@ -28,6 +28,7 @@ export interface SatoriConfig {
} }
export interface Config { export interface Config {
enableLLOB: boolean
satori: SatoriConfig satori: SatoriConfig
ob11: OB11Config ob11: OB11Config
token?: string token?: string
@ -49,8 +50,6 @@ export interface Config {
/** @deprecated */ /** @deprecated */
wsPort?: string wsPort?: string
/** @deprecated */ /** @deprecated */
enableLLOB?: boolean
/** @deprecated */
reportSelfMessage?: boolean reportSelfMessage?: boolean
} }

View File

@ -182,6 +182,15 @@ function onLoad() {
log('process pid', process.pid) log('process pid', process.pid)
const config = getConfigUtil().getConfig() const config = getConfigUtil().getConfig()
if (config.enableLLOB && (config.satori.enable || config.ob11.enable)) {
startHook()
} else {
llonebotError.otherError = 'LLOneBot 未启动'
log('LLOneBot 开关设置为关闭,不启动 LLOneBot')
return
}
ctx.plugin(Log, { ctx.plugin(Log, {
enable: config.log!, enable: config.log!,
filename: logFileName filename: logFileName
@ -224,7 +233,6 @@ function onBrowserWindowCreated(window: BrowserWindow) {
try { try {
onLoad() onLoad()
startHook()
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }

View File

@ -47,11 +47,6 @@ class Core extends Service {
} }
public start() { public start() {
if (!this.config.ob11.enable && !this.config.satori.enable) {
llonebotError.otherError = 'LLOneBot 未启动'
this.ctx.logger.info('LLOneBot 开关设置为关闭,不启动 LLOneBot')
return
}
this.startTime = Date.now() this.startTime = Date.now()
this.registerListener() this.registerListener()
this.ctx.logger.info(`LLOneBot/${version}`) this.ctx.logger.info(`LLOneBot/${version}`)

View File

@ -43,6 +43,13 @@ async function onSettingWindowCreated(view: Element) {
SettingButton('请稍候', 'llonebot-update-button', 'secondary'), SettingButton('请稍候', 'llonebot-update-button', 'secondary'),
), ),
]), ]),
SettingList([
SettingItem(
'是否启用 LLOneBot重启 QQ 后生效',
null,
SettingSwitch('enableLLOB', config.enableLLOB, { 'control-display-id': 'config-enableLLOB' }),
)
]),
SettingList([ SettingList([
SettingItem( SettingItem(
'是否启用 Satori 协议', '是否启用 Satori 协议',