# dev | Marsho AI
Kawaii, Intelligent and Easy to Extend

Skip to content

# Module `nonebot_plugin_marshoai.dev` ​

`@function_call.assign('list')`

### async func `list_functions()` ​

Source code or View on GitHub
python

    @function_call.assign('list')
    async def list_functions():
        reply = '共有如下可调用函数:\n'
        for function in get_function_calls().values():
            reply += f'- {function.short_info}\n'
        await UniMessage(reply).send()

`@function_call.assign('info')`

### async func `function_info(function_name: str)` ​

Source code or View on GitHub
python

    @function_call.assign('info')
    async def function_info(function_name: str):
        function = get_function_calls().get(function_name)
        if function is None:
            await UniMessage(f'未找到函数 {function_name}').send()
            return
        await UniMessage(str(function)).send()

`@function_call.assign('call')`

### async func `call_function(function_name: str, kwargs: list[str], event: Event, bot: Bot, matcher: Matcher, state: T_State)` ​

Source code or View on GitHub
python

    @function_call.assign('call')
    async def call_function(function_name: str, kwargs: list[str], event: Event, bot: Bot, matcher: Matcher, state: T_State):
        function = get_function_calls().get(function_name)
        if function is None:
            for f in get_function_calls().values():
                if f.short_name == function_name:
                    function = f
                    break
            else:
                await UniMessage(f'未找到函数 {function_name}').send()
                return
        await UniMessage(str(await function.with_ctx(SessionContext(event=event, bot=bot, matcher=matcher, state=state)).call(**{i.split('=', 1)[0]: i.split('=', 1)[1] for i in kwargs}))).send()

`@on_file_system_event((str(Path(__file__).parent / 'plugins'), *config.marshoai_plugin_dirs), recursive=True)`

### func `on_plugin_file_change(event)` ​

Source code or View on GitHub
python

    @on_file_system_event((str(Path(__file__).parent / 'plugins'), *config.marshoai_plugin_dirs), recursive=True)
    def on_plugin_file_change(event):
        if event.src_path.endswith('.py'):
            logger.info(f'文件变动: {event.src_path}')
            dir_list: list[str] = event.src_path.split('/')
            dir_list[-1] = dir_list[-1].split('.', 1)[0]
            dir_list.reverse()
            for plugin_name in dir_list:
                if (plugin := get_plugin(plugin_name)):
                    if plugin.module_path.endswith('__init__.py'):
                        if os.path.dirname(plugin.module_path).replace('\\', '/') in event.src_path.replace('\\', '/'):
                            logger.debug(f'找到变动插件: {plugin.name}，正在重新加载')
                            reload_plugin(plugin)
                            context.reset_all()
                            break
                    elif plugin.module_path == event.src_path:
                        logger.debug(f'找到变动插件: {plugin.name}，正在重新加载')
                        reload_plugin(plugin)
                        context.reset_all()
                        break
            else:
                logger.debug('未找到变动插件')
                return

### var `dir_list` ​

- Description: type: ignore

- Type: `list[str]`

- Default: `event.src_path.split('/')`