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

Function get_current_user_id

agents/master-coordinator/main.py:148–165  ·  view source on GitHub ↗

从 roles.json 获取当前角色的 user_id Returns: 用户 ID,如果 roles.json 不存在则返回 open_id

()

Source from the content-addressed store, hash-verified

146
147
148def get_current_user_id() -> str:
149 """
150 从 roles.json 获取当前角色的 user_id
151
152 Returns:
153 用户 ID,如果 roles.json 不存在则返回 open_id
154 """
155 import json
156 roles_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "data", "roles.json")
157 try:
158 with open(roles_path, 'r', encoding='utf-8') as f:
159 roles_data = json.load(f)
160 current_role = roles_data.get("current_role", "")
161 if current_role and current_role in roles_data.get("roles", {}):
162 return roles_data["roles"][current_role].get("user_id", "user_default")
163 except (FileNotFoundError, json.JSONDecodeError, KeyError):
164 pass
165 return "user_default"
166
167
168def send_message(text: str, chat_id: Optional[str] = None, user_id: Optional[str] = None) -> Dict[str, Any]:

Callers 1

__init__Method · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected