| 121 | |
| 122 | description: string = help_text; |
| 123 | |
| 124 | cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = { |
| 125 | epic: async (msg: Api.Message) => { |
| 126 | const client = await getGlobalClient(); |
| 127 | if (!client) { |
| 128 | await msg.edit({ text: "❌ 客户端未初始化", parseMode: "html" }); |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | const parts = msg.text?.trim().split(/\s+/) || []; |
| 133 | const sub = (parts[1] || "").toLowerCase(); |
| 134 | |
| 135 | if (sub === "help" || sub === "h") { |
| 136 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | try { |
| 141 | await msg.edit({ text: "🎮 获取 Epic 限免游戏中...", parseMode: "html" }); |
| 142 | |
| 143 | const res = await axios.get(EPIC_API_URL, { timeout: 15000 }); |
| 144 | const { current, upcoming } = parseFreeGames(res.data); |
| 145 | |
| 146 | let text = "🎮 <b>Epic Games 限免游戏</b>\n\n"; |
| 147 | |
| 148 | if (current.length > 0) { |
| 149 | text += "📢 <b>当前限免:</b>\n\n"; |
| 150 | current.forEach((g, i) => (text += buildGameText(g, i + 1) + "\n\n")); |
| 151 | } else { |
| 152 | text += "📢 <b>当前限免:</b> 暂无\n\n"; |
| 153 | } |
| 154 | |
| 155 | await msg.edit({ text, parseMode: "html", linkPreview: false }); |
| 156 | } catch (error: any) { |
| 157 | console.error("[epic] 获取失败:", error); |
| 158 | await msg.edit({ text: `❌ <b>获取失败:</b> ${htmlEscape(error.message || "网络错误")}`, parseMode: "html" }); |
| 159 | } |
| 160 | }, |
| 161 | }; |
| 162 | } |
| 163 | |
| 164 | export default new EpicPlugin(); |
| 165 |
nothing calls this directly
no test coverage detected