mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-15 00:24:26 +08:00
19 lines
10 KiB
JavaScript
19 lines
10 KiB
JavaScript
|
import{_ as n,o as a,c as s,e}from"./app-BvUYPzLF.js";const t={},o=e(`<h1 id="liteyuki-message-on" tabindex="-1"><a class="header-anchor" href="#liteyuki-message-on"><span>liteyuki.message.on</span></a></h1><p><strong>说明</strong>: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/19 下午10:52 @Author : snowykami @Email : snowykami@outlook.com @File : on.py @Software: PyCharm</p><h3 id="def-add-matcher-matcher-matcher" tabindex="-1"><a class="header-anchor" href="#def-add-matcher-matcher-matcher"><span><em><strong>def</strong></em> <code>add_matcher(matcher: Matcher)</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.py#L41" 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">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"><</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="def-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher" tabindex="-1"><a class="header-anchor" href="#def-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher"><span><em><strong>def</strong></em> <code>on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.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 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">></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="def-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher" tabindex="-1"><a class="header-anchor" href="#def-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher"><span><em><strong>def</strong></em> <code>on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher</code></span></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.py#L57" 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">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">></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">&</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>`,9),p=[o];function i(l,r){return a(),s("div",null,p)}const u=n(t,[["render",i],["__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","lastUpdated":false,"description":"liteyuki.message.on 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/8/19 下午10:52 @Author : snowykami @Email : snowykami@outlook.com @File : on.py @S...","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":"liteyuki.message.on 说明: Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved @Time : 2024/8/19 下午10:52 @Author : snowykami @Email : snowykami@outlook.com @File : on.py @S..."}],["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":"def add_matcher(matcher: Matcher)","slug":"def-add-matcher-matcher-matcher","link":"#def-add-matcher-matcher-matcher","children":[]},{"level":3,"title":"def on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher","slug":"def-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher","link":"#def-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher","children":[]},{"level":3,"title":"def on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher","slug":"def-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher","link":"#def-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher","children":[]}],"git":{"createdTime":1724234361000,"updatedTime":1724912379000,"contributors":[{"name":"snowy","email":"snowykami@outlook.com","commits":2}]},"readingTime":{"minutes":0.69,"words":207},"filePathRelative":"dev/api/message/on.md","localizedDate":"2024年8月21日","autoDesc":true}');export{u as comp,d as data};
|