Skip to main content

- Resource Pack
- Liteyuki Function
- Liteyuki Plugin
- Communication
- - liteyuki
  - liteyuki.config
  - liteyuki.exception
  - liteyuki.log
  - liteyuki.mkdoc
  - liteyuki.utils
  - - liteyuki.message
    - liteyuki.message.event
    - liteyuki.message.matcher
    - liteyuki.message.on
    - liteyuki.message.rule
    - liteyuki.message.session

# liteyuki.message.matcher

SnowyKami
Less than 1 minute
API

On This Page

- def decorator(handler: EventHandler) -> EventHandler
- class Matcher
- def __init__(self, rule: Rule, priority: int, block: bool) -> None
- def handle(self) -> Callable[[EventHandler], EventHandler]

### def `decorator(handler: EventHandler) -> EventHandler`

源代码

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

### class `Matcher`

### def `__init__(self, rule: Rule, priority: int, block: bool) -> None`

匹配器

Args:

    rule: 规则

    priority: 优先级 >= 0

    block: 是否阻断后续优先级更低的匹配器

源代码

    def __init__(self, rule: Rule, priority: int, block: bool):
        """
            匹配器
            Args:
                rule: 规则
                priority: 优先级 >= 0
                block: 是否阻断后续优先级更低的匹配器
            """
        self.rule = rule
        self.priority = priority
        self.block = block
        self.handlers: list[EventHandler] = []

### def `handle(self) -> Callable[[EventHandler], EventHandler]`

添加处理函数，装饰器

Returns:

    装饰器 handler

源代码

    def handle(self) -> Callable[[EventHandler], EventHandler]:
        """
            添加处理函数，装饰器
            Returns:
                装饰器 handler
            """

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