MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / handle

Method handle

search/search.ts:180–227  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

178 }
179
180 public async handle(msg: Api.Message) {
181 let fullArgs = msg.message.substring(4).trim();
182 const useSpoiler = fullArgs.toLowerCase().includes(" -s");
183 const useRandom = fullArgs.toLowerCase().includes(" -r");
184
185 if (useSpoiler) fullArgs = fullArgs.replace(/\s+-s/i, "").trim();
186 if (useRandom) fullArgs = fullArgs.replace(/\s+-r/i, "").trim();
187
188 const args = fullArgs.split(/\s+/);
189 const subCommand = args[0]?.toLowerCase() as SubCommand;
190 const subCommandArgs = args.slice(1).join(" ");
191
192 const adminMsg = await msg.edit({ text: `⚙️ 正在执行命令...` });
193 if (!adminMsg) return;
194
195 try {
196 switch (subCommand) {
197 case SubCommand.Add:
198 await this.handleAdd(adminMsg, subCommandArgs);
199 break;
200 case SubCommand.Delete:
201 await this.handleDelete(adminMsg, subCommandArgs);
202 break;
203 case SubCommand.Default:
204 await this.handleDefault(adminMsg, subCommandArgs);
205 break;
206 case SubCommand.List:
207 await this.handleList(adminMsg);
208 break;
209 case SubCommand.Export:
210 await this.handleExport(msg);
211 break;
212 case SubCommand.Import:
213 await this.handleImport(msg);
214 break;
215 case SubCommand.Kkp:
216 await this.handleKkp(msg, useSpoiler);
217 break;
218 case SubCommand.Ad:
219 await this.handleAd(msg, subCommandArgs);
220 break;
221 default:
222 await this.handleSearch(msg, fullArgs, useSpoiler, useRandom);
223 }
224 } catch (error: any) {
225 await adminMsg.edit({ text: `❌ 错误:\n${error.message}` });
226 }
227 }
228
229 private async handleAdd(msg: Api.Message, args: string) {
230 if (!args) throw new Error("请提供频道链接或 @username,使用 \\ 分隔。");

Callers 1

soFunction · 0.95

Calls 10

handleAddMethod · 0.95
handleDeleteMethod · 0.95
handleDefaultMethod · 0.95
handleListMethod · 0.95
handleExportMethod · 0.95
handleImportMethod · 0.95
handleKkpMethod · 0.95
handleAdMethod · 0.95
handleSearchMethod · 0.95
editMethod · 0.45

Tested by

no test coverage detected