一开始是想做一个引用回复的原消息内容的获取,想先本地测试一下避免实操频繁上下线被封号。昨天自己摸索了很久,但是对于单测中如何监听消息并捕获到event中的消息链还是云里雾里的,最下面的订阅事件代码是无效的:

@Test public void test() { MockBot mockBot = MockBotFactory.Companion.newMockBotBuilder().create(); mockBot.addGroup(798100000L, "qqgroup"); Bot bot = mockBot; bot.login(); MessageReceipt message = bot.getGroup(798100000L).sendMessage("hello world"); MessageChain messageChain = new MessageChainBuilder().append(message.quote() + " haha").build(); bot.getGroup(798100000L).sendMessage(messageChain); QuoteReply quoteReply = messageChain.get(QuoteReply.Key); System.out.println(quoteReply); // 事件订阅? bot.getEventChannel().subscribeAlways(GroupMessageEvent.class, (GroupMessageEvent event) -> { System.out.println(event.getMessage().serializeToMiraiCode()); }); bot.getGroup(798100000L).sendMessage("Hi Hi"); }