import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message.matcher","description":"","frontmatter":{"title":"liteyuki.message.matcher"},"headers":[],"relativePath":"dev/api/message/matcher.md","filePath":"zh/dev/api/message/matcher.md","lastUpdated":null}'),t={name:"dev/api/message/matcher.md"},n=e(`

模块 liteyuki.message.matcher

Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved

@Time : 2024/8/19 下午10:51 @Author : snowykami @Email : snowykami@outlook.com @File : matcher.py @Software: PyCharm

class Matcher


func __init__(self, rule: Rule, priority: int, block: bool)

说明: 匹配器

参数:

源代码在GitHub上查看
python
def __init__(self, rule: Rule, priority: int, block: bool):
    self.rule = rule
    self.priority = priority
    self.block = block
    self.handlers: list[EventHandler] = []

func handle(self) -> Callable[[EventHandler], EventHandler]

说明: 添加处理函数,装饰器

返回: 装饰器 handler

源代码在GitHub上查看
python
def handle(self) -> Callable[[EventHandler], EventHandler]:

    def decorator(handler: EventHandler) -> EventHandler:
        self.handlers.append(handler)
        return handler
    return decorator

async func run(self, event: MessageEvent) -> None

说明: 运行处理函数

参数:

源代码在GitHub上查看
python
async def run(self, event: MessageEvent) -> None:
    if not await self.rule(event):
        return
    for handler in self.handlers:
        try:
            await handler(event)
        except Exception:
            traceback.print_exc()
`,21),l=[n];function h(r,p,k,o,d,c){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{y as __pageData,E as default};