mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
"cordis": "^3.18.1",
|
||||
"cors": "^2.8.5",
|
||||
"cosmokit": "^1.6.3",
|
||||
"express": "^5.0.0",
|
||||
"express": "^5.0.1",
|
||||
"fast-xml-parser": "^4.5.0",
|
||||
"fluent-ffmpeg": "^2.1.3",
|
||||
"minato": "^3.6.0",
|
||||
@@ -42,7 +42,7 @@
|
||||
"electron": "^31.4.0",
|
||||
"electron-vite": "^2.3.0",
|
||||
"protobufjs-cli": "^1.1.3",
|
||||
"typescript": "^5.6.2",
|
||||
"typescript": "^5.6.3",
|
||||
"vite": "^5.4.8",
|
||||
"vite-plugin-cp": "^4.0.8"
|
||||
},
|
||||
|
@@ -34,7 +34,8 @@ export class ConfigUtil {
|
||||
enableWsReverse: false,
|
||||
messagePostFormat: 'array',
|
||||
enableHttpHeart: false,
|
||||
listenLocalhost: false
|
||||
listenLocalhost: false,
|
||||
reportSelfMessage: false
|
||||
}
|
||||
const satoriDefault: SatoriConfig = {
|
||||
enable: true,
|
||||
@@ -50,7 +51,6 @@ export class ConfigUtil {
|
||||
enableLocalFile2Url: false,
|
||||
debug: false,
|
||||
log: false,
|
||||
reportSelfMessage: false,
|
||||
autoDeleteFile: false,
|
||||
autoDeleteFileSecond: 60,
|
||||
musicSignUrl: '',
|
||||
@@ -73,6 +73,7 @@ export class ConfigUtil {
|
||||
this.checkOldConfig(jsonData.ob11, jsonData, 'httpPort', 'http')
|
||||
this.checkOldConfig(jsonData.ob11, jsonData, 'httpHosts', 'hosts')
|
||||
this.checkOldConfig(jsonData.ob11, jsonData, 'wsPort', 'wsPort')
|
||||
this.checkOldConfig(jsonData.ob11, jsonData, 'reportSelfMessage', 'reportSelfMessage')
|
||||
this.config = jsonData
|
||||
return this.config
|
||||
}
|
||||
@@ -86,8 +87,8 @@ export class ConfigUtil {
|
||||
private checkOldConfig(
|
||||
currentConfig: OB11Config,
|
||||
oldConfig: Config,
|
||||
currentKey: 'httpPort' | 'httpHosts' | 'wsPort',
|
||||
oldKey: 'http' | 'hosts' | 'wsPort',
|
||||
currentKey: 'httpPort' | 'httpHosts' | 'wsPort' | 'reportSelfMessage',
|
||||
oldKey: 'http' | 'hosts' | 'wsPort' | 'reportSelfMessage',
|
||||
) {
|
||||
// 迁移旧的配置到新配置,避免用户重新填写配置
|
||||
const oldValue = oldConfig[oldKey]
|
||||
|
@@ -17,6 +17,7 @@ export interface OB11Config {
|
||||
*/
|
||||
enableQOAutoQuote?: boolean
|
||||
listenLocalhost: boolean
|
||||
reportSelfMessage: boolean
|
||||
}
|
||||
|
||||
export interface SatoriConfig {
|
||||
@@ -33,7 +34,6 @@ export interface Config {
|
||||
heartInterval: number // ms
|
||||
enableLocalFile2Url?: boolean // 开启后,本地文件路径图片会转成http链接, 语音会转成base64
|
||||
debug?: boolean
|
||||
reportSelfMessage?: boolean
|
||||
log?: boolean
|
||||
autoDeleteFile?: boolean
|
||||
autoDeleteFileSecond?: number
|
||||
@@ -50,6 +50,8 @@ export interface Config {
|
||||
wsPort?: string
|
||||
/** @deprecated */
|
||||
enableLLOB?: boolean
|
||||
/** @deprecated */
|
||||
reportSelfMessage?: boolean
|
||||
}
|
||||
|
||||
export interface CheckVersion {
|
||||
|
@@ -183,7 +183,6 @@ function onLoad() {
|
||||
heartInterval: config.heartInterval,
|
||||
token: config.token!,
|
||||
debug: config.debug!,
|
||||
reportSelfMessage: config.reportSelfMessage!,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url!,
|
||||
ffmpeg: config.ffmpeg,
|
||||
|
@@ -205,9 +205,6 @@ class Core extends Service {
|
||||
})
|
||||
|
||||
registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmdS.SELF_SEND_MSG, payload => {
|
||||
if (!this.config.reportSelfMessage) {
|
||||
return
|
||||
}
|
||||
sentMsgIds.set(payload.msgRecord.msgId, true)
|
||||
})
|
||||
|
||||
|
@@ -173,9 +173,6 @@ class OneBot11Adapter extends Service {
|
||||
return
|
||||
}
|
||||
const isSelfMsg = msg.user_id.toString() === selfInfo.uin
|
||||
if (isSelfMsg && !this.config.reportSelfMessage) {
|
||||
return
|
||||
}
|
||||
if (isSelfMsg) {
|
||||
msg.target_id = parseInt(message.peerUin)
|
||||
}
|
||||
@@ -310,7 +307,6 @@ class OneBot11Adapter extends Service {
|
||||
heartInterval: config.heartInterval,
|
||||
token: config.token,
|
||||
debug: config.debug,
|
||||
reportSelfMessage: config.reportSelfMessage,
|
||||
msgCacheExpire: config.msgCacheExpire,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url,
|
||||
@@ -341,6 +337,9 @@ class OneBot11Adapter extends Service {
|
||||
this.handleRecallMsg(input)
|
||||
})
|
||||
this.ctx.on('nt/message-sent', input => {
|
||||
if (!this.config.reportSelfMessage) {
|
||||
return
|
||||
}
|
||||
this.handleMsg(input)
|
||||
})
|
||||
this.ctx.on('nt/group-notify', input => {
|
||||
@@ -370,7 +369,6 @@ namespace OneBot11Adapter {
|
||||
heartInterval: number
|
||||
token: string
|
||||
debug: boolean
|
||||
reportSelfMessage: boolean
|
||||
musicSignUrl?: string
|
||||
enableLocalFile2Url: boolean
|
||||
ffmpeg?: string
|
||||
|
@@ -171,7 +171,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
SettingItem(
|
||||
'上报 Bot 自身发送的消息',
|
||||
'上报 event 为 message_sent',
|
||||
SettingSwitch('reportSelfMessage', config.reportSelfMessage),
|
||||
SettingSwitch('ob11.reportSelfMessage', config.ob11.reportSelfMessage),
|
||||
),
|
||||
SettingItem(
|
||||
'使用 Base64 编码获取文件',
|
||||
|
Reference in New Issue
Block a user