| 182 | description: string = `疯狂星期四文案插件\n\n${help_text}`; |
| 183 | |
| 184 | cmdHandlers = { |
| 185 | crazy4: async (msg: Api.Message) => { |
| 186 | const client = await getGlobalClient(); |
| 187 | if (!client) { |
| 188 | await msg.edit({ text: "❌ 客户端未初始化", parseMode: "html" }); |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | try { |
| 193 | // 检查是否是帮助命令 |
| 194 | const text = msg.text?.trim() || ""; |
| 195 | if (text.includes("help") || text.includes("h")) { |
| 196 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | // 发送随机文案 |
| 201 | const randomIndex = Math.floor(Math.random() * crazy4_data.length); |
| 202 | const randomText = crazy4_data[randomIndex]; |
| 203 | |
| 204 | // 检查原消息是否在回复其他消息 |
| 205 | const replyToMsgId = msg.replyToMsgId; |
| 206 | |
| 207 | // 发送新消息,如果原消息是回复,则新消息也回复同一条 |
| 208 | await client.sendMessage(msg.peerId, { |
| 209 | message: `${htmlEscape(randomText)}`, |
| 210 | parseMode: "html", |
| 211 | replyTo: replyToMsgId // 保持原有的回复关系 |
| 212 | }); |
| 213 | |
| 214 | // 删除原命令消息 |
| 215 | await msg.delete({ revoke: true }); |
| 216 | |
| 217 | } catch (error: any) { |
| 218 | console.error("[crazy4] 插件执行失败:", error); |
| 219 | await msg.edit({ |
| 220 | text: `❌ <b>插件执行失败:</b> ${htmlEscape(error.message || "未知错误")}`, |
| 221 | parseMode: "html" |
| 222 | }); |
| 223 | } |
| 224 | } |
| 225 | }; |
| 226 | } |
| 227 | |
| 228 | export default new Crazy4Plugin(); |
nothing calls this directly
no test coverage detected