import{_ as i,o as a,c as e,a7 as n}from"./chunks/framework._avq4Ty7.js";const c=JSON.parse('{"title":"liteyuki.session.matcher","description":"","frontmatter":{"title":"liteyuki.session.matcher"},"headers":[],"relativePath":"en/dev/api/session/matcher.md","filePath":"en/dev/api/session/matcher.md","lastUpdated":null}'),t={name:"en/dev/api/session/matcher.md"};function l(h,s,r,p,k,o){return a(),e("div",null,s[0]||(s[0]=[n(`

Module liteyuki.session.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)

Description: 匹配器

Arguments:

Source code or View on 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]

Description: 添加处理函数,装饰器

Return: 装饰器 handler

Source code or View on 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

Description: 运行处理函数

Arguments:

Source code or View on 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)]))}const g=i(t,[["render",l]]);export{c as __pageData,g as default};