import{_ as e,o as n,c as s,d as a}from"./app-EhCe7g9m.js";const t={},l=a(`
Source code
@Rule
async def empty_rule(event: MessageEvent) -> bool:
return True
Source code
@Rule
async def is_su_rule(event: MessageEvent) -> bool:
return str(event.user_id) in _superusers
Source code
def __init__(self, handler: RuleHandlerFunc):
self.handler = handler
Source code
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)
Source code
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)
Source code
async def __call__(self, event: MessageEvent) -> bool:
if self.handler is None:
return True
return await self.handler(event)
Type: TypeAlias
Description: 规则函数签名
`,19),o=[l];function c(p,r){return n(),s("div",null,o)}const i=e(t,[["render",c],["__file","rule.html.vue"]]),d=JSON.parse(`{"path":"/en/api/message/rule.html","title":"liteyuki.message.rule","lang":"en-US","frontmatter":{"title":"liteyuki.message.rule","description":"@Rule async func empty_rule() -> bool Source code @Rule async func is_su_rule() -> bool Source code class Rule method __init__(self, handler: RuleHandlerFunc) Source code method...","head":[["link",{"rel":"alternate","hreflang":"zh-cn","href":"https://vuepress-theme-hope-docs-demo.netlify.app/api/message/rule.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/en/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 Source code @Rule async func is_su_rule() -> bool Source code class Rule method __init__(self, handler: RuleHandlerFunc) Source code method..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"en-US"}],["meta",{"property":"og:locale:alternate","content":"zh-CN"}],["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.69,"words":207},"filePathRelative":"en/api/message/rule.md","autoDesc":true}`);export{i as comp,d as data};