(msg: Api.Message)
| 77 | |
| 78 | try { |
| 79 | // 检查是否在群组中 |
| 80 | if (!(msg.chat instanceof Api.Chat || msg.chat instanceof Api.Channel)) { |
| 81 | await msg.edit({ |
| 82 | text: "❌ <b>错误:</b>此命令只能在群组或超级群组中使用", |
| 83 | parseMode: "html" |
| 84 | }); |
| 85 | await this.autoDelete(msg, 5); |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | // 获取回复消息 |
| 90 | const replyMsg = await safeGetReplyMessage(msg); |
| 91 | if (!replyMsg) { |
| 92 | await msg.edit({ |
| 93 | text: "❌ <b>错误:</b>请回复要禁言用户的消息", |
| 94 | parseMode: "html" |
| 95 | }); |
| 96 | await this.autoDelete(msg, 5); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | // 获取发送者 |
| 101 | const sender = replyMsg.sender; |
| 102 | if (!sender) { |
| 103 | await msg.edit({ |
| 104 | text: "❌ <b>错误:</b>无法获取用户信息", |
| 105 | parseMode: "html" |
| 106 | }); |
| 107 | await this.autoDelete(msg, 5); |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | // 检查是否为自己 |
| 112 | const self = await safeGetMe(client); |
| 113 | if (!self) return; |
| 114 | if (sender.id?.eq?.(self.id)) { |
| 115 | await msg.edit({ |
| 116 | text: "❌ <b>错误:</b>无法禁言自己", |
| 117 | parseMode: "html" |
| 118 | }); |
| 119 | await this.autoDelete(msg, 5); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | // 解析参数 |
| 124 | const text = msg.text || ""; |
| 125 | const parts = text.trim().split(/\s+/).slice(1); |
| 126 | |
| 127 | let reason = ""; |
| 128 | let seconds = -1; |
| 129 | |
| 130 | if (parts.length === 1) { |
| 131 | seconds = parseTimeString(parts[0]); |
| 132 | if (seconds === -1) { |
| 133 | await msg.edit({ |
| 134 | text: "❌ <b>错误:</b>无效的时间参数", |
| 135 | parseMode: "html" |
| 136 | }); |
nothing calls this directly
no test coverage detected