(msg: Api.Message, text: string)
| 522 | `├ ${icon} 项目: ${configName}\n` + |
| 523 | `├ 🔄 旧值: ${previousValue ? '✅ 启用' : '❌ 禁用'}\n` + |
| 524 | `├ ✨ 新值: ${boolValue ? '✅ 启用' : '❌ 禁用'}\n` + |
| 525 | `└ 💾 配置已保存`; |
| 526 | await this.editAndDelete(msg, configMsg, 10); |
| 527 | } |
| 528 | |
| 529 | private async formatEntity(target: string | Api.TypePeer, mention?: boolean, throwErrorIfFailed?: boolean) { |
| 530 | const client = await getGlobalClient(); |
| 531 | if (!client) throw new Error("客户端未初始化"); |
| 532 | let id: any, entity: any; |
| 533 | try { |
| 534 | entity = (typeof target !== 'string' && target?.className) ? target : await client?.getEntity(target); |
| 535 | if (!entity) throw new Error("无法获取entity"); |
| 536 | id = entity.id; |
| 537 | } catch (e: any) { |
| 538 | if (throwErrorIfFailed) throw new Error(`无法获取 ${target}: ${e?.message}`); |
| 539 | } |
| 540 | const displayParts: string[] = []; |
| 541 | if (entity?.title) displayParts.push(htmlEscape(entity.title)); |
| 542 | if (entity?.firstName) displayParts.push(htmlEscape(entity.firstName)); |
| 543 | if (entity?.lastName) displayParts.push(htmlEscape(entity.lastName)); |
| 544 | if (entity?.username) { |
| 545 | displayParts.push(mention ? `@${entity.username}` : `<code>@${entity.username}</code>`); |
| 546 | } |
| 547 | if (id) { |
| 548 | displayParts.push( |
| 549 | entity instanceof Api.User |
| 550 | ? `<a href="tg://user?id=${id}">${id}</a>` |
| 551 | : `<a href="https://t.me/c/${id}">${id}</a>` |
| 552 | ); |
| 553 | } |
| 554 | return { id, entity, display: displayParts.join(" ").trim() }; |
| 555 | } |
| 556 | |
| 557 | private async parseReactions(msg: Api.Message, text: string): Promise<(string | BigInteger)[]> { |
no test coverage detected