(msg: Api.Message, args: string[], chatId: string)
| 226 | /* ===================== 白名单处理 ===================== */ |
| 227 | |
| 228 | private async handleWhiteList(msg: Api.Message, args: string[], chatId: string): Promise<void> { |
| 229 | const list = this.db.data.whitelist; |
| 230 | |
| 231 | switch (args[2]) { |
| 232 | case "add": |
| 233 | if (!list.includes(chatId)) list.push(chatId); |
| 234 | await this.db.write(); |
| 235 | await msg.edit({ |
| 236 | text: `✔ 已将本会话加入白名单`, |
| 237 | parseMode: "html", |
| 238 | }); |
| 239 | return; |
| 240 | |
| 241 | case "remove": |
| 242 | _.remove(list, (x) => x === chatId); |
| 243 | await this.db.write(); |
| 244 | await msg.edit({ |
| 245 | text: `✔ 已将本会话移出白名单`, |
| 246 | parseMode: "html", |
| 247 | }); |
| 248 | return; |
| 249 | |
| 250 | case "list": |
| 251 | await msg.edit({ |
| 252 | text: `⚪ 白名单列表:\n<code>${htmlEscape(list.join("\n")) || "空"}</code>`, |
| 253 | parseMode: "html", |
| 254 | }); |
| 255 | return; |
| 256 | |
| 257 | default: |
| 258 | await msg.edit({ text: help_text, parseMode: "html" }); |
| 259 | return; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /* ===================== 黑名单处理 ===================== */ |
| 264 |
no test coverage detected