import{_ as n,o as e,c as s,d as a}from"./app-CLi4lRj1.js";const t={},l=a(`

@Rule

async func empty_rule() -> bool

源代码
@Rule
async def empty_rule(event: MessageEvent) -> bool:
    return True

@Rule

async func is_su_rule() -> bool

源代码
@Rule
async def is_su_rule(event: MessageEvent) -> bool:
    return str(event.user_id) in _superusers

class Rule

method __init__(self, handler: RuleHandlerFunc)

源代码
def __init__(self, handler: RuleHandlerFunc):
    self.handler = handler

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

源代码
def __or__(self, other: 'Rule') -> 'Rule':

    async def combined_handler(event: MessageEvent) -> bool:
        return await self.handler(event) or await other.handler(event)
    return Rule(combined_handler)

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

源代码
def __and__(self, other: 'Rule') -> 'Rule':

    async def combined_handler(event: MessageEvent) -> bool:
        return await self.handler(event) and await other.handler(event)
    return Rule(combined_handler)

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

源代码
async def __call__(self, event: MessageEvent) -> bool:
    if self.handler is None:
        return True
    return await self.handler(event)

var _superusers = get_config('liteyuki.superusers', [])

var RuleHandlerFunc = Callable[[MessageEvent], Coroutine[None, None, bool]]

`,19),o=[l];function p(c,r){return e(),s("div",null,o)}const i=n(t,[["render",p],["__file","rule.html.vue"]]),d=JSON.parse(`{"path":"/api/message/rule.html","title":"liteyuki.message.rule","lang":"zh-CN","frontmatter":{"title":"liteyuki.message.rule","description":"@Rule async func empty_rule() -> bool 源代码 @Rule async func is_su_rule() -> bool 源代码 class Rule method __init__(self, handler: RuleHandlerFunc) 源代码 method __or__(self, other: Rul...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/api/message/rule.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/api/message/rule.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.message.rule"}],["meta",{"property":"og:description","content":"@Rule async func empty_rule() -> bool 源代码 @Rule async func is_su_rule() -> bool 源代码 class Rule method __init__(self, handler: RuleHandlerFunc) 源代码 method __or__(self, other: Rul..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"liteyuki.message.rule\\",\\"image\\":[\\"\\"],\\"dateModified\\":null,\\"author\\":[]}"]]},"headers":[{"level":3,"title":"@Rule","slug":"rule","link":"#rule","children":[]},{"level":3,"title":"async func empty_rule() -> bool","slug":"async-func-empty-rule-bool","link":"#async-func-empty-rule-bool","children":[]},{"level":3,"title":"@Rule","slug":"rule-1","link":"#rule-1","children":[]},{"level":3,"title":"async func is_su_rule() -> bool","slug":"async-func-is-su-rule-bool","link":"#async-func-is-su-rule-bool","children":[]},{"level":3,"title":"class Rule","slug":"class-rule","link":"#class-rule","children":[]},{"level":3,"title":"method __init__(self, handler: RuleHandlerFunc)","slug":"method-init-self-handler-rulehandlerfunc","link":"#method-init-self-handler-rulehandlerfunc","children":[]},{"level":3,"title":"method __or__(self, other: Rule) -> Rule","slug":"method-or-self-other-rule-rule","link":"#method-or-self-other-rule-rule","children":[]},{"level":3,"title":"method __and__(self, other: Rule) -> Rule","slug":"method-and-self-other-rule-rule","link":"#method-and-self-other-rule-rule","children":[]},{"level":3,"title":"async method __call__(self, event: MessageEvent) -> bool","slug":"async-method-call-self-event-messageevent-bool","link":"#async-method-call-self-event-messageevent-bool","children":[]},{"level":3,"title":"var _superusers = get_config('liteyuki.superusers', [])","slug":"var-superusers-get-config-liteyuki-superusers","link":"#var-superusers-get-config-liteyuki-superusers","children":[]},{"level":3,"title":"var RuleHandlerFunc = Callable[[MessageEvent], Coroutine[None, None, bool]]","slug":"var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool","link":"#var-rulehandlerfunc-callable-messageevent-coroutine-none-none-bool","children":[]}],"git":{"createdTime":null,"updatedTime":null,"contributors":[]},"readingTime":{"minutes":0.72,"words":216},"filePathRelative":"api/message/rule.md","autoDesc":true}`);export{i as comp,d as data};