From 00985e7fb8ef33da77f528149ede438ccd8eefcb Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Fri, 14 Oct 2022 14:12:09 +0800 Subject: [PATCH] fix bili live sign bugs --- .../qqbot/models/BiliBili/BiliBiliLive.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java index f9d9085..bf64b9a 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java @@ -20,7 +20,7 @@ public class BiliBiliLive extends Model { @Override public String[] getUsePowers() { return new String[]{ - Model.QQGroupCommands.BILI_LIVE_DANMU_SEND + Model.QQGroupCommands.BILI_LIVE_DANMU_SEND }; } @@ -32,28 +32,31 @@ public class BiliBiliLive extends Model { @Override public synchronized void onTime(Long qq, String time) { super.onTime(qq, time); - if("00:01:00".equals(time)){ + if ("00:01:00".equals(time)) { QQBotManager.getInstance().sendMessage(qq, BiliBiliUtils.liveSignIn()); Set biliLive = RedisTools.list_get("bili_live"); - StringBuilder builder=new StringBuilder(); + StringBuilder builder = new StringBuilder(); for (String id : biliLive) { boolean sign = BiliBiliUtils.sendLiveDanmu(Integer.getInteger(id), "打卡"); builder.append("BiliLiveSign ").append(id).append(":").append(sign).append("\n"); } - QQBotManager.getInstance().sendMessage(qq,builder.toString()); + QQBotManager.getInstance().sendMessage(qq, builder.toString()); } } @Override public void onMessage(Long qq, MessageEvent event, boolean isGroup) { super.onMessage(qq, event, isGroup); + if (!msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_SEND)) { + return; + } + StringBuilder message; try { Integer roomId = Integer.getInteger(msg); - StringBuilder message; - if(BiliBiliUtils.checkLiveRoom(roomId)&&!RedisTools.list_isExist("bili_live",roomId+"")){ - RedisTools.list_add("bili_live",roomId+""); + if (BiliBiliUtils.checkLiveRoom(roomId) && !RedisTools.list_isExist("bili_live", roomId + "")) { + RedisTools.list_add("bili_live", roomId + ""); message = new StringBuilder("live sign Add Success"); - }else{ + } else { message = new StringBuilder("live sign Add Error\n"); message.append("-----live sign roomId-----\n"); Set biliLive = RedisTools.list_get("bili_live"); @@ -61,10 +64,15 @@ public class BiliBiliLive extends Model { message.append(id).append("\n"); } } - QQBotManager.getInstance().sendMessage(qq,message.toString()); - }catch (Exception e){ - e.printStackTrace(); + } catch (Exception e) { + message = new StringBuilder("live sign Add Error\n"); + message.append("-----live sign roomId-----\n"); + Set biliLive = RedisTools.list_get("bili_live"); + for (String id : biliLive) { + message.append(id).append("\n"); + } } + QQBotManager.getInstance().sendMessage(qq, message.toString()); } }