forked from bot/app
34 lines
8.9 KiB
JavaScript
34 lines
8.9 KiB
JavaScript
import{_ as n,o as e,c as a,e as s}from"./app-CrguweBL.js";const t={},l=s(`<h3 id="def-decorator-handler-eventhandler-eventhandler" tabindex="-1"><a class="header-anchor" href="#def-decorator-handler-eventhandler-eventhandler"><span><em><strong>def</strong></em> <code>decorator(handler: EventHandler) -> EventHandler</code></span></a></h3><details><summary>源代码</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">decorator</span><span class="token punctuation">(</span>handler<span class="token punctuation">:</span> EventHandler<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> EventHandler<span class="token punctuation">:</span>
|
||
self<span class="token punctuation">.</span>handlers<span class="token punctuation">.</span>append<span class="token punctuation">(</span>handler<span class="token punctuation">)</span>
|
||
<span class="token keyword">return</span> handler
|
||
</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-matcher" tabindex="-1"><a class="header-anchor" href="#class-matcher"><span><em><strong>class</strong></em> <code>Matcher</code></span></a></h3><h3 id="def-init-self-rule-rule-priority-int-block-bool-none" tabindex="-1"><a class="header-anchor" href="#def-init-self-rule-rule-priority-int-block-bool-none"><span> <em><strong>def</strong></em> <code>__init__(self, rule: Rule, priority: int, block: bool) -> None</code></span></a></h3><p> 匹配器</p><p>Args:</p><pre><code>rule: 规则
|
||
|
||
priority: 优先级 >= 0
|
||
|
||
block: 是否阻断后续优先级更低的匹配器
|
||
</code></pre><details><summary>源代码</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> rule<span class="token punctuation">:</span> Rule<span class="token punctuation">,</span> priority<span class="token punctuation">:</span> <span class="token builtin">int</span><span class="token punctuation">,</span> block<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
||
<span class="token triple-quoted-string string">"""
|
||
匹配器
|
||
Args:
|
||
rule: 规则
|
||
priority: 优先级 >= 0
|
||
block: 是否阻断后续优先级更低的匹配器
|
||
"""</span>
|
||
self<span class="token punctuation">.</span>rule <span class="token operator">=</span> rule
|
||
self<span class="token punctuation">.</span>priority <span class="token operator">=</span> priority
|
||
self<span class="token punctuation">.</span>block <span class="token operator">=</span> block
|
||
self<span class="token punctuation">.</span>handlers<span class="token punctuation">:</span> <span class="token builtin">list</span><span class="token punctuation">[</span>EventHandler<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><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 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 class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-handle-self-callable-eventhandler-eventhandler" tabindex="-1"><a class="header-anchor" href="#def-handle-self-callable-eventhandler-eventhandler"><span> <em><strong>def</strong></em> <code>handle(self) -> Callable[[EventHandler], EventHandler]</code></span></a></h3><p> 添加处理函数,装饰器</p><p>Returns:</p><pre><code>装饰器 handler
|
||
</code></pre><details><summary>源代码</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">handle</span><span class="token punctuation">(</span>self<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> Callable<span class="token punctuation">[</span><span class="token punctuation">[</span>EventHandler<span class="token punctuation">]</span><span class="token punctuation">,</span> EventHandler<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
||
<span class="token triple-quoted-string string">"""
|
||
添加处理函数,装饰器
|
||
Returns:
|
||
装饰器 handler
|
||
"""</span>
|
||
|
||
<span class="token keyword">def</span> <span class="token function">decorator</span><span class="token punctuation">(</span>handler<span class="token punctuation">:</span> EventHandler<span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> EventHandler<span class="token punctuation">:</span>
|
||
self<span class="token punctuation">.</span>handlers<span class="token punctuation">.</span>append<span class="token punctuation">(</span>handler<span class="token punctuation">)</span>
|
||
<span class="token keyword">return</span> handler
|
||
<span class="token keyword">return</span> decorator
|
||
</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 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 class="line-number"></div></div></div></details>`,13),o=[l];function r(i,p){return e(),a("div",null,o)}const d=n(t,[["render",r],["__file","matcher.html.vue"]]),u=JSON.parse('{"path":"/en/dev/api/message/matcher.html","title":"liteyuki.message.matcher","lang":"en-US","frontmatter":{"title":"liteyuki.message.matcher","order":1,"icon":"laptop-code","category":"API","description":"def decorator(handler: EventHandler) -> EventHandler 源代码 class Matcher def __init__(self, rule: Rule, priority: int, block: bool) -> None 匹配器 Args: 源代码 def handle(self) -> Calla...","head":[["link",{"rel":"alternate","hreflang":"zh-cn","href":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/message/matcher.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/message/matcher.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot"}],["meta",{"property":"og:title","content":"liteyuki.message.matcher"}],["meta",{"property":"og:description","content":"def decorator(handler: EventHandler) -> EventHandler 源代码 class Matcher def __init__(self, rule: Rule, priority: int, block: bool) -> None 匹配器 Args: 源代码 def handle(self) -> Calla..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"en-US"}],["meta",{"property":"og:locale:alternate","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2024-08-21T09:59:21.000Z"}],["meta",{"property":"article:modified_time","content":"2024-08-21T09:59:21.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.message.matcher\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-21T09:59:21.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"def decorator(handler: EventHandler) -> EventHandler","slug":"def-decorator-handler-eventhandler-eventhandler","link":"#def-decorator-handler-eventhandler-eventhandler","children":[]},{"level":3,"title":"class Matcher","slug":"class-matcher","link":"#class-matcher","children":[]},{"level":3,"title":"def __init__(self, rule: Rule, priority: int, block: bool) -> None","slug":"def-init-self-rule-rule-priority-int-block-bool-none","link":"#def-init-self-rule-rule-priority-int-block-bool-none","children":[]},{"level":3,"title":"def handle(self) -> Callable[[EventHandler], EventHandler]","slug":"def-handle-self-callable-eventhandler-eventhandler","link":"#def-handle-self-callable-eventhandler-eventhandler","children":[]}],"git":{"createdTime":1724234361000,"updatedTime":1724234361000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":1}]},"readingTime":{"minutes":0.63,"words":188},"filePathRelative":"en/dev/api/message/matcher.md","localizedDate":"August 21, 2024","autoDesc":true}');export{d as comp,u as data};
|