mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-14 13:47:24 +08:00
24 lines
13 KiB
JavaScript
24 lines
13 KiB
JavaScript
import{_ as e,o as n,c as s,e as a}from"./app-BvUYPzLF.js";const t={},o=a(`<h1 id="liteyuki-message-rule" tabindex="-1"><a class="header-anchor" href="#liteyuki-message-rule"><span>liteyuki.message.rule</span></a></h1><p><strong>说明</strong>: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/19 下午10:55 @Author : snowykami @Email : snowykami@outlook.com @File : rule.py @Software: PyCharm</p><h3 id="var-rulehandlerfunc" tabindex="-1"><a class="header-anchor" href="#var-rulehandlerfunc"><span>var <code>RuleHandlerFunc</code></span></a></h3><ul><li><p><strong>说明</strong>: 规则函数签名</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[MessageEvent], Coroutine[None, None, bool]]</code></p></li></ul><h3 id="class-rule" tabindex="-1"><a class="header-anchor" href="#class-rule"><span><em><strong>class</strong></em> <code>Rule</code></span></a></h3><h4 id="def-init-self-handler-rulehandlerfunc" tabindex="-1"><a class="header-anchor" href="#def-init-self-handler-rulehandlerfunc"><span><em><strong>def</strong></em> <code>__init__(self, handler: RuleHandlerFunc)</code></span></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L24" target="_blank">在GitHub上查看</a></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><h4 id="def-or-self-other-rule-rule" tabindex="-1"><a class="header-anchor" href="#def-or-self-other-rule-rule"><span><em><strong>def</strong></em> <code>__or__(self, other: Rule) -> Rule</code></span></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L27" target="_blank">在GitHub上查看</a></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">'Rule'</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token string">'Rule'</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">></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><h4 id="def-and-self-other-rule-rule" tabindex="-1"><a class="header-anchor" href="#def-and-self-other-rule-rule"><span><em><strong>def</strong></em> <code>__and__(self, other: Rule) -> Rule</code></span></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L33" target="_blank">在GitHub上查看</a></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">'Rule'</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token string">'Rule'</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">></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><h4 id="async-def-call-self-event-messageevent-bool" tabindex="-1"><a class="header-anchor" href="#async-def-call-self-event-messageevent-bool"><span><em><strong>async def</strong></em> <code>__call__(self, event: MessageEvent) -> bool</code></span></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L39" target="_blank">在GitHub上查看</a></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">></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><p><code>@Rule</code></p><h3 id="async-def-empty-rule-event-messageevent-bool" tabindex="-1"><a class="header-anchor" href="#async-def-empty-rule-event-messageevent-bool"><span><em><strong>async def</strong></em> <code>empty_rule(event: MessageEvent) -> bool</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L46" target="_blank">在GitHub上查看</a></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">></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><p><code>@Rule</code></p><h3 id="async-def-is-su-rule-event-messageevent-bool" tabindex="-1"><a class="header-anchor" href="#async-def-is-su-rule-event-messageevent-bool"><span><em><strong>async def</strong></em> <code>is_su_rule(event: MessageEvent) -> bool</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/rule.py#L50" target="_blank">在GitHub上查看</a></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">></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>`,20),l=[o];function p(i,r){return n(),s("div",null,l)}const u=e(t,[["render",p],["__file","rule.html.vue"]]),d=JSON.parse('{"path":"/dev/api/message/rule.html","title":"liteyuki.message.rule","lang":"zh-CN","frontmatter":{"title":"liteyuki.message.rule","lastUpdated":false,"description":"liteyuki.message.rule 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/8/19 下午10:55 @Author : snowykami @Email : snowykami@outlook.com @File : rule.p...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/message/rule.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/message/rule.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.message.rule"}],["meta",{"property":"og:description","content":"liteyuki.message.rule 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/8/19 下午10:55 @Author : snowykami @Email : snowykami@outlook.com @File : rule.p..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["meta",{"property":"og:updated_time","content":"2024-08-29T06:19:39.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-29T06:19:39.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.message.rule\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-29T06:19:39.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"var RuleHandlerFunc","slug":"var-rulehandlerfunc","link":"#var-rulehandlerfunc","children":[]},{"level":3,"title":"class Rule","slug":"class-rule","link":"#class-rule","children":[]},{"level":3,"title":"async def empty_rule(event: MessageEvent) -> bool","slug":"async-def-empty-rule-event-messageevent-bool","link":"#async-def-empty-rule-event-messageevent-bool","children":[]},{"level":3,"title":"async def is_su_rule(event: MessageEvent) -> bool","slug":"async-def-is-su-rule-event-messageevent-bool","link":"#async-def-is-su-rule-event-messageevent-bool","children":[]}],"git":{"createdTime":1724234361000,"updatedTime":1724912379000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":2}]},"readingTime":{"minutes":1.09,"words":326},"filePathRelative":"dev/api/message/rule.md","localizedDate":"2024年8月21日","autoDesc":true}');export{u as comp,d as data};
|