Skip to content

关于 matcher.reject 是否有全局强制中断方法。 #43

Answered by yanyongyu
nanshaobit asked this question in 问答
Discussion options

You must be logged in to vote

你可以写一个args_parser并在其中进行退出判断调用finish来进行退出

async def allow_cancel(bot: Bot, event: Event, state: T_State):
    """An args parser allows to finish the session."""
    message = str(event.get_message())
    if message == "取消":
        await bot.send(event, "已取消")
        raise FinishedException
    state[state["_current_key"]] = str(event.get_message())

并在matcher中注册

matcher.args_parser(allow_cancel)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nanshaobit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
问答
Labels
None yet
2 participants