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