mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-06-03 00:35:21 +00:00
2.0 KiB
Executable File
2.0 KiB
Executable File
title
title |
---|
register |
Module nonebot_plugin_marshoai.plugin.register
此模块用于获取function call中函数定义信息以及注册函数
func async_wrapper(func: SYNC_FUNCTION_CALL_FUNC) -> ASYNC_FUNCTION_CALL_FUNC
Description: 将同步函数包装为异步函数,但是不会真正异步执行,仅用于统一调用及函数签名
Arguments:
- func: 同步函数
Return: ASYNC_FUNCTION_CALL: 异步函数
Source code or View on GitHub
def async_wrapper(func: SYNC_FUNCTION_CALL_FUNC) -> ASYNC_FUNCTION_CALL_FUNC:
async def wrapper(*args, **kwargs) -> str:
return func(*args, **kwargs)
return wrapper
func function_call(*funcs: FUNCTION_CALL_FUNC) -> None
Arguments:
- func: 函数对象,要有完整的 Google Style Docstring
Return: str: 函数定义信息
Source code or View on GitHub
def function_call(*funcs: FUNCTION_CALL_FUNC) -> None:
for func in funcs:
function_call = get_function_info(func)
func get_function_info(func: FUNCTION_CALL_FUNC)
Description: 获取函数信息
Arguments:
- func: 函数对象
Return: FunctionCall: 函数信息对象模型
Source code or View on GitHub
def get_function_info(func: FUNCTION_CALL_FUNC):
name = func.__name__
description = func.__doc__
logger.info(f'注册函数: {name} {description}')