From 943a2c933421703370ed4f93d36e9ad7b51c5521 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sat, 7 Jan 2023 10:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96B=E7=AB=99=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=97=B4=E6=AF=8F=E6=97=A5=E7=AD=BE=E5=88=B0=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yutou/qqbot/bilibili/AppUserTask.java | 11 +++++++++++ .../java/com/yutou/qqbot/bilibili/BiliBiliManga.java | 4 ++-- .../yutou/qqbot/models/BiliBili/BiliBiliLive.java | 12 +++++++----- .../qqbot/models/WebSign/BiliBiliMangeSign.java | 12 +++++++----- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/bilibili/AppUserTask.java b/src/main/java/com/yutou/qqbot/bilibili/AppUserTask.java index b5c2970..5d4f832 100644 --- a/src/main/java/com/yutou/qqbot/bilibili/AppUserTask.java +++ b/src/main/java/com/yutou/qqbot/bilibili/AppUserTask.java @@ -18,6 +18,17 @@ public class AppUserTask { private long weekGroup; private DayTask dayTask; + public static String toMessageFormat(AppUserTask oldTask, AppUserTask newTask) { + StringBuilder sb = new StringBuilder(); + sb.append("当前电池数量:").append(String.format("%.2f → %.2f", + (double) oldTask.wallet.gold / 100, + (double) newTask.wallet.gold / 100) + ).append("\n"); + sb.append("当前银瓜子数量:").append(newTask.wallet.silver).append("\n"); + sb.append("每日领取电池:").append(newTask.dayTask.toMessageFormat()).append("\n"); + newTask.weekTask.forEach(task -> sb.append(task.toMessageFormat(newTask.weekTotal)).append("\n")); + return sb.toString(); + } public String toMessageFormat() { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliManga.java b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliManga.java index 95f191c..130116d 100644 --- a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliManga.java +++ b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliManga.java @@ -13,8 +13,8 @@ import java.util.Timer; import java.util.TimerTask; public class BiliBiliManga { - public BiliBiliManga() { - biliUtils = BiliBiliUtils.getInstance(QQBotManager.defQQ); + public BiliBiliManga(long qq) { + biliUtils = BiliBiliUtils.getInstance(qq); } public static JSONObject sign() { 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 2a8c200..4c18894 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java @@ -39,7 +39,7 @@ public class BiliBiliLive extends Model { public synchronized void onTime(Long qq, String time) { super.onTime(qq, time); if ("00:01:00".equals(time)) { - if(!new BiliLogin(qq).testLogin()){ + if (!new BiliLogin(qq).testLogin()) { new BiliLogin(QQBotManager.defQQ).loginAsQQ(); return; } @@ -48,7 +48,7 @@ public class BiliBiliLive extends Model { } private void signLive(long qq, long sendQQ) { - if(!new BiliLogin(qq).testLogin()){ + if (!new BiliLogin(qq).testLogin()) { new BiliLogin(qq).loginAsQQ(); return; } @@ -66,9 +66,11 @@ public class BiliBiliLive extends Model { builder.append("BiliLiveSign").append(id).append(":").append(sign).append("\n"); } QQBotManager.getInstance().sendMessage(sendQQ, builder.toString()); - AppUserTask task = new BiliBiliAppUtils(QQBotManager.defQQ).startAppTask(); + BiliBiliAppUtils appUtils = new BiliBiliAppUtils(QQBotManager.defQQ); + AppUserTask oldTask = appUtils.startAppTask(); + AppUserTask newTask = appUtils.getTaskProgress(); builder = new StringBuilder(); - builder.append("执行APP任务").append("\n").append(task.toMessageFormat()); + builder.append("执行APP任务").append("\n").append(AppUserTask.toMessageFormat(oldTask, newTask)); QQBotManager.getInstance().sendMessage(sendQQ, builder.toString()); } @@ -99,7 +101,7 @@ public class BiliBiliLive extends Model { msg = "0"; } Integer roomId = Integer.parseInt(msg); - if(!new BiliLogin(qq).testLogin()){ + if (!new BiliLogin(qq).testLogin()) { new BiliLogin(qq).loginAsQQ(); return; } diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java b/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java index bfde21e..a71b94c 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java @@ -10,6 +10,7 @@ import com.yutou.qqbot.utlis.QRCodeUtils; import net.mamoe.mirai.event.events.MessageEvent; import java.io.File; + @UseModel public class BiliBiliMangeSign extends Model { @Override @@ -34,6 +35,7 @@ public class BiliBiliMangeSign extends Model { @Override public void onMessage(Long qq, MessageEvent event, boolean isGroup) { super.onMessage(qq, event, isGroup); + BiliBiliManga manga = new BiliBiliManga(user); if (msg.equals(QQFromCommands.BILI_MANGA_SIGN)) { String msg; if (new BiliLogin(user).testLogin()) { @@ -70,8 +72,8 @@ public class BiliBiliMangeSign extends Model { } QQBotManager.getInstance().sendMessage(qq, builder.toString()); } else if (msg.equals(QQFromCommands.BILI_MANGA_PAY_STOP)) { - new BiliBiliManga().stopPayMission(); - QQBotManager.getInstance().sendMessage(qq, "当前任务已取消:"+BiliBiliManga.getMission()); + manga.stopPayMission(); + QQBotManager.getInstance().sendMessage(qq, "当前任务已取消:" + BiliBiliManga.getMission()); } else if (msg.startsWith(QQFromCommands.BILI_MANGA_PAY)) { msg = msg.replace(QQFromCommands.BILI_MANGA_PAY, ""); String[] message = msg.split(" "); @@ -97,7 +99,7 @@ public class BiliBiliMangeSign extends Model { QQBotManager.getInstance().sendMessage(qq, "商城id错误"); return; } - BiliBiliManga manga = new BiliBiliManga(); + manga.addInterface(new ObjectInterface() { @Override public void out(String data) { @@ -113,8 +115,8 @@ public class BiliBiliMangeSign extends Model { } @Override - public void onTime(Long qq,String time) { - super.onTime(qq,time); + public void onTime(Long qq, String time) { + super.onTime(qq, time); if ("00:01:00".equals(time)) { if (new BiliLogin(QQBotManager.defQQ).testLogin()) { String msg;