mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-24 22:25:06 +08:00
Deploying to docs from @ LiteyukiStudio/LiteyukiBot@7bf94a15c8 🚀
This commit is contained in:
parent
e94846f1a4
commit
e13e920f5d
@ -1 +1 @@
|
||||
import{R as p}from"./chunks/theme.CoOFLGSO.js";import{R as o,a8 as u,a9 as l,aa as c,ab as f,ac as d,ad as m,ae as h,af as g,ag as A,ah as v,d as P,u as R,v as w,s as y,ai as C,aj as b,ak as E,al as S}from"./chunks/framework.jrU0lkHV.js";function i(e){if(e.extends){const a=i(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const s=i(p),T=P({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=R();return w(()=>{y(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&C(),b(),E(),s.setup&&s.setup(),()=>S(s.Layout)}});async function j(){globalThis.__VITEPRESS__=!0;const e=_(),a=D();a.provide(l,e);const t=c(e.route);return a.provide(f,t),a.component("Content",d),a.component("ClientOnly",m),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),s.enhanceApp&&await s.enhanceApp({app:a,router:e,siteData:h}),{app:a,router:e,data:t}}function D(){return g(T)}function _(){let e=o,a;return A(t=>{let n=v(t),r=null;return n&&(e&&(a=n),(e||a===n)&&(n=n.replace(/\.js$/,".lean.js")),r=import(n)),o&&(e=!1),r},s.NotFound)}o&&j().then(({app:e,router:a,data:t})=>{a.go().then(()=>{u(a.route,t.site),e.mount("#app")})});export{j as createApp};
|
||||
import{R as p}from"./chunks/theme.DsuJY84h.js";import{R as o,a8 as u,a9 as l,aa as c,ab as f,ac as d,ad as m,ae as h,af as g,ag as A,ah as v,d as P,u as R,v as w,s as y,ai as C,aj as b,ak as E,al as S}from"./chunks/framework.jrU0lkHV.js";function i(e){if(e.extends){const a=i(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const s=i(p),T=P({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=R();return w(()=>{y(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&C(),b(),E(),s.setup&&s.setup(),()=>S(s.Layout)}});async function j(){globalThis.__VITEPRESS__=!0;const e=_(),a=D();a.provide(l,e);const t=c(e.route);return a.provide(f,t),a.component("Content",d),a.component("ClientOnly",m),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),s.enhanceApp&&await s.enhanceApp({app:a,router:e,siteData:h}),{app:a,router:e,data:t}}function D(){return g(T)}function _(){let e=o,a;return A(t=>{let n=v(t),r=null;return n&&(e&&(a=n),(e||a===n)&&(n=n.replace(/\.js$/,".lean.js")),r=import(n)),o&&(e=!1),r},s.NotFound)}o&&j().then(({app:e,router:a,data:t})=>{a.go().then(()=>{u(a.route,t.site),e.mount("#app")})});export{j as createApp};
|
1
assets/chunks/@localSearchIndexen.B9rukqki.js
Normal file
1
assets/chunks/@localSearchIndexen.B9rukqki.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
assets/chunks/@localSearchIndexroot.CnccKATG.js
Normal file
1
assets/chunks/@localSearchIndexroot.CnccKATG.js
Normal file
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
import{g as c}from"./theme.CoOFLGSO.js";import{d as e,o as a,c as n,j as t,t as i,k as p,_ as u}from"./framework.jrU0lkHV.js";const _="https://github.com/",o="LiteyukiStudio/LiteyukiBot",b=`${_}${o}`,m={class:"contributor-bar"},l=e({__name:"ContributorBar",setup(h){const r=`https://contrib.rocks/image?repo=${o}`,s=`${b}/graphs/contributors`;return(d,f)=>(a(),n("div",m,[t("h2",null,i(p(c)("thx_contributors")),1),t("a",{href:s},[t("div",{class:"contributor-list"},[t("img",{src:r,alt:"Contributors"})])])]))}}),k=u(l,[["__scopeId","data-v-bc374713"]]);export{k as C};
|
||||
import{g as c}from"./theme.DsuJY84h.js";import{d as e,o as a,c as n,j as t,t as i,k as p,_ as u}from"./framework.jrU0lkHV.js";const _="https://github.com/",o="LiteyukiStudio/LiteyukiBot",b=`${_}${o}`,m={class:"contributor-bar"},l=e({__name:"ContributorBar",setup(h){const r=`https://contrib.rocks/image?repo=${o}`,s=`${b}/graphs/contributors`;return(d,f)=>(a(),n("div",m,[t("h2",null,i(p(c)("thx_contributors")),1),t("a",{href:s},[t("div",{class:"contributor-list"},[t("img",{src:r,alt:"Contributors"})])])]))}}),k=u(l,[["__scopeId","data-v-bc374713"]]);export{k as C};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
assets/deploy_fandq.md.DYuQyOrf.js
Normal file
3
assets/deploy_fandq.md.DYuQyOrf.js
Normal file
@ -0,0 +1,3 @@
|
||||
import{_ as o,c as t,a7 as a,o as l}from"./chunks/framework.jrU0lkHV.js";const u=JSON.parse('{"title":"答疑","description":"","frontmatter":{"title":"答疑","order":3},"headers":[],"relativePath":"deploy/fandq.md","filePath":"zh/deploy/fandq.md","lastUpdated":1729881298000}'),i={name:"deploy/fandq.md"};function d(n,e,r,p,c,s){return l(),t("div",null,e[0]||(e[0]=[a(`<h1 id="答疑" tabindex="-1">答疑 <a class="header-anchor" href="#答疑" aria-label="Permalink to "答疑""></a></h1><h2 id="常见问题" tabindex="-1"><strong>常见问题</strong> <a class="header-anchor" href="#常见问题" aria-label="Permalink to "**常见问题**""></a></h2><ul><li><p>设备上Python环境太乱了,pip和python不对应怎么办?</p><ul><li>请使用<code>/path/to/python -m pip install -r requirements.txt</code>来安装依赖, 然后用<code>/path/to/python main.py</code>来启动Bot, 其中<code>/path/to/python</code>是你要用来运行Bot的可执行文件</li></ul></li><li><p>更新轻雪失败,报错<code>InvalidGitRepositoryError</code></p><ul><li>请正确安装<code>Git</code>,并使用克隆而非直接下载的方式部署轻雪</li></ul></li><li><p>怎么对接聊天平台?</p><ul><li>Bot部分插件提供了对接特定平台的能力,例如使用NoneBot插件可对接支持的适配器平台</li></ul></li><li><p><code>Playwright</code>安装失败</p><ul><li>输入<code>playwright install</code>安装浏览器</li></ul></li><li><p>有的插件安装后报错无法启动</p><ul><li>请先查阅插件文档,确认插件必要配置项完好后,仍然出现问题,请联系插件作者或在安全模式<code>safe_mode: true</code>下启动轻雪,在安全模式下你可以使用<code>npm uninstall</code>卸载问题插件</li></ul></li></ul><h2 id="其他问题" tabindex="-1">其他问题 <a class="header-anchor" href="#其他问题" aria-label="Permalink to "其他问题""></a></h2><pre><code>-
|
||||
加入QQ群[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
|
||||
</code></pre>`,5)]))}const m=o(i,[["render",d]]);export{u as __pageData,m as default};
|
3
assets/deploy_fandq.md.DYuQyOrf.lean.js
Normal file
3
assets/deploy_fandq.md.DYuQyOrf.lean.js
Normal file
@ -0,0 +1,3 @@
|
||||
import{_ as o,c as t,a7 as a,o as l}from"./chunks/framework.jrU0lkHV.js";const u=JSON.parse('{"title":"答疑","description":"","frontmatter":{"title":"答疑","order":3},"headers":[],"relativePath":"deploy/fandq.md","filePath":"zh/deploy/fandq.md","lastUpdated":1729881298000}'),i={name:"deploy/fandq.md"};function d(n,e,r,p,c,s){return l(),t("div",null,e[0]||(e[0]=[a(`<h1 id="答疑" tabindex="-1">答疑 <a class="header-anchor" href="#答疑" aria-label="Permalink to "答疑""></a></h1><h2 id="常见问题" tabindex="-1"><strong>常见问题</strong> <a class="header-anchor" href="#常见问题" aria-label="Permalink to "**常见问题**""></a></h2><ul><li><p>设备上Python环境太乱了,pip和python不对应怎么办?</p><ul><li>请使用<code>/path/to/python -m pip install -r requirements.txt</code>来安装依赖, 然后用<code>/path/to/python main.py</code>来启动Bot, 其中<code>/path/to/python</code>是你要用来运行Bot的可执行文件</li></ul></li><li><p>更新轻雪失败,报错<code>InvalidGitRepositoryError</code></p><ul><li>请正确安装<code>Git</code>,并使用克隆而非直接下载的方式部署轻雪</li></ul></li><li><p>怎么对接聊天平台?</p><ul><li>Bot部分插件提供了对接特定平台的能力,例如使用NoneBot插件可对接支持的适配器平台</li></ul></li><li><p><code>Playwright</code>安装失败</p><ul><li>输入<code>playwright install</code>安装浏览器</li></ul></li><li><p>有的插件安装后报错无法启动</p><ul><li>请先查阅插件文档,确认插件必要配置项完好后,仍然出现问题,请联系插件作者或在安全模式<code>safe_mode: true</code>下启动轻雪,在安全模式下你可以使用<code>npm uninstall</code>卸载问题插件</li></ul></li></ul><h2 id="其他问题" tabindex="-1">其他问题 <a class="header-anchor" href="#其他问题" aria-label="Permalink to "其他问题""></a></h2><pre><code>-
|
||||
加入QQ群[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
|
||||
</code></pre>`,5)]))}const m=o(i,[["render",d]]);export{u as __pageData,m as default};
|
@ -1 +0,0 @@
|
||||
import{_ as a,c as n,j as e,a as t,o as i}from"./chunks/framework.jrU0lkHV.js";const u=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"dev/api/session/message/segments.md","filePath":"zh/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"dev/api/session/message/segments.md"};function m(l,s,r,d,g,c){return i(),n("div",null,s[0]||(s[0]=[e("h1",{id:"模块-liteyuki-session-message-segments",tabindex:"-1"},[e("strong",null,"模块"),t(),e("code",null,"liteyuki.session.message.segments"),t(),e("a",{class:"header-anchor",href:"#模块-liteyuki-session-message-segments","aria-label":'Permalink to "**模块** `liteyuki.session.message.segments`"'},"")],-1)]))}const f=a(o,[["render",m]]);export{u as __pageData,f as default};
|
@ -1 +0,0 @@
|
||||
import{_ as a,c as n,j as e,a as t,o as i}from"./chunks/framework.jrU0lkHV.js";const u=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"dev/api/session/message/segments.md","filePath":"zh/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"dev/api/session/message/segments.md"};function m(l,s,r,d,g,c){return i(),n("div",null,s[0]||(s[0]=[e("h1",{id:"模块-liteyuki-session-message-segments",tabindex:"-1"},[e("strong",null,"模块"),t(),e("code",null,"liteyuki.session.message.segments"),t(),e("a",{class:"header-anchor",href:"#模块-liteyuki-session-message-segments","aria-label":'Permalink to "**模块** `liteyuki.session.message.segments`"'},"")],-1)]))}const f=a(o,[["render",m]]);export{u as __pageData,f as default};
|
1
assets/dev_api_session_message_segments.md.BquBMIE7.js
Normal file
1
assets/dev_api_session_message_segments.md.BquBMIE7.js
Normal file
@ -0,0 +1 @@
|
||||
import{_ as a,c as t,a7 as s,o as r}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"dev/api/session/message/segments.md","filePath":"zh/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"dev/api/session/message/segments.md"};function n(l,e,d,i,c,m){return r(),t("div",null,e[0]||(e[0]=[s('<h1 id="模块-liteyuki-session-message-segments" tabindex="-1"><strong>模块</strong> <code>liteyuki.session.message.segments</code> <a class="header-anchor" href="#模块-liteyuki-session-message-segments" aria-label="Permalink to "**模块** `liteyuki.session.message.segments`""></a></h1><h3 id="class-baseseg-basemodel" tabindex="-1"><em><strong>class</strong></em> <code>BaseSeg(BaseModel)</code> <a class="header-anchor" href="#class-baseseg-basemodel" aria-label="Permalink to "***class*** `BaseSeg(BaseModel)`""></a></h3><h4 id="attr-type-str-segment" tabindex="-1"><em><strong>attr</strong></em> <code>type: str = 'Segment'</code> <a class="header-anchor" href="#attr-type-str-segment" aria-label="Permalink to "***attr*** `type: str = 'Segment'`""></a></h4><h4 id="attr-data-dict-str-any-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>data: dict[str, Any] = NO_DEFAULT</code> <a class="header-anchor" href="#attr-data-dict-str-any-no-default" aria-label="Permalink to "***attr*** `data: dict[str, Any] = NO_DEFAULT`""></a></h4><h3 id="class-text-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Text(BaseSeg)</code> <a class="header-anchor" href="#class-text-baseseg" aria-label="Permalink to "***class*** `Text(BaseSeg)`""></a></h3><h4 id="attr-content-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>content: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-content-str-no-default" aria-label="Permalink to "***attr*** `content: str = NO_DEFAULT`""></a></h4><h3 id="class-image-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Image(BaseSeg)</code> <a class="header-anchor" href="#class-image-baseseg" aria-label="Permalink to "***class*** `Image(BaseSeg)`""></a></h3><h4 id="attr-url-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>url: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-url-str-no-default" aria-label="Permalink to "***attr*** `url: str = NO_DEFAULT`""></a></h4>',8)]))}const u=a(o,[["render",n]]);export{h as __pageData,u as default};
|
@ -0,0 +1 @@
|
||||
import{_ as a,c as t,a7 as s,o as r}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"dev/api/session/message/segments.md","filePath":"zh/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"dev/api/session/message/segments.md"};function n(l,e,d,i,c,m){return r(),t("div",null,e[0]||(e[0]=[s('<h1 id="模块-liteyuki-session-message-segments" tabindex="-1"><strong>模块</strong> <code>liteyuki.session.message.segments</code> <a class="header-anchor" href="#模块-liteyuki-session-message-segments" aria-label="Permalink to "**模块** `liteyuki.session.message.segments`""></a></h1><h3 id="class-baseseg-basemodel" tabindex="-1"><em><strong>class</strong></em> <code>BaseSeg(BaseModel)</code> <a class="header-anchor" href="#class-baseseg-basemodel" aria-label="Permalink to "***class*** `BaseSeg(BaseModel)`""></a></h3><h4 id="attr-type-str-segment" tabindex="-1"><em><strong>attr</strong></em> <code>type: str = 'Segment'</code> <a class="header-anchor" href="#attr-type-str-segment" aria-label="Permalink to "***attr*** `type: str = 'Segment'`""></a></h4><h4 id="attr-data-dict-str-any-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>data: dict[str, Any] = NO_DEFAULT</code> <a class="header-anchor" href="#attr-data-dict-str-any-no-default" aria-label="Permalink to "***attr*** `data: dict[str, Any] = NO_DEFAULT`""></a></h4><h3 id="class-text-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Text(BaseSeg)</code> <a class="header-anchor" href="#class-text-baseseg" aria-label="Permalink to "***class*** `Text(BaseSeg)`""></a></h3><h4 id="attr-content-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>content: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-content-str-no-default" aria-label="Permalink to "***attr*** `content: str = NO_DEFAULT`""></a></h4><h3 id="class-image-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Image(BaseSeg)</code> <a class="header-anchor" href="#class-image-baseseg" aria-label="Permalink to "***class*** `Image(BaseSeg)`""></a></h3><h4 id="attr-url-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>url: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-url-str-no-default" aria-label="Permalink to "***attr*** `url: str = NO_DEFAULT`""></a></h4>',8)]))}const u=a(o,[["render",n]]);export{h as __pageData,u as default};
|
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as e}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"进程通信","description":"","frontmatter":{"title":"进程通信","order":4},"headers":[],"relativePath":"dev/comm.md","filePath":"zh/dev/comm.md","lastUpdated":1725102337000}'),l={name:"dev/comm.md"};function h(t,s,p,k,r,d){return e(),a("div",null,s[0]||(s[0]=[n(`<h1 id="通道通信" tabindex="-1"><strong>通道通信</strong> <a class="header-anchor" href="#通道通信" aria-label="Permalink to "**通道通信**""></a></h1><h3 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h3><p>轻雪运行在主进程 MainProcess 里,其他插件框架进程是伴随的子进程,因此无法通过内存共享和直接对象传递的方式进行通信, 轻雪提供了一个通道<a href="./api/comm/channel.html#class-channel-generic-t"><code>Channel</code></a>用于跨进程通信, 你可以通过<a href="./api/comm/channel.html#class-channel-generic-t"><code>Channel</code></a>发送消息给其他进程,也可以监听其他进程的消息。</p><p>例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。</p><h3 id="示例" tabindex="-1">示例 <a class="header-anchor" href="#示例" aria-label="Permalink to "示例""></a></h3><p>通道是全双工的,有两种接收模式,但一个通道只能使用一种,即被动模式和主动模式,被动模式由<code>chan.on_receive()</code>装饰回调函数实现,主动模式需调用<code>chan.receive()</code>实现</p><ul><li>创建子进程的同时会初始化一个被动通道和一个主动通道,且通道标识为<code>{process_name}-active</code>和<code>{process_name}-passive</code>,</li><li>主进程中通过<code>get_channel</code>函数获取通道对象</li><li>子进程中导入单例<code>active_channel</code>及<code>passive_channel</code>即可</li></ul><blockquote><p>在轻雪插件中(主进程中)</p></blockquote><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;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"进程通信","description":"","frontmatter":{"title":"进程通信","order":4},"headers":[],"relativePath":"dev/comm.md","filePath":"zh/dev/comm.md","lastUpdated":1729881298000}'),l={name:"dev/comm.md"};function e(h,s,p,k,r,d){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="通道通信" tabindex="-1"><strong>通道通信</strong> <a class="header-anchor" href="#通道通信" aria-label="Permalink to "**通道通信**""></a></h1><h3 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h3><p>轻雪运行在主进程 MainProcess 里,有部分实现插件为了一些功能在子进程中运行,这样两个进程上下文是不会互相干扰的,因此无法通过共享内存和直接对象传递进行通信。</p><p>例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。</p><h3 id="示例" tabindex="-1">示例 <a class="header-anchor" href="#示例" aria-label="Permalink to "示例""></a></h3><p>通道是全双工的,有两种接收模式,但一个通道只能使用一种,即被动模式和主动模式,被动模式由<code>chan.on_receive()</code>装饰回调函数实现,主动模式需调用<code>chan.receive()</code>实现</p><ul><li>创建子进程的同时会初始化一个被动通道和一个主动通道,且通道标识为<code>{process_name}-active</code>和<code>{process_name}-passive</code>,</li><li>主进程中通过<code>get_channel</code>函数获取通道对象</li><li>子进程中导入单例<code>active_channel</code>及<code>passive_channel</code>即可</li></ul><blockquote><p>在轻雪插件中(主进程中)</p></blockquote><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;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.comm </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel, Channel</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot</span></span>
|
||||
@ -40,4 +40,4 @@ import{_ as i,c as a,a7 as n,o as e}from"./chunks/framework.jrU0lkHV.js";const o
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">...</span></span></code></pre></div><h2 id="共享内存通信" tabindex="-1"><strong>共享内存通信</strong> <a class="header-anchor" href="#共享内存通信" aria-label="Permalink to "**共享内存通信**""></a></h2><h3 id="简介-1" tabindex="-1">简介 <a class="header-anchor" href="#简介-1" aria-label="Permalink to "简介""></a></h3><ul><li>相比于普通进程通信,内存共享使得代码编写更加简洁,轻雪框架提供了一个内存共享通信的接口,你可以通过<code>storage</code>模块实现内存共享通信,该模块封装通道实现</li><li>内存共享是线程安全的,你可以在多个线程中读写共享内存,线程锁会自动保护共享内存的读写操作</li></ul><h3 id="示例-1" tabindex="-1">示例 <a class="header-anchor" href="#示例-1" aria-label="Permalink to "示例""></a></h3><blockquote><p>在任意进程中均可使用</p></blockquote><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.comm.storage </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">shared_memory.set(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 设置共享内存</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 获取共享内存</span></span></code></pre></div><p>源代码:<a href="https://github.com/LiteyukiStudio/LiteyukiBot/blob/main/liteyuki/comm/storage.py" target="_blank" rel="noreferrer">liteyuki/comm/storage.py</a></p>`,20)]))}const c=i(l,[["render",h]]);export{o as __pageData,c as default};
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 获取共享内存</span></span></code></pre></div><p>源代码:<a href="https://github.com/LiteyukiStudio/LiteyukiBot/blob/main/liteyuki/comm/storage.py" target="_blank" rel="noreferrer">liteyuki/comm/storage.py</a></p>`,20)]))}const c=i(l,[["render",e]]);export{o as __pageData,c as default};
|
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as e}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"进程通信","description":"","frontmatter":{"title":"进程通信","order":4},"headers":[],"relativePath":"dev/comm.md","filePath":"zh/dev/comm.md","lastUpdated":1725102337000}'),l={name:"dev/comm.md"};function h(t,s,p,k,r,d){return e(),a("div",null,s[0]||(s[0]=[n(`<h1 id="通道通信" tabindex="-1"><strong>通道通信</strong> <a class="header-anchor" href="#通道通信" aria-label="Permalink to "**通道通信**""></a></h1><h3 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h3><p>轻雪运行在主进程 MainProcess 里,其他插件框架进程是伴随的子进程,因此无法通过内存共享和直接对象传递的方式进行通信, 轻雪提供了一个通道<a href="./api/comm/channel.html#class-channel-generic-t"><code>Channel</code></a>用于跨进程通信, 你可以通过<a href="./api/comm/channel.html#class-channel-generic-t"><code>Channel</code></a>发送消息给其他进程,也可以监听其他进程的消息。</p><p>例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。</p><h3 id="示例" tabindex="-1">示例 <a class="header-anchor" href="#示例" aria-label="Permalink to "示例""></a></h3><p>通道是全双工的,有两种接收模式,但一个通道只能使用一种,即被动模式和主动模式,被动模式由<code>chan.on_receive()</code>装饰回调函数实现,主动模式需调用<code>chan.receive()</code>实现</p><ul><li>创建子进程的同时会初始化一个被动通道和一个主动通道,且通道标识为<code>{process_name}-active</code>和<code>{process_name}-passive</code>,</li><li>主进程中通过<code>get_channel</code>函数获取通道对象</li><li>子进程中导入单例<code>active_channel</code>及<code>passive_channel</code>即可</li></ul><blockquote><p>在轻雪插件中(主进程中)</p></blockquote><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;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"进程通信","description":"","frontmatter":{"title":"进程通信","order":4},"headers":[],"relativePath":"dev/comm.md","filePath":"zh/dev/comm.md","lastUpdated":1729881298000}'),l={name:"dev/comm.md"};function e(h,s,p,k,r,d){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="通道通信" tabindex="-1"><strong>通道通信</strong> <a class="header-anchor" href="#通道通信" aria-label="Permalink to "**通道通信**""></a></h1><h3 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h3><p>轻雪运行在主进程 MainProcess 里,有部分实现插件为了一些功能在子进程中运行,这样两个进程上下文是不会互相干扰的,因此无法通过共享内存和直接对象传递进行通信。</p><p>例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。</p><h3 id="示例" tabindex="-1">示例 <a class="header-anchor" href="#示例" aria-label="Permalink to "示例""></a></h3><p>通道是全双工的,有两种接收模式,但一个通道只能使用一种,即被动模式和主动模式,被动模式由<code>chan.on_receive()</code>装饰回调函数实现,主动模式需调用<code>chan.receive()</code>实现</p><ul><li>创建子进程的同时会初始化一个被动通道和一个主动通道,且通道标识为<code>{process_name}-active</code>和<code>{process_name}-passive</code>,</li><li>主进程中通过<code>get_channel</code>函数获取通道对象</li><li>子进程中导入单例<code>active_channel</code>及<code>passive_channel</code>即可</li></ul><blockquote><p>在轻雪插件中(主进程中)</p></blockquote><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;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.comm </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel, Channel</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot</span></span>
|
||||
@ -40,4 +40,4 @@ import{_ as i,c as a,a7 as n,o as e}from"./chunks/framework.jrU0lkHV.js";const o
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">...</span></span></code></pre></div><h2 id="共享内存通信" tabindex="-1"><strong>共享内存通信</strong> <a class="header-anchor" href="#共享内存通信" aria-label="Permalink to "**共享内存通信**""></a></h2><h3 id="简介-1" tabindex="-1">简介 <a class="header-anchor" href="#简介-1" aria-label="Permalink to "简介""></a></h3><ul><li>相比于普通进程通信,内存共享使得代码编写更加简洁,轻雪框架提供了一个内存共享通信的接口,你可以通过<code>storage</code>模块实现内存共享通信,该模块封装通道实现</li><li>内存共享是线程安全的,你可以在多个线程中读写共享内存,线程锁会自动保护共享内存的读写操作</li></ul><h3 id="示例-1" tabindex="-1">示例 <a class="header-anchor" href="#示例-1" aria-label="Permalink to "示例""></a></h3><blockquote><p>在任意进程中均可使用</p></blockquote><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.comm.storage </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">shared_memory.set(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 设置共享内存</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 获取共享内存</span></span></code></pre></div><p>源代码:<a href="https://github.com/LiteyukiStudio/LiteyukiBot/blob/main/liteyuki/comm/storage.py" target="_blank" rel="noreferrer">liteyuki/comm/storage.py</a></p>`,20)]))}const c=i(l,[["render",h]]);export{o as __pageData,c as default};
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"key"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 获取共享内存</span></span></code></pre></div><p>源代码:<a href="https://github.com/LiteyukiStudio/LiteyukiBot/blob/main/liteyuki/comm/storage.py" target="_blank" rel="noreferrer">liteyuki/comm/storage.py</a></p>`,20)]))}const c=i(l,[["render",e]]);export{o as __pageData,c as default};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"轻雪插件开发","description":"","frontmatter":{"title":"轻雪插件开发","order":3},"headers":[],"relativePath":"dev/plugin.md","filePath":"zh/dev/plugin.md","lastUpdated":1725101868000}'),h={name:"dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const E=JSON.parse('{"title":"插件开发","description":"","frontmatter":{"title":"插件开发","order":3},"headers":[],"relativePath":"dev/plugin.md","filePath":"zh/dev/plugin.md","lastUpdated":1729881298000}'),h={name:"dev/plugin.md"};function p(l,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><p>插件大致可分为应用(Application)、实现(Implementation)及服务(Service)等几种类型,大部分情况下一个插件通常承担着多个责任,可按需调整</p><p>应用:从总线通道接收到消息后进行处理,响应,以实现某些功能,例如<code>echo</code></p><p>实现:对接特定平台,把平台的消息转换为轻雪消息格式传入总线通道</p><p>服务:提供一系列对外的ipc/rpc/http等服务,供其他插件调用</p><p>我们鼓励使用<code>magicoca</code>进行对象传递来进行插件间通信而不是依赖关系,这样可以避免很多潜在的问题。</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> .watch_dog </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 导入逻辑部分</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 定义插件元数据</span></span>
|
||||
@ -29,4 +29,4 @@ import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"File </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.src_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> changed, reloading nonebot..."</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.restart_process(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"nonebot"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 调用重启进程方法</span></span></code></pre></div><h3 id="加载插件" tabindex="-1">加载插件 <a class="header-anchor" href="#加载插件" aria-label="Permalink to "加载插件""></a></h3><h4 id="方法1" tabindex="-1">方法1 <a class="header-anchor" href="#方法1" aria-label="Permalink to "方法1""></a></h4><ul><li>在配置文件中的<code>liteyuki.plugins</code>中添加你的插件路径,例如<code>watchdog_plugin</code>,重启轻雪即可加载插件。</li></ul><h4 id="方法2" tabindex="-1">方法2 <a class="header-anchor" href="#方法2" aria-label="Permalink to "方法2""></a></h4><ul><li>使用开发工具快速运行插件,无需手动创建实例</li><li>创建入口文件,例如<code>main.py</code>,并在其中写入以下代码</li></ul><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.dev.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> run_plugins</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">run_plugins(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"watchdog_plugin"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p>然后运行<code>python main.py</code>即可启动插件</p><p>启用插件后,我们在src/nonebot_plugins下创建一个文件,例如<code>test.py</code>,并在其中写入一些代码,保存后轻雪会自动重载NoneBot进程</p>`,19)]))}const g=i(h,[["render",l]]);export{o as __pageData,g as default};
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">run_plugins(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"watchdog_plugin"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p>然后运行<code>python main.py</code>即可启动插件</p><p>启用插件后,我们在src/nonebot_plugins下创建一个文件,例如<code>test.py</code>,并在其中写入一些代码,保存后轻雪会自动重载NoneBot进程</p>`,24)]))}const g=i(h,[["render",p]]);export{E as __pageData,g as default};
|
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"轻雪插件开发","description":"","frontmatter":{"title":"轻雪插件开发","order":3},"headers":[],"relativePath":"dev/plugin.md","filePath":"zh/dev/plugin.md","lastUpdated":1725101868000}'),h={name:"dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const E=JSON.parse('{"title":"插件开发","description":"","frontmatter":{"title":"插件开发","order":3},"headers":[],"relativePath":"dev/plugin.md","filePath":"zh/dev/plugin.md","lastUpdated":1729881298000}'),h={name:"dev/plugin.md"};function p(l,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><p>插件大致可分为应用(Application)、实现(Implementation)及服务(Service)等几种类型,大部分情况下一个插件通常承担着多个责任,可按需调整</p><p>应用:从总线通道接收到消息后进行处理,响应,以实现某些功能,例如<code>echo</code></p><p>实现:对接特定平台,把平台的消息转换为轻雪消息格式传入总线通道</p><p>服务:提供一系列对外的ipc/rpc/http等服务,供其他插件调用</p><p>我们鼓励使用<code>magicoca</code>进行对象传递来进行插件间通信而不是依赖关系,这样可以避免很多潜在的问题。</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> .watch_dog </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 导入逻辑部分</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 定义插件元数据</span></span>
|
||||
@ -29,4 +29,4 @@ import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"File </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event.src_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> changed, reloading nonebot..."</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.restart_process(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"nonebot"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 调用重启进程方法</span></span></code></pre></div><h3 id="加载插件" tabindex="-1">加载插件 <a class="header-anchor" href="#加载插件" aria-label="Permalink to "加载插件""></a></h3><h4 id="方法1" tabindex="-1">方法1 <a class="header-anchor" href="#方法1" aria-label="Permalink to "方法1""></a></h4><ul><li>在配置文件中的<code>liteyuki.plugins</code>中添加你的插件路径,例如<code>watchdog_plugin</code>,重启轻雪即可加载插件。</li></ul><h4 id="方法2" tabindex="-1">方法2 <a class="header-anchor" href="#方法2" aria-label="Permalink to "方法2""></a></h4><ul><li>使用开发工具快速运行插件,无需手动创建实例</li><li>创建入口文件,例如<code>main.py</code>,并在其中写入以下代码</li></ul><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.dev.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> run_plugins</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">run_plugins(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"watchdog_plugin"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p>然后运行<code>python main.py</code>即可启动插件</p><p>启用插件后,我们在src/nonebot_plugins下创建一个文件,例如<code>test.py</code>,并在其中写入一些代码,保存后轻雪会自动重载NoneBot进程</p>`,19)]))}const g=i(h,[["render",l]]);export{o as __pageData,g as default};
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">run_plugins(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"watchdog_plugin"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><p>然后运行<code>python main.py</code>即可启动插件</p><p>启用插件后,我们在src/nonebot_plugins下创建一个文件,例如<code>test.py</code>,并在其中写入一些代码,保存后轻雪会自动重载NoneBot进程</p>`,24)]))}const g=i(h,[["render",p]]);export{E as __pageData,g as default};
|
1
assets/en_deploy_fandq.md.CfGzF3ge.js
Normal file
1
assets/en_deploy_fandq.md.CfGzF3ge.js
Normal file
@ -0,0 +1 @@
|
||||
import{_ as t,c as o,a7 as a,o as i}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"FAQ","description":"","frontmatter":{"title":"FAQ","order":3},"headers":[],"relativePath":"en/deploy/fandq.md","filePath":"en/deploy/fandq.md","lastUpdated":1729881298000}'),n={name:"en/deploy/fandq.md"};function l(r,e,s,u,p,d){return i(),o("div",null,e[0]||(e[0]=[a('<h1 id="faq" tabindex="-1">FAQ <a class="header-anchor" href="#faq" aria-label="Permalink to "FAQ""></a></h1><h2 id="frequently-asked-questions" tabindex="-1"><strong>Frequently Asked Questions</strong> <a class="header-anchor" href="#frequently-asked-questions" aria-label="Permalink to "**Frequently Asked Questions**""></a></h2><ul><li><p>There are too many python interpreters on my computer, how do I know which one to use?</p><ul><li>You can specify which python interpreter to use by using the full path to the python executable, for example, <code>/path/to/python main.py</code></li><li>Use virtual environments to avoid conflicts between different python interpreters</li></ul></li><li><p>Update Liteyuki failed, error <code>InvalidGitRepositoryError</code></p><ul><li>Please install <code>Git</code> correctly and deploy Liteyuki using cloning instead of direct download</li></ul></li><li><p>How to log in to chat platforms?</p><ul><li>Some plugins provide the ability to log in to specific platforms, for example, using the NoneBot plugin to log in to supported adapter platforms</li></ul></li><li><p><code>Playwright</code> installation failed</p><ul><li>Enter <code>playwright install</code> to install the browser</li></ul></li><li><p>Some plugins report errors after installation and cannot be started</p><ul><li>Please refer to the plugin documentation first, confirm that the necessary configuration items of the plugin are intact, and if the problem persists, please contact the plugin author or start Liteyuki in safe mode <code>safe_mode: true</code>. In safe mode, you can use <code>npm uninstall</code> to uninstall problematic plugins</li></ul></li></ul><h2 id="other-questions" tabindex="-1">Other questions <a class="header-anchor" href="#other-questions" aria-label="Permalink to "Other questions""></a></h2><ul><li>Join chat group<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726" target="_blank" rel="noreferrer">775840726</a></li><li>If you don't have a QQ account, you can <a href="https://github.com/LiteyukiStudio/LiteyukiBot/issues/new?assignees=&labels=&projects=&template=%E9%97%AE%E9%A2%98%E5%8F%8D%E9%A6%88.md&title=" target="_blank" rel="noreferrer">submit an issue on GitHub</a></li></ul>',5)]))}const f=t(n,[["render",l]]);export{h as __pageData,f as default};
|
1
assets/en_deploy_fandq.md.CfGzF3ge.lean.js
Normal file
1
assets/en_deploy_fandq.md.CfGzF3ge.lean.js
Normal file
@ -0,0 +1 @@
|
||||
import{_ as t,c as o,a7 as a,o as i}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"FAQ","description":"","frontmatter":{"title":"FAQ","order":3},"headers":[],"relativePath":"en/deploy/fandq.md","filePath":"en/deploy/fandq.md","lastUpdated":1729881298000}'),n={name:"en/deploy/fandq.md"};function l(r,e,s,u,p,d){return i(),o("div",null,e[0]||(e[0]=[a('<h1 id="faq" tabindex="-1">FAQ <a class="header-anchor" href="#faq" aria-label="Permalink to "FAQ""></a></h1><h2 id="frequently-asked-questions" tabindex="-1"><strong>Frequently Asked Questions</strong> <a class="header-anchor" href="#frequently-asked-questions" aria-label="Permalink to "**Frequently Asked Questions**""></a></h2><ul><li><p>There are too many python interpreters on my computer, how do I know which one to use?</p><ul><li>You can specify which python interpreter to use by using the full path to the python executable, for example, <code>/path/to/python main.py</code></li><li>Use virtual environments to avoid conflicts between different python interpreters</li></ul></li><li><p>Update Liteyuki failed, error <code>InvalidGitRepositoryError</code></p><ul><li>Please install <code>Git</code> correctly and deploy Liteyuki using cloning instead of direct download</li></ul></li><li><p>How to log in to chat platforms?</p><ul><li>Some plugins provide the ability to log in to specific platforms, for example, using the NoneBot plugin to log in to supported adapter platforms</li></ul></li><li><p><code>Playwright</code> installation failed</p><ul><li>Enter <code>playwright install</code> to install the browser</li></ul></li><li><p>Some plugins report errors after installation and cannot be started</p><ul><li>Please refer to the plugin documentation first, confirm that the necessary configuration items of the plugin are intact, and if the problem persists, please contact the plugin author or start Liteyuki in safe mode <code>safe_mode: true</code>. In safe mode, you can use <code>npm uninstall</code> to uninstall problematic plugins</li></ul></li></ul><h2 id="other-questions" tabindex="-1">Other questions <a class="header-anchor" href="#other-questions" aria-label="Permalink to "Other questions""></a></h2><ul><li>Join chat group<a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726" target="_blank" rel="noreferrer">775840726</a></li><li>If you don't have a QQ account, you can <a href="https://github.com/LiteyukiStudio/LiteyukiBot/issues/new?assignees=&labels=&projects=&template=%E9%97%AE%E9%A2%98%E5%8F%8D%E9%A6%88.md&title=" target="_blank" rel="noreferrer">submit an issue on GitHub</a></li></ul>',5)]))}const f=t(n,[["render",l]]);export{h as __pageData,f as default};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
import{_ as a,c as t,a7 as s,o as r}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"en/dev/api/session/message/segments.md","filePath":"en/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"en/dev/api/session/message/segments.md"};function n(l,e,d,i,c,m){return r(),t("div",null,e[0]||(e[0]=[s('<h1 id="module-liteyuki-session-message-segments" tabindex="-1"><strong>Module</strong> <code>liteyuki.session.message.segments</code> <a class="header-anchor" href="#module-liteyuki-session-message-segments" aria-label="Permalink to "**Module** `liteyuki.session.message.segments`""></a></h1><h3 id="class-baseseg-basemodel" tabindex="-1"><em><strong>class</strong></em> <code>BaseSeg(BaseModel)</code> <a class="header-anchor" href="#class-baseseg-basemodel" aria-label="Permalink to "***class*** `BaseSeg(BaseModel)`""></a></h3><h4 id="attr-type-str-segment" tabindex="-1"><em><strong>attr</strong></em> <code>type: str = 'Segment'</code> <a class="header-anchor" href="#attr-type-str-segment" aria-label="Permalink to "***attr*** `type: str = 'Segment'`""></a></h4><h4 id="attr-data-dict-str-any-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>data: dict[str, Any] = NO_DEFAULT</code> <a class="header-anchor" href="#attr-data-dict-str-any-no-default" aria-label="Permalink to "***attr*** `data: dict[str, Any] = NO_DEFAULT`""></a></h4><h3 id="class-text-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Text(BaseSeg)</code> <a class="header-anchor" href="#class-text-baseseg" aria-label="Permalink to "***class*** `Text(BaseSeg)`""></a></h3><h4 id="attr-content-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>content: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-content-str-no-default" aria-label="Permalink to "***attr*** `content: str = NO_DEFAULT`""></a></h4><h3 id="class-image-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Image(BaseSeg)</code> <a class="header-anchor" href="#class-image-baseseg" aria-label="Permalink to "***class*** `Image(BaseSeg)`""></a></h3><h4 id="attr-url-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>url: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-url-str-no-default" aria-label="Permalink to "***attr*** `url: str = NO_DEFAULT`""></a></h4>',8)]))}const u=a(o,[["render",n]]);export{h as __pageData,u as default};
|
@ -0,0 +1 @@
|
||||
import{_ as a,c as t,a7 as s,o as r}from"./chunks/framework.jrU0lkHV.js";const h=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"en/dev/api/session/message/segments.md","filePath":"en/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"en/dev/api/session/message/segments.md"};function n(l,e,d,i,c,m){return r(),t("div",null,e[0]||(e[0]=[s('<h1 id="module-liteyuki-session-message-segments" tabindex="-1"><strong>Module</strong> <code>liteyuki.session.message.segments</code> <a class="header-anchor" href="#module-liteyuki-session-message-segments" aria-label="Permalink to "**Module** `liteyuki.session.message.segments`""></a></h1><h3 id="class-baseseg-basemodel" tabindex="-1"><em><strong>class</strong></em> <code>BaseSeg(BaseModel)</code> <a class="header-anchor" href="#class-baseseg-basemodel" aria-label="Permalink to "***class*** `BaseSeg(BaseModel)`""></a></h3><h4 id="attr-type-str-segment" tabindex="-1"><em><strong>attr</strong></em> <code>type: str = 'Segment'</code> <a class="header-anchor" href="#attr-type-str-segment" aria-label="Permalink to "***attr*** `type: str = 'Segment'`""></a></h4><h4 id="attr-data-dict-str-any-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>data: dict[str, Any] = NO_DEFAULT</code> <a class="header-anchor" href="#attr-data-dict-str-any-no-default" aria-label="Permalink to "***attr*** `data: dict[str, Any] = NO_DEFAULT`""></a></h4><h3 id="class-text-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Text(BaseSeg)</code> <a class="header-anchor" href="#class-text-baseseg" aria-label="Permalink to "***class*** `Text(BaseSeg)`""></a></h3><h4 id="attr-content-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>content: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-content-str-no-default" aria-label="Permalink to "***attr*** `content: str = NO_DEFAULT`""></a></h4><h3 id="class-image-baseseg" tabindex="-1"><em><strong>class</strong></em> <code>Image(BaseSeg)</code> <a class="header-anchor" href="#class-image-baseseg" aria-label="Permalink to "***class*** `Image(BaseSeg)`""></a></h3><h4 id="attr-url-str-no-default" tabindex="-1"><em><strong>attr</strong></em> <code>url: str = NO_DEFAULT</code> <a class="header-anchor" href="#attr-url-str-no-default" aria-label="Permalink to "***attr*** `url: str = NO_DEFAULT`""></a></h4>',8)]))}const u=a(o,[["render",n]]);export{h as __pageData,u as default};
|
@ -1 +0,0 @@
|
||||
import{_ as a,c as n,j as e,a as t,o as i}from"./chunks/framework.jrU0lkHV.js";const p=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"en/dev/api/session/message/segments.md","filePath":"en/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"en/dev/api/session/message/segments.md"};function l(m,s,r,d,g,u){return i(),n("div",null,s[0]||(s[0]=[e("h1",{id:"module-liteyuki-session-message-segments",tabindex:"-1"},[e("strong",null,"Module"),t(),e("code",null,"liteyuki.session.message.segments"),t(),e("a",{class:"header-anchor",href:"#module-liteyuki-session-message-segments","aria-label":'Permalink to "**Module** `liteyuki.session.message.segments`"'},"")],-1)]))}const f=a(o,[["render",l]]);export{p as __pageData,f as default};
|
@ -1 +0,0 @@
|
||||
import{_ as a,c as n,j as e,a as t,o as i}from"./chunks/framework.jrU0lkHV.js";const p=JSON.parse('{"title":"liteyuki.session.message.segments","description":"","frontmatter":{"title":"liteyuki.session.message.segments"},"headers":[],"relativePath":"en/dev/api/session/message/segments.md","filePath":"en/dev/api/session/message/segments.md","lastUpdated":null}'),o={name:"en/dev/api/session/message/segments.md"};function l(m,s,r,d,g,u){return i(),n("div",null,s[0]||(s[0]=[e("h1",{id:"module-liteyuki-session-message-segments",tabindex:"-1"},[e("strong",null,"Module"),t(),e("code",null,"liteyuki.session.message.segments"),t(),e("a",{class:"header-anchor",href:"#module-liteyuki-session-message-segments","aria-label":'Permalink to "**Module** `liteyuki.session.message.segments`"'},"")],-1)]))}const f=a(o,[["render",l]]);export{p as __pageData,f as default};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"Liteyuki Plugin","description":"","frontmatter":{"title":"Liteyuki Plugin","order":3},"headers":[],"relativePath":"en/dev/plugin.md","filePath":"en/dev/plugin.md","lastUpdated":1726859552000}'),h={name:"en/dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"Plugin","description":"","frontmatter":{"title":"Plugin","order":3},"headers":[],"relativePath":"en/dev/plugin.md","filePath":"en/dev/plugin.md","lastUpdated":1729881298000}'),h={name:"en/dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能。</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> .watch_dog </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 导入逻辑部分</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 定义插件元数据</span></span>
|
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"Liteyuki Plugin","description":"","frontmatter":{"title":"Liteyuki Plugin","order":3},"headers":[],"relativePath":"en/dev/plugin.md","filePath":"en/dev/plugin.md","lastUpdated":1726859552000}'),h={name:"en/dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
import{_ as i,c as a,a7 as n,o as t}from"./chunks/framework.jrU0lkHV.js";const o=JSON.parse('{"title":"Plugin","description":"","frontmatter":{"title":"Plugin","order":3},"headers":[],"relativePath":"en/dev/plugin.md","filePath":"en/dev/plugin.md","lastUpdated":1729881298000}'),h={name:"en/dev/plugin.md"};function l(p,s,e,k,d,r){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="简介" tabindex="-1">简介 <a class="header-anchor" href="#简介" aria-label="Permalink to "简介""></a></h1><p>轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能。</p><h2 id="开始" tabindex="-1">开始 <a class="header-anchor" href="#开始" aria-label="Permalink to "开始""></a></h2><h3 id="创建插件" tabindex="-1">创建插件 <a class="header-anchor" href="#创建插件" aria-label="Permalink to "创建插件""></a></h3><p>一个<code>.py</code>文件或一个包含<code>__init__.py</code>的文件夹即可被识别为插件</p><p>首先创建一个文件夹,例如<code>watchdog_plugin</code>,并在其中创建一个<code>__init__.py</code>文件,即可创建一个插件</p><p><code>__init__.py</code></p><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;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> liteyuki.plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata, PluginType</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> .watch_dog </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 导入逻辑部分</span></span>
|
||||
<span class="line"></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 定义插件元数据</span></span>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user