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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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