跳至主要內容

- 资源包开发
- 轻雪函数
- 轻雪插件开发
- 进程通信
- - liteyuki
  - liteyuki.config
  - liteyuki.exception
  - liteyuki.log
  - liteyuki.mkdoc
  - liteyuki.utils
  - - liteyuki.message
    - liteyuki.message.event
    - liteyuki.message.matcher
    - liteyuki.message.on
    - liteyuki.message.rule
    - liteyuki.message.session

# liteyuki.message.on

远野千束
小于 1 分钟
API

此页内容

- def on_message(rule: Rule, priority: int, block: bool) -> Matcher
- def on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -> Matcher
- async def on_keywords_rule(event: MessageEvent) -> None
- var current_priority = -1
- var matcher = Matcher(rule, priority, block)
- var current_priority = matcher.priority

### def `on_message(rule: Rule, priority: int, block: bool) -> Matcher`

源代码

    def on_message(rule: Rule=empty_rule, priority: int=0, block: bool=False) -> Matcher:
        matcher = Matcher(rule, priority, block)
        for (i, m) in enumerate(_matcher_list):
            if m.priority < matcher.priority:
                _matcher_list.insert(i, matcher)
                break
        else:
            _matcher_list.append(matcher)
        return matcher

### def `on_keywords(keywords: list[str], rule: Any, priority: int, block: bool) -> 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)

### async def `on_keywords_rule(event: MessageEvent) -> None`

源代码

    @Rule
    async def on_keywords_rule(event: MessageEvent):
        return any((keyword in event.raw_message for keyword in keywords))

### var `current_priority = -1`

### var `matcher = Matcher(rule, priority, block)`

### var `current_priority = matcher.priority`