* [MODIFIED] Now ignores messages sent by the bot itself to prevent feedback loops.
(msg: Api.Message)
| 233 | return this.traceKeyword(msg, keyword, fullEmojiText); |
| 234 | } else if (action === "del" && keyword) { |
| 235 | return this.untraceKeyword(msg, keyword); |
| 236 | } |
| 237 | break; |
| 238 | case "status": |
| 239 | return this.showStatus(msg); |
| 240 | case "clean": |
| 241 | return this.cleanTraces(msg); |
| 242 | case "reset": |
| 243 | return this.resetDatabase(msg); |
| 244 | case "log": |
| 245 | return this.setConfig(msg, "keepLog", args[0]); |
| 246 | case "big": |
| 247 | return this.setConfig(msg, "big", args[0]); |
| 248 | } |
| 249 | |
| 250 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 251 | |
| 252 | } catch (error: any) { |
| 253 | console.error("[trace] Error handling command:", error); |
| 254 | const errorMsg = `❌ <b>操作失败</b>\n` + |
| 255 | `├ 💔 错误类型: ${error.name || 'Unknown'}\n` + |
| 256 | `├ 📝 错误信息: ${htmlEscape(error.message)}\n` + |
| 257 | `└ 💡 请检查命令格式或稍后重试`; |
| 258 | await msg.edit({ |
| 259 | text: errorMsg, |
| 260 | parseMode: "html", |
| 261 | }); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * [MODIFIED] Now ignores messages sent by the bot itself to prevent feedback loops. |
| 267 | */ |
| 268 | private async handleMessage(msg: Api.Message) { |
| 269 | // Ensure we know who "I" am. |
| 270 | await this.initializeSelf(); |
| 271 | if (!this.db?.data || !msg.senderId || !this.meId) return; |
nothing calls this directly
no test coverage detected