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

Method handleSet

xmsl/xmsl.ts:472–528  ·  view source on GitHub ↗
(msg: Api.Message, args: string[])

Source from the content-addressed store, hash-verified

470 });
471 return;
472 }
473
474 const key = args[0].toLowerCase();
475 const value = args.slice(1).join(' ');
476
477 try {
478 switch (key) {
479 case 'mode':
480 if (!['openai', 'gemini'].includes(value.toLowerCase())) {
481 await msg.edit({
482 text: "❌ mode 只能是 'openai' 或 'gemini'",
483 parseMode: 'html',
484 });
485 return;
486 }
487 this.config.apiMode = value.toLowerCase() as APIMode;
488 break;
489
490 case 'key':
491 this.config.apiKey = value;
492 break;
493
494 case 'url':
495 this.config.baseUrl = value.endsWith('/') ? value : value + '/';
496 break;
497
498 case 'model':
499 this.config.model = value.toLowerCase();
500 break;
501
502 default:
503 await msg.edit({
504 text: '❌ 未知配置项\n支持: mode, key, url, model',
505 parseMode: 'html',
506 });
507 return;
508 }
509
510 await this.saveConfig();
511 await msg.edit({
512 text: `✅ ${key} 已设置为: <code>${htmlEscape(value)}</code>`,
513 parseMode: 'html',
514 });
515 } catch (error: any) {
516 await msg.edit({
517 text: `❌ 设置失败: ${htmlEscape(error.message)}`,
518 parseMode: 'html',
519 });
520 }
521 }
522
523 private async showStatus(msg: Api.Message) {
524 const modeEmoji = this.config.apiMode === 'gemini' ? '🔵' : '🟠';
525 const statusText = `🧠 <b>XMSL 状态</b>
526
527${modeEmoji} 模式: ${this.config.apiMode}
528🔑 密钥: ${this.config.apiKey ? '✅ 已设置' : '❌ 未设置'}
529📍 地址: ${htmlEscape(this.config.baseUrl.replace(/\/$/, ''))}

Callers 1

handleXmslMethod · 0.95

Calls 3

saveConfigMethod · 0.95
htmlEscapeMethod · 0.95
editMethod · 0.45

Tested by

no test coverage detected