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

Method addConfig

ai/ai.ts:3890–3925  ·  view source on GitHub ↗
(
    msg: Api.Message,
    args: string[],
    configManager: ConfigManager,
  )

Source from the content-addressed store, hash-verified

3888
3889 private async addConfig(
3890 msg: Api.Message,
3891 args: string[],
3892 configManager: ConfigManager,
3893 ): Promise<void> {
3894 requireUser(
3895 !!(msg as any).savedPeerId,
3896 "出于安全考虑,禁止在公开场景添加/修改 API 密钥",
3897 );
3898 const { tag, url, key, type } = this.parseAddConfigArgs(args);
3899
3900 requireUser(!!key.trim(), "API 密钥不能为空");
3901 requireUser(key.length >= 10, "API 密钥长度过短");
3902
3903 await configManager.updateConfig((cfg) => {
3904 cfg.configs[tag] = {
3905 tag,
3906 url,
3907 key,
3908 type,
3909 stream: false,
3910 responses: false,
3911 };
3912 });
3913
3914 await this.editMessage(
3915 msg,
3916 "✅ API 配置已添加:\n\n" +
3917 `🏷️ 标签: <code>${tag}</code>\n` +
3918 `🔗 地址: <code>${url}</code>\n` +
3919 `🧩 Type: <code>${formatProviderTypeLabel({ url, type })}</code>\n` +
3920 `🔑 密钥: <code>${key}</code>\n` +
3921 `🌊 Stream: <code>off</code>\n` +
3922 `🧠 Responses(chat/search): <code>off</code>`,
3923 );
3924 }
3925
3926 private async setStream(
3927 msg: Api.Message,
3928 args: string[],

Callers 1

executeMethod · 0.95

Calls 5

parseAddConfigArgsMethod · 0.95
formatProviderTypeLabelFunction · 0.85
editMessageMethod · 0.80
requireUserFunction · 0.70
updateConfigMethod · 0.45

Tested by

no test coverage detected