mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 00:31:14 +00:00
change rule
This commit is contained in:
@ -6,9 +6,7 @@ from nonebot.typing import Event
|
||||
from nonebot.plugin import on_message
|
||||
from nonebot.adapters.cqhttp import Bot, Message
|
||||
|
||||
print(repr(Message("asdfasdf[CQ:at,qq=123][CQ:at,qq=all]")))
|
||||
|
||||
test_matcher = on_message(Rule(), state={"default": 1})
|
||||
test_matcher = on_message(state={"default": 1})
|
||||
|
||||
|
||||
@test_matcher.handle()
|
||||
|
@ -1,18 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from nonebot.rule import Rule
|
||||
from nonebot.event import Event
|
||||
from nonebot.plugin import on_metaevent
|
||||
from nonebot.typing import Bot, Event
|
||||
|
||||
|
||||
def heartbeat(bot, event: Event) -> bool:
|
||||
def heartbeat(bot: Bot, event: Event) -> bool:
|
||||
return event.detail_type == "heartbeat"
|
||||
|
||||
|
||||
test_matcher = on_metaevent(Rule(heartbeat))
|
||||
test_matcher = on_metaevent(heartbeat)
|
||||
|
||||
|
||||
@test_matcher.handle()
|
||||
async def handle_heartbeat(bot, event: Event, state: dict):
|
||||
async def handle_heartbeat(bot: Bot, event: Event, state: dict):
|
||||
print("[i] Heartbeat")
|
||||
|
Reference in New Issue
Block a user