import{_ as i,c as n,o as a,ae as t}from"./chunks/framework.BHrE6nLq.js";const g=JSON.parse('{"title":"register","description":"","frontmatter":{"title":"register"},"headers":[],"relativePath":"en/dev/api/plugin/register.md","filePath":"en/dev/api/plugin/register.md","lastUpdated":1734175019000}'),e={name:"en/dev/api/plugin/register.md"};function l(h,s,p,r,k,o){return a(),n("div",null,s[0]||(s[0]=[t(`<h1 id="module-nonebot-plugin-marshoai-plugin-register" tabindex="-1"><strong>Module</strong> <code>nonebot_plugin_marshoai.plugin.register</code> <a class="header-anchor" href="#module-nonebot-plugin-marshoai-plugin-register" aria-label="Permalink to &quot;**Module** \`nonebot_plugin_marshoai.plugin.register\`&quot;">​</a></h1><p>此模块用于获取function call中函数定义信息以及注册函数</p><hr><h3 id="func-async-wrapper-func-sync-function-call-func-async-function-call-func" tabindex="-1"><em><strong>func</strong></em> <code>async_wrapper(func: SYNC_FUNCTION_CALL_FUNC) -&gt; ASYNC_FUNCTION_CALL_FUNC</code> <a class="header-anchor" href="#func-async-wrapper-func-sync-function-call-func-async-function-call-func" aria-label="Permalink to &quot;***func*** \`async_wrapper(func: SYNC_FUNCTION_CALL_FUNC) -&gt; ASYNC_FUNCTION_CALL_FUNC\`&quot;">​</a></h3><p><strong>Description</strong>: 将同步函数包装为异步函数，但是不会真正异步执行，仅用于统一调用及函数签名</p><p><strong>Arguments</strong>:</p><blockquote><ul><li>func: 同步函数</li></ul></blockquote><p><strong>Return</strong>: ASYNC_FUNCTION_CALL: 异步函数</p><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/plugin/register.py#L20" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> async_wrapper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SYNC_FUNCTION_CALL_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ASYNC_FUNCTION_CALL_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> wrapper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">        return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> wrapper</span></span></code></pre></div></details><hr><h3 id="func-function-call-funcs-function-call-func-none" tabindex="-1"><em><strong>func</strong></em> <code>function_call(*funcs: FUNCTION_CALL_FUNC) -&gt; None</code> <a class="header-anchor" href="#func-function-call-funcs-function-call-func-none" aria-label="Permalink to &quot;***func*** \`function_call(*funcs: FUNCTION_CALL_FUNC) -&gt; None\`&quot;">​</a></h3><p><strong>Arguments</strong>:</p><blockquote><ul><li>func: 函数对象，要有完整的 Google Style Docstring</li></ul></blockquote><p><strong>Return</strong>: str: 函数定义信息</p><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/plugin/register.py#L36" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> function_call</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">funcs: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">FUNCTION_CALL_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> funcs:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        function_call </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_function_info(func)</span></span></code></pre></div></details><hr><h3 id="func-get-function-info-func-function-call-func" tabindex="-1"><em><strong>func</strong></em> <code>get_function_info(func: FUNCTION_CALL_FUNC)</code> <a class="header-anchor" href="#func-get-function-info-func-function-call-func" aria-label="Permalink to &quot;***func*** \`get_function_info(func: FUNCTION_CALL_FUNC)\`&quot;">​</a></h3><p><strong>Description</strong>: 获取函数信息</p><p><strong>Arguments</strong>:</p><blockquote><ul><li>func: 函数对象</li></ul></blockquote><p><strong>Return</strong>: FunctionCall: 函数信息对象模型</p><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/plugin/register.py#L50" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_function_info</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">FUNCTION_CALL_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    description </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__doc__</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    logger.info(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;注册函数: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> {</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">description</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details>`,22)]))}const u=i(e,[["render",l]]);export{g as __pageData,u as default};
