import{_ as s,c as i,o as a,a6 as e}from"./chunks/framework.BcfwU5BI.js";const g=JSON.parse('{"title":"liteyuki.message.on","description":"","frontmatter":{"title":"liteyuki.message.on"},"headers":[],"relativePath":"en/dev/api/message/on.md","filePath":"en/dev/api/message/on.md","lastUpdated":1725101868000}'),t={name:"en/dev/api/message/on.md"},n=e(`
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/19 下午10:52 @Author : snowykami @Email : snowykami@outlook.com @File : on.py @Software: PyCharm
add_matcher(matcher: Matcher)
def add_matcher(matcher: Matcher):
for i, m in enumerate(_matcher_list):
if m.priority < matcher.priority:
_matcher_list.insert(i, matcher)
break
else:
_matcher_list.append(matcher)
on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher
def on_message(rule: Rule=empty_rule, priority: int=0, block: bool=False) -> Matcher:
matcher = Matcher(rule, priority, block)
add_matcher(matcher)
return matcher
on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher
def on_keywords(keywords: list[str], rule=empty_rule, priority: int=0, block: bool=False) -> Matcher:
@Rule
async def on_keywords_rule(event: MessageEvent):
return any((keyword in event.raw_message for keyword in keywords))
return on_message(on_keywords_rule & rule, priority, block)