MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / process_role_command

Function process_role_command

agents/role-manager/main.py:375–429  ·  view source on GitHub ↗

处理角色命令 Args: command_text: 用户命令 feishu_user_id: 飞书用户 ID send_to_feishu: 是否发送飞书 Returns: 处理结果

(
    command_text: str,
    feishu_user_id: Optional[str] = None,
    send_to_feishu: bool = True
)

Source from the content-addressed store, hash-verified

373
374
375def process_role_command(
376 command_text: str,
377 feishu_user_id: Optional[str] = None,
378 send_to_feishu: bool = True
379) -> Dict[str, Any]:
380 """
381 处理角色命令
382
383 Args:
384 command_text: 用户命令
385 feishu_user_id: 飞书用户 ID
386 send_to_feishu: 是否发送飞书
387
388 Returns:
389 处理结果
390 """
391 import re
392
393 command = parse_role_command(command_text)
394
395 if not command:
396 return {"success": False, "message": "未识别到有效命令"}
397
398 action = command.get("action")
399
400 if action == "create":
401 result = create_role(
402 role_name=command["role_name"],
403 natural_language=command.get("natural_language", ""),
404 feishu_chat_id=command.get("feishu_chat_id"),
405 )
406 elif action == "bind":
407 result = bind_chat_id(
408 role_name=command["role_name"],
409 feishu_chat_id=command["feishu_chat_id"],
410 )
411 elif action == "switch":
412 result = switch_role(command["role_name"])
413 elif action == "list":
414 result = list_roles()
415 if result["success"]:
416 result["formatted"] = format_role_list(result)
417 elif action == "delete":
418 result = delete_role(command["role_name"])
419 else:
420 result = {"success": False, "message": "未知命令"}
421
422 # 发送到飞书
423 if send_to_feishu and feishu_user_id and result.get("success"):
424 if "formatted" in result:
425 send_text(feishu_user_id, result["formatted"])
426 else:
427 send_text(feishu_user_id, result.get("message", "操作完成"))
428
429 return result
430
431
432if __name__ == "__main__":

Callers 1

main.pyFile · 0.85

Calls 9

parse_role_commandFunction · 0.85
bind_chat_idFunction · 0.85
format_role_listFunction · 0.85
send_textFunction · 0.85
getMethod · 0.80
create_roleFunction · 0.70
switch_roleFunction · 0.70
list_rolesFunction · 0.70
delete_roleFunction · 0.70

Tested by

no test coverage detected