| 711 | const helpResponse = `🛰️ <b>保送插件</b>\n\n${escapeHtml(helpText)}`; |
| 712 | |
| 713 | class BsPlugin extends Plugin { |
| 714 | |
| 715 | description: string = `保送被回复的消息至指定目标\n\n${helpText}`; |
| 716 | |
| 717 | cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = { |
| 718 | [pluginName]: async (msg: Api.Message) => { |
| 719 | const client = await getGlobalClient(); |
| 720 | if (!client) { |
| 721 | await msg.edit({ text: "❌ <b>客户端未初始化</b>", parseMode: "html" }); |
| 722 | return; |
| 723 | } |
| 724 | |
| 725 | const text = msg.message || msg.text || ""; |
| 726 | const lines = text.trim().split(/\r?\n/); |
| 727 | const head = lines[0] || ""; |
| 728 | const parts = head.trim().split(/\s+/).filter(Boolean); |
| 729 | const args = parts.slice(1); |
| 730 | const command = (args[0] || "").toLowerCase(); |
| 731 | |
| 732 | if (!command || /^\d+$/.test(command)) { |
| 733 | const count = command ? Number(command) : 1; |
| 734 | if (!count || count <= 0) { |
| 735 | await msg.edit({ |
| 736 | text: `❌ <b>消息数必须是正整数</b>\n示例:<code>${commandName} 3</code>`, |
| 737 | parseMode: "html", |
| 738 | linkPreview: false, |
| 739 | }); |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | if (!msg.isReply) { |
| 744 | await msg.edit({ |
| 745 | text: "❌ <b>请先回复需要保送的消息</b>", |
| 746 | parseMode: "html", |
| 747 | }); |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | const replyMessage = await safeGetReplyMessage(msg); |
| 752 | if (!replyMessage) { |
| 753 | await msg.edit({ |
| 754 | text: "❌ <b>无法获取被回复的消息</b>", |
| 755 | parseMode: "html", |
| 756 | }); |
| 757 | return; |
| 758 | } |
| 759 | |
| 760 | await msg.edit({ |
| 761 | text: "🚚 <b>正在保送消息...</b>", |
| 762 | parseMode: "html", |
| 763 | }); |
| 764 | |
| 765 | const peerForFetch = msg.peerId ?? replyMessage.peerId; |
| 766 | const { messageIds } = await collectMessages( |
| 767 | client, |
| 768 | peerForFetch, |
| 769 | replyMessage.id, |
| 770 | count |
nothing calls this directly
no test coverage detected