(msg: Api.Message)
| 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 | |
| 392 | async 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["雷军"] }; |
nothing calls this directly
no test coverage detected