import{_ as s,c as i,o as e,a9 as a}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.message.rule","description":"","frontmatter":{"title":"liteyuki.message.rule"},"headers":[],"relativePath":"en/dev/api/message/rule.md","filePath":"en/dev/api/message/rule.md","lastUpdated":1725101868000}'),t={name:"en/dev/api/message/rule.md"},n=a('
liteyuki.message.rule
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/19 下午10:55 @Author : snowykami @Email : snowykami@outlook.com @File : rule.py @Software: PyCharm
RuleHandlerFunc
Description: 规则函数签名
Type: TypeAlias
Default: Callable[[MessageEvent], Coroutine[None, None, bool]]
Rule
__init__(self, handler: RuleHandlerFunc)
def __init__(self, handler: RuleHandlerFunc):\n self.handler = handler
__or__(self, other: Rule) -> Rule
def __or__(self, other: 'Rule') -> 'Rule':\n\n async def combined_handler(event: MessageEvent) -> bool:\n return await self.handler(event) or await other.handler(event)\n return Rule(combined_handler)
__and__(self, other: Rule) -> Rule
def __and__(self, other: 'Rule') -> 'Rule':\n\n async def combined_handler(event: MessageEvent) -> bool:\n return await self.handler(event) and await other.handler(event)\n return Rule(combined_handler)
__call__(self, event: MessageEvent) -> bool
async def __call__(self, event: MessageEvent) -> bool:\n if self.handler is None:\n return True\n return await self.handler(event)
@Rule
empty_rule(event: MessageEvent) -> bool
@Rule\nasync def empty_rule(event: MessageEvent) -> bool:\n return True
@Rule
is_su_rule(event: MessageEvent) -> bool
@Rule\nasync def is_su_rule(event: MessageEvent) -> bool:\n return str(event.user_id) in _superusers