MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / call

Method call

astrbot/core/tools/computer_tools/python.py:84–110  ·  view source on GitHub ↗
(
        self,
        context: ContextWrapper[AstrAgentContext],
        code: str,
        silent: bool = False,
        timeout: int = 30,
    )

Source from the content-addressed store, hash-verified

82 parameters: dict = field(default_factory=lambda: param_schema)
83
84 async def call(
85 self,
86 context: ContextWrapper[AstrAgentContext],
87 code: str,
88 silent: bool = False,
89 timeout: int = 30,
90 ) -> ToolExecResult:
91 if permission_error := check_admin_permission(context, "Python execution"):
92 return permission_error
93 sb = await get_booter(
94 context.context.context,
95 context.context.event.unified_msg_origin,
96 )
97 effective_timeout = (
98 min(timeout, context.tool_call_timeout)
99 if timeout > 0
100 else context.tool_call_timeout
101 )
102 try:
103 result = await sb.python.exec(
104 code,
105 timeout=effective_timeout,
106 silent=silent,
107 )
108 return await handle_result(result, context.context.event)
109 except Exception as e:
110 return f"Error executing code: {str(e)}"
111
112
113@builtin_tool(config=_LOCAL_PYTHON_TOOL_CONFIG)

Callers

nothing calls this directly

Calls 4

get_booterFunction · 0.90
check_admin_permissionFunction · 0.85
handle_resultFunction · 0.85
execMethod · 0.45

Tested by

no test coverage detected