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

Method execute

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

Source from the content-addressed store, hash-verified

4034
4035 async execute(
4036 msg: Api.Message,
4037 args: string[],
4038 _prefixes: string[],
4039 ): Promise<void> {
4040 const configManager = await this.getConfigManager();
4041 const config = configManager.getConfig();
4042
4043 if (args.length < 2) {
4044 await this.editMessage(
4045 msg,
4046 `🤖 <b>当前 AI 配置:</b>\n\n` +
4047 `💬 chat 配置: <code>${config.currentChatTag || "未设置"}</code>\n` +
4048 `🧠 chat 模型: <code>${config.currentChatModel || "未设置"}</code>\n` +
4049 `🔎 search 配置: <code>${config.currentSearchTag || "未设置"}</code>\n` +
4050 `📚 search 模型: <code>${config.currentSearchModel || "未设置"}</code>\n` +
4051 `🖼️ image 配置: <code>${config.currentImageTag || "未设置"}</code>\n` +
4052 `🎨 image 模型: <code>${config.currentImageModel || "未设置"}</code>\n` +
4053 `🎬 video 配置: <code>${config.currentVideoTag || "未设置"}</code>\n` +
4054 `📹 video 模型: <code>${config.currentVideoModel || "未设置"}</code>`,
4055 );
4056 return;
4057 }
4058
4059 const mode = args[1]?.toLowerCase();
4060 requireUser(
4061 mode === "chat" ||
4062 mode === "search" ||
4063 mode === "image" ||
4064 mode === "video",
4065 "参数格式错误",
4066 );
4067 requireUser(args.length >= 4, "参数不足");
4068
4069 const model = args[args.length - 1];
4070 const tag = args.slice(2, -1).join(" ").trim();
4071 requireUser(!!config.configs[tag], `配置标签 "${tag}" 不存在`);
4072
4073 await configManager.updateConfig((cfg) => {
4074 if (mode === "chat") {
4075 cfg.currentChatTag = tag;
4076 cfg.currentChatModel = model;
4077 } else if (mode === "search") {
4078 cfg.currentSearchTag = tag;
4079 cfg.currentSearchModel = model;
4080 } else if (mode === "video") {
4081 cfg.currentVideoTag = tag;
4082 cfg.currentVideoModel = model;
4083 } else {
4084 cfg.currentImageTag = tag;
4085 cfg.currentImageModel = model;
4086 }
4087 });
4088
4089 const modeLabel =
4090 mode === "chat"
4091 ? "chat 模型"
4092 : mode === "search"
4093 ? "search 模型"

Callers

nothing calls this directly

Calls 5

getConfigManagerMethod · 0.80
editMessageMethod · 0.80
requireUserFunction · 0.70
getConfigMethod · 0.45
updateConfigMethod · 0.45

Tested by

no test coverage detected