Skip to content
Discussion options

You must be logged in to vote

你可以使用on_message_sent = on("message_sent", block=False),并在你的handler函数前装饰:

@yourcommand.handle()
@on_message_sent.handle()
def yourhandler(bot: Bot, matcher: Matcher, event: Event):
    ...

值得注意的是,event参数应当被声明为Event而非MessageEventGroupMessageEvent,否则mathcer无法正常捕获消息。

同时,"message_sent"模式下的event无法从get_message()或其它方法获得消息,但你可以event.raw_message直接获取机器人账号的消息。你可以通过isinstance(event, Event)来判断当前方法是响应哪个事件来分别获得消息并响应。

Replies: 5 comments 17 replies

Comment options

You must be logged in to vote
1 reply
@mzltest
Comment options

Comment options

You must be logged in to vote
6 replies
@mnixry
Comment options

@yanyongyu
Comment options

@mnixry
Comment options

@yanyongyu
Comment options

@mzltest
Comment options

Comment options

You must be logged in to vote
3 replies
@fu050409
Comment options

@fu050409
Comment options

@mzltest
Comment options

Answer selected by mzltest
Comment options

You must be logged in to vote
5 replies
@yanyongyu
Comment options

@Loping151
Comment options

@faithleysath
Comment options

@Loping151
Comment options

@faithleysath
Comment options

Comment options

You must be logged in to vote
2 replies
@yanyongyu
Comment options

@21036045
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
问答
Labels
None yet
7 participants