mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-07 12:23:00 +08:00
commit
936fd20919
@ -360,13 +360,13 @@ async def do_dispatch_command(
|
|||||||
"message",
|
"message",
|
||||||
Rule(),
|
Rule(),
|
||||||
permission,
|
permission,
|
||||||
None,
|
handlers=None,
|
||||||
True,
|
temp=True,
|
||||||
priority=0,
|
priority=0,
|
||||||
block=True,
|
block=True,
|
||||||
plugin=matcher.plugin,
|
plugin=matcher.plugin,
|
||||||
module=matcher.module,
|
module=matcher.module,
|
||||||
expire_time=datetime.now() + bot.config.session_expire_timeout,
|
expire_time=datetime.now(),
|
||||||
default_state=matcher.state,
|
default_state=matcher.state,
|
||||||
default_type_updater=matcher.__class__._default_type_updater,
|
default_type_updater=matcher.__class__._default_type_updater,
|
||||||
default_permission_updater=matcher.__class__._default_permission_updater,
|
default_permission_updater=matcher.__class__._default_permission_updater,
|
||||||
@ -379,34 +379,3 @@ async def do_dispatch_command(
|
|||||||
do_del_sub(new_matcher)
|
do_del_sub(new_matcher)
|
||||||
new_matcher_ins = new_matcher()
|
new_matcher_ins = new_matcher()
|
||||||
asyncio.create_task(new_matcher_ins.run(bot, event, state))
|
asyncio.create_task(new_matcher_ins.run(bot, event, state))
|
||||||
|
|
||||||
|
|
||||||
test_matcher = on_command("testtt")
|
|
||||||
|
|
||||||
|
|
||||||
@test_matcher.handle()
|
|
||||||
async def _handler(bot: Bot, event: Event, matcher: Matcher, state: T_State):
|
|
||||||
permission = await matcher.update_permission(bot, event)
|
|
||||||
new_matcher = Matcher.new(
|
|
||||||
"message",
|
|
||||||
Rule(),
|
|
||||||
permission,
|
|
||||||
None,
|
|
||||||
True,
|
|
||||||
priority=0,
|
|
||||||
block=True,
|
|
||||||
plugin=matcher.plugin,
|
|
||||||
module=matcher.module,
|
|
||||||
expire_time=datetime.now() + bot.config.session_expire_timeout,
|
|
||||||
default_state=matcher.state,
|
|
||||||
default_type_updater=matcher.__class__._default_type_updater,
|
|
||||||
default_permission_updater=matcher.__class__._default_permission_updater,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def h():
|
|
||||||
logger.warning("yes")
|
|
||||||
await new_matcher.send("666")
|
|
||||||
|
|
||||||
new_matcher.handle()(h)
|
|
||||||
new_matcher_ins = new_matcher()
|
|
||||||
await new_matcher_ins.run(bot, event, state)
|
|
||||||
|
@ -453,17 +453,3 @@ async def test_del_sub(app: App):
|
|||||||
ctx.should_finished()
|
ctx.should_finished()
|
||||||
subs = config.list_subscribe(10000, "group")
|
subs = config.list_subscribe(10000, "group")
|
||||||
assert len(subs) == 0
|
assert len(subs) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_test(app: App):
|
|
||||||
from nonebot.adapters.onebot.v11.bot import Bot
|
|
||||||
from nonebot.adapters.onebot.v11.message import Message
|
|
||||||
from nonebot_bison.config_manager import test_matcher
|
|
||||||
|
|
||||||
async with app.test_matcher(test_matcher) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
event = fake_group_message_event(message=Message("testtt"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_pass_permission()
|
|
||||||
ctx.should_pass_rule()
|
|
||||||
ctx.should_call_send(event, "666", True)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user