(msg: Api.Message)
| 335 | return targetId ? { id: targetId, name } : null; |
| 336 | } |
| 337 | |
| 338 | /* ====== cs (zero-request, reads cache) ====== */ |
| 339 | |
| 340 | private async doDet(msg: Api.Message, args: string[]) { |
| 341 | if (!this.cacheReady) { |
| 342 | await msg.edit({ text: "⏳ 缓存正在初始化,请稍后再试。", parseMode: "html" }); |
| 343 | return; |
| 344 | } |
| 345 | const target = await this.resolveTarget(msg, args); |
| 346 | if (!target) { |
| 347 | await msg.edit({ text: "❌ 无法识别目标,请回复消息或提供用户名/ID", parseMode: "html" }); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | await msg.edit({ text: `🔍 正在搜索嫌疑人 ${target.name} 的蛛丝马迹...`, parseMode: "html" }); |
| 352 | |
| 353 | let found: { msg: CachedMsg; peer: string } | null = null; |
| 354 | |
| 355 | for (const [peer, chat] of this.chatCache) { |
| 356 | for (const m of chat.msgs) { |
| 357 | if (String(m.senderId) === target.id) { |
| 358 | if (!found || m.date > found.msg.date) found = { msg: m, peer }; |
| 359 | break; // newest msg in this group, move on |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | await msg.delete().catch(() => {}); |
| 365 | |
| 366 | if (!found) { |
| 367 | await this.sendReply(msg, `🤦♀ 暂时没发现 ${target.name} 有作案嫌疑。`); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | // build link from cache, no API call needed |
| 372 | const chat = this.chatCache.get(found.peer)!; |
| 373 | const text = htmlEsc((found.msg.text || "").slice(0, 50) || "[媒体消息]"); |
| 374 | const link = chat.username |
| 375 | ? `<a href="https://t.me/${chat.username}/${found.msg.id}">${text}</a>` |
| 376 | : `<a href="https://t.me/c/${peelChatId(found.peer)}/${found.msg.id}">${text}</a>`; |
| 377 | await this.sendReply(msg, `👀 发现嫌疑人 ${target.name} 的作案现场:\n\n${link}\n\n<i>要想人不知除非己莫为。</i>`); |
| 378 | } |
| 379 | |
| 380 | /* ====== sv ====== */ |
| 381 | |
| 382 | private async doSur(msg: Api.Message, args: string[]) { |
| 383 | const cl = await getGlobalClient(); |
| 384 | if (!cl) return; |
| 385 | const target = await this.resolveTarget(msg, args); |
| 386 | if (!target) { |
| 387 | await msg.edit({ text: "❌ 无法识别目标", parseMode: "html" }); |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | await msg.edit({ text: `👁️ 正在对嫌疑人 ${target.name} 进行蹲守...`, parseMode: "html" }); |
| 392 | |
| 393 | this.sv.set(target.id, { |
| 394 | targetId: target.id, |
nothing calls this directly
no test coverage detected