( msg: Api.Message, trigger: Api.Message | undefined, options: CommandResponse, ignoreNotModified?: boolean )
| 144 | ): Promise<void> { |
| 145 | if (!trigger) { |
| 146 | if (ignoreNotModified) { |
| 147 | await editMessageIgnoringNotModified(msg, options); |
| 148 | return; |
| 149 | } |
| 150 | await msg.edit(options); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | const client = trigger.client || msg.client; |
| 155 | const peer = trigger.peerId || msg.peerId; |
| 156 | if (!client || !peer) { |
| 157 | await editMessageIgnoringNotModified(msg, options); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | const sendOptions = { |
| 162 | message: options.text, |
| 163 | ...(options.parseMode ? { parseMode: options.parseMode } : {}), |
| 164 | }; |
| 165 | |
| 166 | try { |
| 167 | await client.sendMessage(peer, { |
| 168 | ...sendOptions, |
| 169 | replyTo: trigger.id, |
| 170 | }); |
| 171 | } catch { |
| 172 | await client.sendMessage(peer, sendOptions); |
| 173 | } |
| 174 | |
| 175 | await deleteMessageQuiet(msg); |
| 176 | } |
| 177 | |
| 178 | function parseDurationMinutes(raw?: string): number { |
| 179 | if (!raw) return defaultDurationMinutes; |
| 180 | const minutes = Number(raw); |
| 181 | if (!Number.isFinite(minutes) || minutes <= 0) { |
| 182 | throw new Error("时长必须是大于 0 的分钟数"); |
| 183 | } |
| 184 | return minutes; |
| 185 | } |
| 186 |
no test coverage detected