优化B站直播间每日签到提示文本

This commit is contained in:
Yutousama 2023-01-07 10:22:57 +08:00
parent 3bc4c164e0
commit 943a2c9334
4 changed files with 27 additions and 12 deletions

View File

@ -18,6 +18,17 @@ public class AppUserTask {
private long weekGroup; private long weekGroup;
private DayTask dayTask; 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() { public String toMessageFormat() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@ -13,8 +13,8 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
public class BiliBiliManga { public class BiliBiliManga {
public BiliBiliManga() { public BiliBiliManga(long qq) {
biliUtils = BiliBiliUtils.getInstance(QQBotManager.defQQ); biliUtils = BiliBiliUtils.getInstance(qq);
} }
public static JSONObject sign() { public static JSONObject sign() {

View File

@ -39,7 +39,7 @@ public class BiliBiliLive extends Model {
public synchronized void onTime(Long qq, String time) { public synchronized void onTime(Long qq, String time) {
super.onTime(qq, time); super.onTime(qq, time);
if ("00:01:00".equals(time)) { if ("00:01:00".equals(time)) {
if(!new BiliLogin(qq).testLogin()){ if (!new BiliLogin(qq).testLogin()) {
new BiliLogin(QQBotManager.defQQ).loginAsQQ(); new BiliLogin(QQBotManager.defQQ).loginAsQQ();
return; return;
} }
@ -48,7 +48,7 @@ public class BiliBiliLive extends Model {
} }
private void signLive(long qq, long sendQQ) { private void signLive(long qq, long sendQQ) {
if(!new BiliLogin(qq).testLogin()){ if (!new BiliLogin(qq).testLogin()) {
new BiliLogin(qq).loginAsQQ(); new BiliLogin(qq).loginAsQQ();
return; return;
} }
@ -66,9 +66,11 @@ public class BiliBiliLive extends Model {
builder.append("BiliLiveSign").append(id).append(":").append(sign).append("\n"); builder.append("BiliLiveSign").append(id).append(":").append(sign).append("\n");
} }
QQBotManager.getInstance().sendMessage(sendQQ, builder.toString()); 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 = 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()); QQBotManager.getInstance().sendMessage(sendQQ, builder.toString());
} }
@ -99,7 +101,7 @@ public class BiliBiliLive extends Model {
msg = "0"; msg = "0";
} }
Integer roomId = Integer.parseInt(msg); Integer roomId = Integer.parseInt(msg);
if(!new BiliLogin(qq).testLogin()){ if (!new BiliLogin(qq).testLogin()) {
new BiliLogin(qq).loginAsQQ(); new BiliLogin(qq).loginAsQQ();
return; return;
} }

View File

@ -10,6 +10,7 @@ import com.yutou.qqbot.utlis.QRCodeUtils;
import net.mamoe.mirai.event.events.MessageEvent; import net.mamoe.mirai.event.events.MessageEvent;
import java.io.File; import java.io.File;
@UseModel @UseModel
public class BiliBiliMangeSign extends Model { public class BiliBiliMangeSign extends Model {
@Override @Override
@ -34,6 +35,7 @@ public class BiliBiliMangeSign extends Model {
@Override @Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) { public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, isGroup); super.onMessage(qq, event, isGroup);
BiliBiliManga manga = new BiliBiliManga(user);
if (msg.equals(QQFromCommands.BILI_MANGA_SIGN)) { if (msg.equals(QQFromCommands.BILI_MANGA_SIGN)) {
String msg; String msg;
if (new BiliLogin(user).testLogin()) { if (new BiliLogin(user).testLogin()) {
@ -70,8 +72,8 @@ public class BiliBiliMangeSign extends Model {
} }
QQBotManager.getInstance().sendMessage(qq, builder.toString()); QQBotManager.getInstance().sendMessage(qq, builder.toString());
} else if (msg.equals(QQFromCommands.BILI_MANGA_PAY_STOP)) { } else if (msg.equals(QQFromCommands.BILI_MANGA_PAY_STOP)) {
new BiliBiliManga().stopPayMission(); manga.stopPayMission();
QQBotManager.getInstance().sendMessage(qq, "当前任务已取消:"+BiliBiliManga.getMission()); QQBotManager.getInstance().sendMessage(qq, "当前任务已取消:" + BiliBiliManga.getMission());
} else if (msg.startsWith(QQFromCommands.BILI_MANGA_PAY)) { } else if (msg.startsWith(QQFromCommands.BILI_MANGA_PAY)) {
msg = msg.replace(QQFromCommands.BILI_MANGA_PAY, ""); msg = msg.replace(QQFromCommands.BILI_MANGA_PAY, "");
String[] message = msg.split(" "); String[] message = msg.split(" ");
@ -97,7 +99,7 @@ public class BiliBiliMangeSign extends Model {
QQBotManager.getInstance().sendMessage(qq, "商城id错误"); QQBotManager.getInstance().sendMessage(qq, "商城id错误");
return; return;
} }
BiliBiliManga manga = new BiliBiliManga();
manga.addInterface(new ObjectInterface() { manga.addInterface(new ObjectInterface() {
@Override @Override
public void out(String data) { public void out(String data) {
@ -113,8 +115,8 @@ public class BiliBiliMangeSign extends Model {
} }
@Override @Override
public void onTime(Long qq,String time) { public void onTime(Long qq, String time) {
super.onTime(qq,time); super.onTime(qq, time);
if ("00:01:00".equals(time)) { if ("00:01:00".equals(time)) {
if (new BiliLogin(QQBotManager.defQQ).testLogin()) { if (new BiliLogin(QQBotManager.defQQ).testLogin()) {
String msg; String msg;