This repository has been archived by the owner on Dec 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
如何才能监听到收到消息的事件 #19
Comments
这个是 mirai-core 的问题,正在尝试解决 |
好的,谢谢,请问使用以前的版本有这个问题吗? |
可能可以在1.0-EA2或者1.0-EA中正常 |
我在另一个Issues中听说是匿名内部类的问题,好像有人已经调出来了,但是我却发生了新的异常 public static class CustomEventListener extends SimpleListenerHost {
@EventHandler
public ListeningStatus onFriendMsg(FriendMessageEvent event) {
MessageReceipt<Contact> receipt = event.getSender().sendMessage("测试测试");
receipt.recallIn(10000);
return ListeningStatus.LISTENING;
}
@Override
public void handleException(@NotNull CoroutineContext context, @javax.validation.constraints.NotNull Throwable exception) {
super.handleException(context, exception);
}
}
public static void main(String[] args) throws InterruptedException {
final Bot bot = BotFactoryJvm.newBot(qq, password, new BotConfiguration() {
{
fileBasedDeviceInfo("deviceInfo.json");
}
});
bot.login();
Events.registerEvents(bot, new CustomEventListener());
bot.join();
} 异常信息:
|
@HappyOnion801 请问这个问题发生时使用的 mirai 版本是多少? |
mirai-core-1.1.-EA2 |
请在 mirai core 已有的issue中继续这类问题的讨论 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
我测试了那个Demo的代码,已经成功地登录了,也可以发送消息,到时我发现并不能监听到收到消息的事件
bot.login();
bot.getFriends().forEach(friend -> System.out.println(friend.getId() + ":" + friend.getNick()));
Events.registerEvents(bot, new SimpleListenerHost() {
@eventhandler
public ListeningStatus onGroupMessage(GroupMessageEvent event) {
System.out.println("你收到了新的群消息!");
return ListeningStatus.LISTENING;
}
@OverRide
public void handleException(@NotNull CoroutineContext context, @NotNull Throwable exception) {
throw new RuntimeException("在事件处理中发生异常", exception);
}
});
The text was updated successfully, but these errors were encountered: