HyDevelop / PicqBotX

基于 CQHTTP 插件的 Java QQ 机器人类库
208 stars 53 forks source link

群成员增加事件监听不起作用 #44

Closed august-xu closed 4 years ago

august-xu commented 4 years ago

监听失效,不进入join方法 日志如下: [20-05-26 22:26:29] [PicqBotX] [DEBUG(java.lang.Thread.run:748)] - 数据: {"group_id":xxxx,"notice_type":"group_increase","operator_id":xxxx,"post_type":"notice","self_id":xxx,"sub_type":"approve","time":1590503189,"user_id":xxx} 代码如下: @EventHandler private void join(EventNoticeGroupMemberIncrease event) {

    System.out.println("进入群事件!");

    IcqHttpApi httpApi = event.getHttpApi();

    Long userid = event.getUserId();

    Long groupId = event.getGroupId();

    if (groupId == targetGroupId) {

        //event.getBot().getAccountManager().refreshCache();

        String message = "xxxxx";

        String raw = new MessageBuilder().add(new 
                     ComponentAt(userid)).add(message).toString();

        httpApi.sendGroupMsg(groupId, raw);

    }
hykilpikonna commented 4 years ago

其他的事件都没问题嘛w? bot.getEventManager().registerListeners(...) 了嘛?

august-xu commented 4 years ago

群聊私聊都没问题,注册了

hykilpikonna commented 4 years ago

好奇怪.... 改成监听 EventNoticeGroupMemberApprove 试试吧w

august-xu commented 4 years ago

改成这个也不行囧

hykilpikonna commented 4 years ago

啊w 是不是你那个方法设成 private 了的问题呀w

august-xu commented 4 years ago

还真是这个问题 囧