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

Function setApiKey

t/t.ts:384–399  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

382 }
383 userData.users[userId].defaultRole = roleName;
384 userData.users[userId].defaultRoleId = userData.roles[roleName];
385 await saveUserData(userData);
386 await msg.edit({ text: `✅ 默认角色已切换为: ${roleName}` });
387 } else {
388 await msg.edit({ text: `❌ 无效的角色名:${roleName}\n提示:可以用 ".ts 角色名 角色ID" 直接新增。` });
389 }
390}
391
392async function setApiKey(msg: Api.Message) {
393 const userId = msg.senderId?.toString();
394 if (!userId) return;
395 const [, apiKey] = msg.text?.split(/\s+/).filter(Boolean) || [];
396 if (!apiKey) {
397 await msg.edit({ text: "❌ 请提供 API Key" });
398 return;
399 }
400 const userData = await loadUserData();
401 if (!userData.users[userId]) {
402 userData.users[userId] = { apiKey, defaultRole: "雷军", defaultRoleId: userData.roles["雷军"] };

Callers

nothing calls this directly

Calls 3

loadUserDataFunction · 0.85
saveUserDataFunction · 0.85
editMethod · 0.45

Tested by

no test coverage detected