1
0
forked from bot/app
LiteyukiBot/assets/on.html-C-mSYOEh.js

19 lines
10 KiB
JavaScript

import{_ as n,o as a,c as s,e}from"./app-gnbtOU7f.js";const t={},o=e(`<h3 id="func-add-matcher" tabindex="-1"><a class="header-anchor" href="#func-add-matcher"><span><em>func</em> <code>add_matcher()</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">add_matcher</span><span class="token punctuation">(</span>matcher<span class="token punctuation">:</span> Matcher<span class="token punctuation">)</span><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>
</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></div></details><h3 id="func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher" tabindex="-1"><a class="header-anchor" href="#func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher"><span><em>func</em> <code>on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -&gt; Matcher</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">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>
add_matcher<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></div></details><h3 id="func-on-keywords-keywords-list-str-empty-rule-rule-0-priority-int-false-matcher" tabindex="-1"><a class="header-anchor" href="#func-on-keywords-keywords-list-str-empty-rule-rule-0-priority-int-false-matcher"><span><em>func</em> <code>on_keywords(keywords: list[str] = empty_rule, rule = 0, priority: int = False) -&gt; Matcher</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">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="var-matcher-list" tabindex="-1"><a class="header-anchor" href="#var-matcher-list"><span><em><strong>var</strong></em> <code>_matcher_list = []</code></span></a></h3><ul><li><strong>类型</strong>: <code>list[Matcher]</code></li></ul><h3 id="var-queue-queue" tabindex="-1"><a class="header-anchor" href="#var-queue-queue"><span><em><strong>var</strong></em> <code>_queue = Queue()</code></span></a></h3><ul><li><strong>类型</strong>: <code>Queue</code></li></ul>`,10),p=[o];function l(c,r){return a(),s("div",null,p)}const u=n(t,[["render",l],["__file","on.html.vue"]]),d=JSON.parse('{"path":"/dev/api/message/on.html","title":"liteyuki.message.on","lang":"zh-CN","frontmatter":{"title":"liteyuki.message.on","description":"func add_matcher() 源代码 func on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher 源代码 func on_keywords(keywords: list[str] = empty_rule, rule = ...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/message/on.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/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":"func add_matcher() 源代码 func on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher 源代码 func on_keywords(keywords: list[str] = empty_rule, rule = ..."}],["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.on\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2024-08-29T06:19:39.000Z\\",\\"author\\":[]}"]]},"headers":[{"level":3,"title":"func add_matcher()","slug":"func-add-matcher","link":"#func-add-matcher","children":[]},{"level":3,"title":"func on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher","slug":"func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher","link":"#func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher","children":[]},{"level":3,"title":"func on_keywords(keywords: list[str] = empty_rule, rule = 0, priority: int = False) -> Matcher","slug":"func-on-keywords-keywords-list-str-empty-rule-rule-0-priority-int-false-matcher","link":"#func-on-keywords-keywords-list-str-empty-rule-rule-0-priority-int-false-matcher","children":[]},{"level":3,"title":"var _matcher_list = []","slug":"var-matcher-list","link":"#var-matcher-list","children":[]},{"level":3,"title":"var _queue = Queue()","slug":"var-queue-queue","link":"#var-queue-queue","children":[]}],"git":{"createdTime":1724234361000,"updatedTime":1724912379000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":2}]},"readingTime":{"minutes":0.49,"words":146},"filePathRelative":"dev/api/message/on.md","localizedDate":"2024年8月21日","autoDesc":true}');export{u as comp,d as data};