绑定飞书群 ID 到角色 Args: role_name: 角色名 feishu_chat_id: 飞书群 ID Returns: 绑定结果
(role_name: str, feishu_chat_id: str)
| 275 | """ |
| 276 | 绑定飞书群 ID 到角色 |
| 277 | |
| 278 | Args: |
| 279 | role_name: 角色名 |
| 280 | feishu_chat_id: 飞书群 ID |
| 281 | |
| 282 | Returns: |
| 283 | 绑定结果 |
| 284 | """ |
| 285 | meta = load_roles_meta() |
| 286 | |
| 287 | if role_name not in meta["roles"]: |
| 288 | return {"success": False, "message": f"角色 {role_name} 不存在"} |
| 289 | |
| 290 | meta["roles"][role_name]["feishu_chat_id"] = feishu_chat_id |
| 291 | save_roles_meta(meta) |
| 292 | |
| 293 | # 同时更新画像 |
| 294 | user_id = f"user_{role_name}" |
| 295 | profile = get_profile(user_id) |
| 296 | if profile: |
| 297 | profile["feishu_chat_id"] = feishu_chat_id |
| 298 | profile["updated_at"] = datetime.now().isoformat() |
| 299 | update_profile(user_id, profile) |
| 300 | |
| 301 | return { |
| 302 | "success": True, |
| 303 | "message": f"已将角色 {role_name} 绑定到飞书群 {feishu_chat_id}", |
| 304 | } |
| 305 | |
| 306 | |
| 307 | def parse_role_command(text: str) -> Optional[Dict[str, Any]]: |
| 308 | """ |
| 309 | 解析角色命令 |
| 310 |
no test coverage detected