import{_ as s,c as i,o as e,a4 as a}from"./chunks/framework.C3o_UkTa.js";const y=JSON.parse('{"title":"liteyuki.message.rule","description":"","frontmatter":{"title":"liteyuki.message.rule"},"headers":[],"relativePath":"dev/api/message/rule.md","filePath":"zh/dev/api/message/rule.md","lastUpdated":null}'),t={name:"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

var RuleHandlerFunc

class Rule

def __init__(self, handler: RuleHandlerFunc)

源代码在GitHub上查看
python
def __init__(self, handler: RuleHandlerFunc):\n    self.handler = handler

def __or__(self, other: Rule) -> Rule

源代码在GitHub上查看
python
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)

def __and__(self, other: Rule) -> Rule

源代码在GitHub上查看
python
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)

async def __call__(self, event: MessageEvent) -> bool

源代码在GitHub上查看
python
async def __call__(self, event: MessageEvent) -> bool:\n    if self.handler is None:\n        return True\n    return await self.handler(event)

@Rule

async def empty_rule(event: MessageEvent) -> bool

源代码在GitHub上查看
python
@Rule\nasync def empty_rule(event: MessageEvent) -> bool:\n    return True

@Rule

async def is_su_rule(event: MessageEvent) -> bool

源代码在GitHub上查看
python
@Rule\nasync def is_su_rule(event: MessageEvent) -> bool:\n    return str(event.user_id) in _superusers
',20),l=[n];function h(r,p,k,d,o,g){return e(),i("div",null,l)}const c=s(t,[["render",h]]);export{y as __pageData,c as default};