app/assets/on.html-B36wGBuw.js

20 lines
11 KiB
JavaScript

import{_ as n,o as s,c as a,e}from"./app-Du8R6vOa.js";const t={},o=e(`<h3 id="def-on-message-rule-rule-priority-int-block-bool-matcher" tabindex="-1"><a class="header-anchor" href="#def-on-message-rule-rule-priority-int-block-bool-matcher"><span><em><strong>def</strong></em> <code>on_message(rule: Rule, priority: int, block: bool) -&gt; Matcher</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">on_message</span><span class="token punctuation">(</span>rule<span class="token punctuation">:</span> Rule<span class="token operator">=</span>empty_rule<span class="token punctuation">,</span> priority<span class="token punctuation">:</span> <span class="token builtin">int</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> block<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> Matcher<span class="token punctuation">:</span>
matcher <span class="token operator">=</span> Matcher<span class="token punctuation">(</span>rule<span class="token punctuation">,</span> priority<span class="token punctuation">,</span> block<span class="token punctuation">)</span>
<span class="token keyword">for</span> <span class="token punctuation">(</span>i<span class="token punctuation">,</span> m<span class="token punctuation">)</span> <span class="token keyword">in</span> <span class="token builtin">enumerate</span><span class="token punctuation">(</span>_matcher_list<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">if</span> m<span class="token punctuation">.</span>priority <span class="token operator">&lt;</span> matcher<span class="token punctuation">.</span>priority<span class="token punctuation">:</span>
_matcher_list<span class="token punctuation">.</span>insert<span class="token punctuation">(</span>i<span class="token punctuation">,</span> matcher<span class="token punctuation">)</span>
<span class="token keyword">break</span>
<span class="token keyword">else</span><span class="token punctuation">:</span>
_matcher_list<span class="token punctuation">.</span>append<span class="token punctuation">(</span>matcher<span class="token punctuation">)</span>
<span class="token keyword">return</span> matcher
</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></div></details><h3 id="def-on-keywords-keywords-list-str-rule-any-priority-int-block-bool-matcher" tabindex="-1"><a class="header-anchor" href="#def-on-keywords-keywords-list-str-rule-any-priority-int-block-bool-matcher"><span><em><strong>def</strong></em> <code>on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -&gt; Matcher</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">on_keywords</span><span class="token punctuation">(</span>keywords<span class="token punctuation">:</span> <span class="token builtin">list</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">]</span><span class="token punctuation">,</span> rule<span class="token operator">=</span>empty_rule<span class="token punctuation">,</span> priority<span class="token punctuation">:</span> <span class="token builtin">int</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> block<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">&gt;</span> Matcher<span class="token punctuation">:</span>
<span class="token decorator annotation punctuation">@Rule</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">on_keywords_rule</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token builtin">any</span><span class="token punctuation">(</span><span class="token punctuation">(</span>keyword <span class="token keyword">in</span> event<span class="token punctuation">.</span>raw_message <span class="token keyword">for</span> keyword <span class="token keyword">in</span> keywords<span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">return</span> on_message<span class="token punctuation">(</span>on_keywords_rule <span class="token operator">&amp;</span> rule<span class="token punctuation">,</span> priority<span class="token punctuation">,</span> block<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></div></details><h3 id="async-def-on-keywords-rule-event-messageevent-none" tabindex="-1"><a class="header-anchor" href="#async-def-on-keywords-rule-event-messageevent-none"><span><em><strong>async def</strong></em> <code>on_keywords_rule(event: MessageEvent) -&gt; None</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 decorator annotation punctuation">@Rule</span>
<span class="token keyword">async</span> <span class="token keyword">def</span> <span class="token function">on_keywords_rule</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> MessageEvent<span class="token punctuation">)</span><span class="token punctuation">:</span>
<span class="token keyword">return</span> <span class="token builtin">any</span><span class="token punctuation">(</span><span class="token punctuation">(</span>keyword <span class="token keyword">in</span> event<span class="token punctuation">.</span>raw_message <span class="token keyword">for</span> keyword <span class="token keyword">in</span> keywords<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></div></details><h3 id="var-current-priority-1" tabindex="-1"><a class="header-anchor" href="#var-current-priority-1"><span><em><strong>var</strong></em> <code>current_priority = -1</code></span></a></h3><h3 id="var-matcher-matcher-rule-priority-block" tabindex="-1"><a class="header-anchor" href="#var-matcher-matcher-rule-priority-block"><span><em><strong>var</strong></em> <code>matcher = Matcher(rule, priority, block)</code></span></a></h3><h3 id="var-current-priority-matcher-priority" tabindex="-1"><a class="header-anchor" href="#var-current-priority-matcher-priority"><span><em><strong>var</strong></em> <code>current_priority = matcher.priority</code></span></a></h3>`,9),r=[o];function p(i,c){return s(),a("div",null,r)}const u=n(t,[["render",p],["__file","on.html.vue"]]),d=JSON.parse('{"path":"/en/dev/api/message/on.html","title":"liteyuki.message.on","lang":"en-US","frontmatter":{"title":"liteyuki.message.on","order":1,"icon":"laptop-code","category":"API","description":"def on_message(rule: Rule, priority: int, block: bool) -> Matcher 源代码 def on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -> Matcher 源代码 async def on_key...","head":[["link",{"rel":"alternate","hreflang":"zh-cn","href":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/message/on.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/message/on.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot"}],["meta",{"property":"og:title","content":"liteyuki.message.on"}],["meta",{"property":"og:description","content":"def on_message(rule: Rule, priority: int, block: bool) -> Matcher 源代码 def on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -> Matcher 源代码 async def on_key..."}],["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.on\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-21T09:59:21.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"def on_message(rule: Rule, priority: int, block: bool) -> Matcher","slug":"def-on-message-rule-rule-priority-int-block-bool-matcher","link":"#def-on-message-rule-rule-priority-int-block-bool-matcher","children":[]},{"level":3,"title":"def on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -> Matcher","slug":"def-on-keywords-keywords-list-str-rule-any-priority-int-block-bool-matcher","link":"#def-on-keywords-keywords-list-str-rule-any-priority-int-block-bool-matcher","children":[]},{"level":3,"title":"async def on_keywords_rule(event: MessageEvent) -> None","slug":"async-def-on-keywords-rule-event-messageevent-none","link":"#async-def-on-keywords-rule-event-messageevent-none","children":[]},{"level":3,"title":"var current_priority = -1","slug":"var-current-priority-1","link":"#var-current-priority-1","children":[]},{"level":3,"title":"var matcher = Matcher(rule, priority, block)","slug":"var-matcher-matcher-rule-priority-block","link":"#var-matcher-matcher-rule-priority-block","children":[]},{"level":3,"title":"var current_priority = matcher.priority","slug":"var-current-priority-matcher-priority","link":"#var-current-priority-matcher-priority","children":[]}],"git":{"createdTime":1724234361000,"updatedTime":1724234361000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":1}]},"readingTime":{"minutes":0.52,"words":157},"filePathRelative":"en/dev/api/message/on.md","localizedDate":"August 21, 2024","autoDesc":true}');export{u as comp,d as data};