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

Method execute

ai/ai.ts:3797–3847  ·  view source on GitHub ↗
(
    msg: Api.Message,
    args: string[],
    _prefixes: string[],
  )

Source from the content-addressed store, hash-verified

3795
3796 async execute(
3797 msg: Api.Message,
3798 args: string[],
3799 _prefixes: string[],
3800 ): Promise<void> {
3801 const configManager = await this.getConfigManager();
3802 const config = configManager.getConfig();
3803
3804 if (args.length < 2) {
3805 const list =
3806 Object.values(config.configs)
3807 .map(
3808 (c) =>
3809 `🏷️ <code>${c.tag}</code> - ${c.url}\n🧩 Type: <code>${formatProviderTypeLabel(c)}</code>\n🌊 Stream: <code>${c.stream ? "on" : "off"}</code>\n🧠 Responses(chat/search): <code>${c.responses ? "on" : "off"}</code>`,
3810 )
3811 .join("\n") || "暂无配置";
3812 await this.editMessage(
3813 msg,
3814 `📋 <b>API 配置列表:</b>\n\n⚙️ 配置:\n${list}`,
3815 );
3816 return;
3817 }
3818
3819 const action = args[1].toLowerCase();
3820 if (action === "add") {
3821 requireUser(args.length >= 5, "参数格式错误");
3822 await this.addConfig(msg, args, configManager);
3823 return;
3824 }
3825 if (action === "del") {
3826 requireUser(args.length >= 3, "参数格式错误");
3827 await this.deleteConfig(msg, args, configManager);
3828 return;
3829 }
3830 if (action === "stream") {
3831 requireUser(args.length >= 4, "参数不足");
3832 await this.setStream(msg, args, configManager);
3833 return;
3834 }
3835 if (action === "responses") {
3836 requireUser(args.length >= 4, "参数不足");
3837 await this.setResponses(msg, args, configManager);
3838 return;
3839 }
3840 if (action === "type") {
3841 requireUser(args.length >= 4, "参数不足");
3842 await this.setProviderType(msg, args, configManager);
3843 return;
3844 }
3845 throw new UserError("参数格式错误");
3846 }
3847
3848 private parseProviderType(value: string): ProviderType {
3849 const providerType = normalizeProviderType(value);
3850 requireUser(!!providerType, `type 必须是 ${PROVIDER_TYPE_OPTIONS}`);

Callers

nothing calls this directly

Calls 10

addConfigMethod · 0.95
deleteConfigMethod · 0.95
setStreamMethod · 0.95
setResponsesMethod · 0.95
setProviderTypeMethod · 0.95
formatProviderTypeLabelFunction · 0.85
getConfigManagerMethod · 0.80
editMessageMethod · 0.80
requireUserFunction · 0.70
getConfigMethod · 0.45

Tested by

no test coverage detected