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

Class ConfigFeature

ai/ai.ts:3788–4025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3786
3787class ConfigFeature extends BaseFeatureHandler {
3788 readonly name = "配置管理";
3789 readonly command = "config";
3790 readonly description = "管理 API 配置";
3791
3792 constructor(configManagerPromise: Promise<ConfigManager>) {
3793 super(configManagerPromise);
3794 }
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("参数格式错误");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected