This commit is contained in:
idranme
2024-10-11 18:17:52 +08:00
parent ba565e7c38
commit 0081b0b124
7 changed files with 14 additions and 17 deletions

View File

@@ -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"
},

View File

@@ -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]

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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)
})

View File

@@ -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

View File

@@ -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 编码获取文件',