2024-10-14 00:58:46 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="zh-Hans" dir="ltr">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
|
<title>liteyuki.session.matcher | 轻雪机器人</title>
|
|
|
|
|
<meta name="description" content="一个综合性的机器人应用及管理框架">
|
2024-11-09 23:53:05 +08:00
|
|
|
|
<meta name="generator" content="VitePress v1.5.0">
|
2024-11-16 02:21:14 +08:00
|
|
|
|
<link rel="preload stylesheet" href="/assets/style.ibT9l-Gp.css" as="style">
|
2024-11-09 23:53:05 +08:00
|
|
|
|
<link rel="preload stylesheet" href="/vp-icons.css" as="style">
|
2024-10-14 00:58:46 +08:00
|
|
|
|
|
2024-11-16 02:25:32 +08:00
|
|
|
|
<script type="module" src="/assets/app.BT9SExIC.js"></script>
|
2024-10-14 00:58:46 +08:00
|
|
|
|
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
|
2024-11-16 02:25:32 +08:00
|
|
|
|
<link rel="modulepreload" href="/assets/chunks/theme.DjavgrUf.js">
|
2024-11-16 02:17:59 +08:00
|
|
|
|
<link rel="modulepreload" href="/assets/chunks/framework._avq4Ty7.js">
|
|
|
|
|
<link rel="modulepreload" href="/assets/dev_api_session_matcher.md.DY05_Eet.lean.js">
|
2024-10-14 00:58:46 +08:00
|
|
|
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
|
|
|
<link rel="stylesheet" href="https://fonts.font.im/css?family=Cousine:400,400i,700,700i|Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i">
|
|
|
|
|
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
|
|
|
|
|
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2024-11-16 02:21:14 +08:00
|
|
|
|
<div id="app"><div class="Layout" data-v-2391887b data-v-cf959ac2><!--[--><!--]--><!--[--><span tabindex="-1" data-v-09f1bf64></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-09f1bf64> Skip to content </a><!--]--><!----><header class="VPNav" data-v-cf959ac2 data-v-4a2d6202><div class="VPNavBar" data-v-4a2d6202 data-v-8c2dd89c><div class="wrapper" data-v-8c2dd89c><div class="container" data-v-8c2dd89c><div class="title" data-v-8c2dd89c><div class="VPNavBarTitle has-sidebar" data-v-8c2dd89c data-v-60cf36d1><a class="title" href="/" data-v-60cf36d1><!--[--><!--]--><!--[--><!--[--><!--[--><img class="VPImage dark logo" src="/liteyuki-dark.svg" alt="LiteyukiBot Logo" data-v-e656d635><!--]--><!--[--><img class="VPImage light logo" src="/liteyuki.svg" alt="LiteyukiBot Logo" data-v-e656d635><!--]--><!--]--><!--]--><span data-v-60cf36d1>轻雪机器人</span><!--[--><!--]--></a></div></div><div class="content" data-v-8c2dd89c><div class="content-body" data-v-8c2dd89c><!--[--><!--]--><div class="VPNavBarSearch search" data-v-8c2dd89c><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="打开搜索框"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-8c2dd89c data-v-fb179ef2><span id="main-nav-aria-label" class="visually-hidden" data-v-fb179ef2> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/deploy/install.html" tabindex="0" data-v-fb179ef2 data-v-f6113321><!--[--><span data-v-f6113321>部署</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/usage/basic.html" tabindex="0" data-v-fb179ef2 data-v-f6113321><!--[--><span data-v-f6113321>使用</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/store/resource.html" tabindex="0" data-v-fb179ef2 data-v-f6113321><!--[--><span data-v-f6113321>扩展</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/dev/guide.html" tabindex="0" data-v-fb179ef2 data-v-f6113321><!--[--><span data-v-f6113321>开发</span><!--]--></a><!--]--><!--]--></nav><div class="VPFlyout VPNavBarTranslations translations" data-v-8c2dd89c data-v-7a36dbca data-v-32e61f0e><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="语言" data-v-32e61f0e><span class="text" data-v-32e61f0e><span class="vpi-languages option-icon" data-v-32e61f0e></span><!----><span class="vpi-chevron-down text-icon" data-v-32e61f0e></span></span></button><div class="menu" data-v-32e61f0e><div class="VPMenu" data-v-32e61f0e data-v-12ef594d><!----><!--[--><!--[--><div class="items" data-v-7a36dbca><p class="title" data-v-7a36dbca>简体中文</p><!--[--><div class="VPMenuLink" data-v-7a36dbca data-v-a334e8c3><a class="VPLink link" href="/en/dev/api/session/matcher.html" data-v-a334e8c3><!--[--><span data-v-a334e8c3>English</span><!--]--></a></div><!--]--></div><!--]--><!--]--></div></div></div><div class="VPNavBarAppearance appearance" data-v-8c2dd89c data-v-824ec8bd><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-824ec8bd data-v-d8e7d9d8 data-v-61ab5455><span class="check" data-v-61ab5455><span class="icon" data-v-61ab5455><!--[--><span class="vpi-sun sun" data-v-d8e7d9d8></span><span class="vpi-moon moon" data-v-d8e7d9d8></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-8c2dd89c data-v-b9e91830 data-v-0d378c5e><!--[--><a class="VPSocialLink no-icon" href="https://github.com/LiteyukiStudio/LiteyukiBot" aria-label="github" target="_blank" rel="noopener" data-v-0d378c5e data-v-229dabda><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon
|
2024-10-14 00:58:46 +08:00
|
|
|
|
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.rule </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> rule</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.priority </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> priority</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.block </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> block</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers: list[EventHandler] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span></code></pre></div></details><hr><h4 id="func-handle-self-callable-eventhandler-eventhandler" tabindex="-1"><em><strong>func</strong></em> <code>handle(self) -> Callable[[EventHandler], EventHandler]</code> <a class="header-anchor" href="#func-handle-self-callable-eventhandler-eventhandler" aria-label="Permalink to "***func*** `handle(self) -> Callable[[EventHandler], EventHandler]`""></a></h4><p><strong>说明</strong>: 添加处理函数,装饰器</p><p><strong>返回</strong>: 装饰器 handler</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/session/matcher.py#L37" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -> Callable[[EventHandler], EventHandler]:</span></span>
|
|
|
|
|
<span class="line"></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> decorator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(handler: EventHandler) -> EventHandler:</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers.append(handler)</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> decorator</span></span></code></pre></div></details><hr><h4 id="async-func-run-self-event-messageevent-none" tabindex="-1"><em><strong>async func</strong></em> <code>run(self, event: MessageEvent) -> None</code> <a class="header-anchor" href="#async-func-run-self-event-messageevent-none" aria-label="Permalink to "***async func*** `run(self, event: MessageEvent) -> None`""></a></h4><p><strong>说明</strong>: 运行处理函数</p><p><strong>参数</strong>:</p><blockquote><ul><li>event:</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/session/matcher.py#L49" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event: MessageEvent) -> </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.rule(event):</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers:</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler(event)</span></span>
|
|
|
|
|
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
2024-11-16 02:21:14 +08:00
|
|
|
|
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span></code></pre></div></details></div></div></main><footer class="VPDocFooter" data-v-92d339c1 data-v-d71d06df><!--[--><!--]--><div class="edit-info" data-v-d71d06df><div class="edit-link" data-v-d71d06df><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/session/matcher.py" target="_blank" rel="noreferrer" data-v-d71d06df><!--[--><span class="vpi-square-pen edit-link-icon" data-v-d71d06df></span> 在 GitHub 上编辑此页<!--]--></a></div><!----></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-d71d06df><span class="visually-hidden" id="doc-footer-aria-label" data-v-d71d06df>Pager</span><div class="pager" data-v-d71d06df><a class="VPLink link pager-link prev" href="/dev/api/session/" data-v-d71d06df><!--[--><span class="desc" data-v-d71d06df>上一页</span><span class="title" data-v-d71d06df>liteyuki.session</span><!--]--></a></div><div class="pager" data-v-d71d06df><a class="VPLink link pager-link next" href="/dev/api/session/message/segments.html" data-v-d71d06df><!--[--><span class="desc" data-v-d71d06df>下一页</span><span class="title" data-v-d71d06df>liteyuki.session.message.segments</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-cf959ac2 data-v-2c1ead0b><div class="container" data-v-2c1ead0b><p class="message" data-v-2c1ead0b>文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成</p><p class="copyright" data-v-2c1ead0b>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p></div></footer><!--[--><!--]--></div></div>
|
2024-11-16 02:25:32 +08:00
|
|
|
|
<script>window.__VP_HASH_MAP__=JSON.parse("{\"deploy_config.md\":\"1_CQ0FbK\",\"deploy_fandq.md\":\"BPleytoW\",\"deploy_install.md\":\"Sk9eehU9\",\"dev_api_bot_index.md\":\"Bi674fgO\",\"dev_api_bot_lifespan.md\":\"2zK906gE\",\"dev_api_comm_channel.md\":\"2kL837ew\",\"dev_api_comm_event.md\":\"BU5q7K5I\",\"dev_api_comm_index.md\":\"BQ4CZLqP\",\"dev_api_comm_storage.md\":\"DqJ8aVqB\",\"dev_api_config.md\":\"BF9ZWJMD\",\"dev_api_core_index.md\":\"C7-mYcFb\",\"dev_api_core_manager.md\":\"D-46Ej1L\",\"dev_api_dev_index.md\":\"C-Z4jV0w\",\"dev_api_dev_observer.md\":\"C8n3KGB-\",\"dev_api_dev_plugin.md\":\"kuS0l6X3\",\"dev_api_exception.md\":\"B1ZNvi-7\",\"dev_api_index.md\":\"DCSHyQNH\",\"dev_api_log.md\":\"Cht1l-z0\",\"dev_api_plugin_index.md\":\"Ob9cT1Tw\",\"dev_api_plugin_load.md\":\"B8TUs35a\",\"dev_api_plugin_manager.md\":\"CV_EY-n_\",\"dev_api_plugin_model.md\":\"B6zUTgyK\",\"dev_api_plugins_index.md\":\"BJaF6GJo\",\"dev_api_plugins_liteecho.md\":\"0olLW-gF\",\"dev_api_plugins_plugin_loader_index.md\":\"Bk_JMvR5\",\"dev_api_session_event.md\":\"eoIRQPSp\",\"dev_api_session_index.md\":\"BB5rwUqh\",\"dev_api_session_matcher.md\":\"DY05_Eet\",\"dev_api_session_message_segments.md\":\"0beZiwPd\",\"dev_api_session_models.md\":\"Jq2lUC1f\",\"dev_api_session_on.md\":\"ClG5jupL\",\"dev_api_session_rule.md\":\"Jlr6fWcz\",\"dev_api_utils.md\":\"BCPR7M6j\",\"dev_best_practices.md\":\"Cymrt9FM\",\"dev_comm.md\":\"BdU9h70O\",\"dev_guide.md\":\"CKJge6Av\",\"dev_lyfunc.md\":\"CTyKZzIv\",\"dev_plugin.md\":\"Cw4jmM1r\",\"dev_resource.md\":\"DHaliAic\",\"en_deploy_config.md\":\"BQn5E2Bj\",\"en_deploy_fandq.md\":\"BrjsxnAp\",\"en_deploy_install.md\":\"YWJCbrQ9\",\"en_dev_api_bot_index.md\":\"D7pBXyxE\",\"en_dev_api_bot_lifespan.md\":\"CB0llI1b\",\"en_dev_api_comm_channel.md\":\"BEDKOQou\",\"en_dev_api_comm_event.md\":\"DZFP2XdR\",\"en_dev_api_comm_index.md\":\"fm8_o36k\",\"en_dev_api_comm_storage.md\":\"CrdoT2Rt\",\"en_dev_api_config.md\":\"DXvPY7q0\",\"en_dev_api_core_index.md\":\"B8YwtibJ\",\"en_dev_api_core_manager.md\":\"DY8pAztC\",\"en_dev_api_dev_index.md\":\"BsvLsbb9\",\"en_dev_api_dev_observer.md\":\"Z8JLVw48\",\"en_dev_api_dev_plugin.md\":\"B4YGlvi7\",\"en_dev_api_exception.md\":\"Bi5kZE7B\",\"en_dev_api_index.md\":\"BRwWnJjT\",\"en_dev_api_log.md\":\"CYlQgvc9\",\"en_dev_api_plugin_index.md\":\"DMMLxcgg\",\"en_dev_api_plugin_load.md\":\"DBI0e8uW\",\"en_dev_api_plugin_manager.md\":\"YuROJtz4\",\"en_dev_api_plugin_model.md\":\"DzkLtdgt\",\"en_dev_api_plugins_index.md\":\"CcwDiD2t\",\"en_dev_api_plugins_liteecho.md\":\"XcPv4epx\",\"en_dev_api_plugins_plugin_loader_index.md\":\"DfULXUOM\",\"en_dev_api_session_event.md\":\"C68739Mu\",\"en_dev_api_session_index.md\":\"DlOjeQ_f\",\"en_dev_api_session_matcher.md\":\"Dsdkm06f\",\"en_dev_api_session_message_segments.md\":\"C40mpa6j\",\"en_dev_api_session_models.md\":\"5kxE35_Q\",\"en_dev_api_session_on.md\":\"CF0RXj7a\",\"en_dev_api_session_rule.md\":\"e29t-o48\",\"en_dev_api_utils.md\":\"IxF_QKMD\",\"en_dev_best_practices.md\":\"BL1nZ6wX\",\"en_dev_comm.md\":\"BD35_Pc4\",\"en_dev_guide.md\":\"CaoulG2S\",\"en_dev_lyfunc.md\":\"C0J7k9S-\",\"en_dev_plugin.md\":\"CZ1fZOSs\",\"en_dev_resource.md\":\"gbYl02_m\",\"en_index.md\":\"B7vJePRY\",\"en_store_plugin.md\":\"CKMtd26v\",\"en_store_resource.md\":\"B0jzMlOl\",\"en_usage_agreement.md\":\"DB-DF9k9\",\"en_usage_basic.md\":\"CqXCUHon\",\"en_usage_extra.md\":\"NcwXX0cF\",\"index.md\":\"DHOhfNpJ\",\"store_plugin.md\":\"BG-hPX54\",\"store_resource.md\":\"DxmwBnW7\",\"usage_agreement.md\":\"DgIDC_u9\",\"usage_basic.md\":\"D0kl3gm6\",\"usage_extra.md\":\"CsRUq0wh\"}");function deserializeFunctions(r){return Array.isArray(r)?r.map(deserializeFunctions):typeof r=="object"&&r!==null?Object.keys(r).reduce((t,n)=>(t[n]=deserializeFunctions(r[n]),t),{}):typeof r=="string"&&r.startsWith("_vp-fn_")?new Function(`return ${r.slice(7)}`)():r};window.__VP_SITE_DATA__=deserializeFunctions(JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"VitePress\",\"description\":\"A VitePress site\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\
|
2024-10-14 00:58:46 +08:00
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|