1
0
forked from bot/app
LiteyukiBot/assets/rule.html-Dt491ecB.js

24 lines
13 KiB
JavaScript

import{_ as n,o as e,c as s,d as a}from"./app-CLi4lRj1.js";const t={},l=a(`<h3 id="rule" tabindex="-1"><a class="header-anchor" href="#rule"><span><code>@Rule</code></span></a></h3><h3 id="async-func-empty-rule-bool" tabindex="-1"><a class="header-anchor" href="#async-func-empty-rule-bool"><span><em>async func</em> <code>empty_rule() -&gt; bool</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@Rule</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">empty_rule</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">bool</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token boolean">True</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="rule-1" tabindex="-1"><a class="header-anchor" href="#rule-1"><span><code>@Rule</code></span></a></h3><h3 id="async-func-is-su-rule-bool" tabindex="-1"><a class="header-anchor" href="#async-func-is-su-rule-bool"><span><em>async func</em> <code>is_su_rule() -&gt; bool</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token decorator annotation punctuation">@Rule</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">is_su_rule</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">bool</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token builtin">str</span><span class="token punctuation">(</span>event<span class="token punctuation">.</span>user_id<span class="token punctuation">)</span> <span class="token keyword">in</span> _superusers
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="class-rule" tabindex="-1"><a class="header-anchor" href="#class-rule"><span><strong>class</strong> <code>Rule</code></span></a></h3><h3 id="method-init-self-handler-rulehandlerfunc" tabindex="-1"><a class="header-anchor" href="#method-init-self-handler-rulehandlerfunc"><span><em>method</em> <code>__init__(self, handler: RuleHandlerFunc)</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">__init__</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> handler<span class="token punctuation">:</span> RuleHandlerFunc<span class="token punctuation">)</span><span class="token punctuation">:</span>
self<span class="token punctuation">.</span>handler <span class="token operator">=</span> handler
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="method-or-self-other-rule-rule" tabindex="-1"><a class="header-anchor" href="#method-or-self-other-rule-rule"><span><em>method</em> <code>__or__(self, other: Rule) -&gt; Rule</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">__or__</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> other<span class="token punctuation">:</span> <span class="token string">&#39;Rule&#39;</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token string">&#39;Rule&#39;</span><span class="token punctuation">:</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">combined_handler</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">bool</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> self<span class="token punctuation">.</span>handler<span class="token punctuation">(</span>event<span class="token punctuation">)</span> <span class="token keyword">or</span> <span class="token keyword">await</span> other<span class="token punctuation">.</span>handler<span class="token punctuation">(</span>event<span class="token punctuation">)</span>
<span class="token keyword">return</span> Rule<span class="token punctuation">(</span>combined_handler<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="method-and-self-other-rule-rule" tabindex="-1"><a class="header-anchor" href="#method-and-self-other-rule-rule"><span><em>method</em> <code>__and__(self, other: Rule) -&gt; Rule</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">__and__</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> other<span class="token punctuation">:</span> <span class="token string">&#39;Rule&#39;</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token string">&#39;Rule&#39;</span><span class="token punctuation">:</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">combined_handler</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">bool</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> self<span class="token punctuation">.</span>handler<span class="token punctuation">(</span>event<span class="token punctuation">)</span> <span class="token keyword">and</span> <span class="token keyword">await</span> other<span class="token punctuation">.</span>handler<span class="token punctuation">(</span>event<span class="token punctuation">)</span>
<span class="token keyword">return</span> Rule<span class="token punctuation">(</span>combined_handler<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="async-method-call-self-event-messageevent-bool" tabindex="-1"><a class="header-anchor" href="#async-method-call-self-event-messageevent-bool"><span><em>async method</em> <code>__call__(self, event: MessageEvent) -&gt; bool</code></span></a></h3><details><summary><b>源代码</b></summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">__call__</span><span class="token punctuation">(</span>self<span class="token punctuation">,</span> event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> <span class="token builtin">bool</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> self<span class="token punctuation">.</span>handler <span class="token keyword">is</span> <span class="token boolean">None</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token boolean">True</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> self<span class="token punctuation">.</span>handler<span class="token punctuation">(</span>event<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="var-superusers-get-config-liteyuki-superusers" tabindex="-1"><a class="header-anchor" href="#var-superusers-get-config-liteyuki-superusers"><span><em><strong>var</strong></em> <code>_superusers = get_config(&#39;liteyuki.superusers&#39;, [])</code></span></a></h3><ul><li><strong>类型</strong>: <code>list[str]</code></li></ul><h3 id="var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool" tabindex="-1"><a class="header-anchor" href="#var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool"><span><em><strong>var</strong></em> <code>RuleHandlerFunc = Callable[[MessageEvent], Coroutine[None, None, bool]]</code></span></a></h3><ul><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>说明</strong>: 规则函数签名</p></li></ul>`,19),o=[l];function p(c,r){return e(),s("div",null,o)}const i=n(t,[["render",p],["__file","rule.html.vue"]]),d=JSON.parse(`{"path":"/api/message/rule.html","title":"liteyuki.message.rule","lang":"zh-CN","frontmatter":{"title":"liteyuki.message.rule","description":"@Rule async func empty_rule() -> bool 源代码 @Rule async func is_su_rule() -> bool 源代码 class Rule method __init__(self, handler: RuleHandlerFunc) 源代码 method __or__(self, other: Rul...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/api/message/rule.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/api/message/rule.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.message.rule"}],["meta",{"property":"og:description","content":"@Rule async func empty_rule() -> bool 源代码 @Rule async func is_su_rule() -> bool 源代码 class Rule method __init__(self, handler: RuleHandlerFunc) 源代码 method __or__(self, other: Rul..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.message.rule\\",\\"image\\":[\\"\\"],\\"dateModified\\":null,\\"author\\":[]}"]]},"headers":[{"level":3,"title":"@Rule","slug":"rule","link":"#rule","children":[]},{"level":3,"title":"async func empty_rule() -> bool","slug":"async-func-empty-rule-bool","link":"#async-func-empty-rule-bool","children":[]},{"level":3,"title":"@Rule","slug":"rule-1","link":"#rule-1","children":[]},{"level":3,"title":"async func is_su_rule() -> bool","slug":"async-func-is-su-rule-bool","link":"#async-func-is-su-rule-bool","children":[]},{"level":3,"title":"class Rule","slug":"class-rule","link":"#class-rule","children":[]},{"level":3,"title":"method __init__(self, handler: RuleHandlerFunc)","slug":"method-init-self-handler-rulehandlerfunc","link":"#method-init-self-handler-rulehandlerfunc","children":[]},{"level":3,"title":"method __or__(self, other: Rule) -> Rule","slug":"method-or-self-other-rule-rule","link":"#method-or-self-other-rule-rule","children":[]},{"level":3,"title":"method __and__(self, other: Rule) -> Rule","slug":"method-and-self-other-rule-rule","link":"#method-and-self-other-rule-rule","children":[]},{"level":3,"title":"async method __call__(self, event: MessageEvent) -> bool","slug":"async-method-call-self-event-messageevent-bool","link":"#async-method-call-self-event-messageevent-bool","children":[]},{"level":3,"title":"var _superusers = get_config('liteyuki.superusers', [])","slug":"var-superusers-get-config-liteyuki-superusers","link":"#var-superusers-get-config-liteyuki-superusers","children":[]},{"level":3,"title":"var RuleHandlerFunc = Callable[[MessageEvent], Coroutine[None, None, bool]]","slug":"var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool","link":"#var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool","children":[]}],"git":{"createdTime":null,"updatedTime":null,"contributors":[]},"readingTime":{"minutes":0.72,"words":216},"filePathRelative":"api/message/rule.md","autoDesc":true}`);export{i as comp,d as data};