(message: Api.Message)
| 1652 | if (!getActiveLifecycle()) return; |
| 1653 | if (!(await waitDb())) return; |
| 1654 | const client = message.client as TelegramClient; |
| 1655 | const args = message.message.slice(1).split(/\s+/).slice(1); |
| 1656 | const command = (args[0] || "help").toLowerCase(); |
| 1657 | |
| 1658 | // ── on / off:启用 / 禁用插件 ──────────────────────────────────────────────── |
| 1659 | // 注意:off 只停用插件本身,不重置 captcha 状态,下次 on 后自动恢复 |
| 1660 | if (command === "on" || command === "off") { |
| 1661 | const enabling = command === "on"; |
| 1662 | set(K.ENABLED, enabling); |
| 1663 | // ⚠️ 不再自动关闭 captcha_enabled,保留验证配置状态 |
| 1664 | try { |
| 1665 | const tmp = await client.sendMessage(message.peerId, { |
| 1666 | message: enabling |
| 1667 | ? "✅ <b>PMCaptcha 已启用</b>" |
| 1668 | : `🚫 <b>PMCaptcha 已禁用</b>\n验证配置已保留,下次启用后自动恢复`, |
| 1669 | parseMode: "html" |
| 1670 | }); |
| 1671 | try { await message.delete(); } catch {} |
| 1672 | getActiveLifecycle()?.setTimeout(() => { |
| 1673 | void tmp.delete().catch(() => undefined); |
| 1674 | }, 3000, { label: "pmcaptcha-command-cleanup" }); |
| 1675 | } catch (e) { log(LogLevel.ERROR, "pmc on/off error", e); } |
| 1676 | return; |
| 1677 | } |
| 1678 | |
| 1679 | const edit = async (text: string) => { |
| 1680 | try { |
| 1681 | await client.editMessage(message.peerId, { |
| 1682 | message: message.id, |
| 1683 | text, |
| 1684 | parseMode: "html", |
| 1685 | linkPreview: false |
| 1686 | }); |
| 1687 | } catch (e: any) { |
| 1688 | if (String(e).includes("Could not find the input entity")) { |
| 1689 | try { await message.reply({ message: text, parseMode: "html", linkPreview: false }); } catch {} |
| 1690 | } else { |
| 1691 | throw e; |
| 1692 | } |
| 1693 | } |
| 1694 | }; |
| 1695 | |
| 1696 | try { |
| 1697 | switch (command) { |
| 1698 | |
| 1699 | // ╔══════════════════════════════╗ |
| 1700 | // ║ 帮助 (.pmc h [section]) ║ |
| 1701 | // ╚══════════════════════════════╝ |
| 1702 | |
| 1703 | case "help": case "h": case "?": case "": { |
| 1704 | const section = args[1]?.toLowerCase(); |
| 1705 | await edit(helpText(section)); |
| 1706 | break; |
| 1707 | } |
| 1708 | |
| 1709 | // ╔══════════════════════════════╗ |
| 1710 | // ║ 状态 (.pmc status) ║ |
| 1711 | // ╚══════════════════════════════╝ |
nothing calls this directly
no test coverage detected