修复B站签到未登录时的状态
This commit is contained in:
parent
938d3d532a
commit
3bc4c164e0
@ -3,8 +3,10 @@ package com.yutou.qqbot.bilibili;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.utlis.ConfigTools;
|
||||
import com.yutou.qqbot.utlis.HttpTools;
|
||||
import com.yutou.qqbot.utlis.QRCodeUtils;
|
||||
import com.yutou.qqbot.utlis.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -21,7 +23,7 @@ public class BiliLogin {
|
||||
|
||||
public BiliLogin(Long qq) {
|
||||
biliUtils = BiliBiliUtils.getInstance(qq);
|
||||
this.qq=qq;
|
||||
this.qq = qq;
|
||||
}
|
||||
|
||||
public JSONObject login() {
|
||||
@ -33,6 +35,12 @@ public class BiliLogin {
|
||||
return json;
|
||||
}
|
||||
|
||||
public void loginAsQQ() {
|
||||
String url = login().getString("url");
|
||||
File code = QRCodeUtils.createQRCode("bili_login", url);
|
||||
QQBotManager.getInstance().sendMessage(code, qq, "B站未登录,请扫码登陆后再试");
|
||||
}
|
||||
|
||||
public void waitLogin(String oauthKey) {
|
||||
long time = System.currentTimeMillis();
|
||||
String bd = "gourl=https%3A%2F%2Fpassport.bilibili.com%2Fajax%2FminiLogin%2Fredirect&oauthKey=" + oauthKey;
|
||||
@ -88,10 +96,10 @@ public class BiliLogin {
|
||||
}
|
||||
|
||||
public static String getCookieToken(Long qq) {
|
||||
if (StringUtils.isEmpty(ConfigTools.readFile(new File(qq+"_bilibili.cookie")))) {
|
||||
if (StringUtils.isEmpty(ConfigTools.readFile(new File(qq + "_bilibili.cookie")))) {
|
||||
return null;
|
||||
}
|
||||
JSONObject json = JSON.parseObject(ConfigTools.readFile(new File(qq+"_bilibili.cookie")));
|
||||
JSONObject json = JSON.parseObject(ConfigTools.readFile(new File(qq + "_bilibili.cookie")));
|
||||
return json.getString("bili_jct");
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,7 @@ public class BiliBiliLive extends Model {
|
||||
super.onTime(qq, time);
|
||||
if ("00:01:00".equals(time)) {
|
||||
if(!new BiliLogin(qq).testLogin()){
|
||||
String url = new BiliLogin(QQBotManager.defQQ).login().getString("url");
|
||||
File code = QRCodeUtils.createQRCode("bili_login", url);
|
||||
QQBotManager.getInstance().sendMessage(code, qq, "B站未登录,请扫码登陆后再试");
|
||||
new BiliLogin(QQBotManager.defQQ).loginAsQQ();
|
||||
return;
|
||||
}
|
||||
signLive(QQBotManager.defQQ, qq);
|
||||
@ -50,6 +48,10 @@ public class BiliBiliLive extends Model {
|
||||
}
|
||||
|
||||
private void signLive(long qq, long sendQQ) {
|
||||
if(!new BiliLogin(qq).testLogin()){
|
||||
new BiliLogin(qq).loginAsQQ();
|
||||
return;
|
||||
}
|
||||
BiliBiliUtils biliUtils = BiliBiliUtils.getInstance(qq);
|
||||
QQBotManager.getInstance().sendMessage(sendQQ, biliUtils.liveSignIn());
|
||||
Set<String> biliLive = RedisTools.list_get("bili_live");
|
||||
@ -98,9 +100,7 @@ public class BiliBiliLive extends Model {
|
||||
}
|
||||
Integer roomId = Integer.parseInt(msg);
|
||||
if(!new BiliLogin(qq).testLogin()){
|
||||
String url = new BiliLogin(user).login().getString("url");
|
||||
File code = QRCodeUtils.createQRCode("bili_login", url);
|
||||
QQBotManager.getInstance().sendMessage(code, qq, "B站未登录,请扫码登陆后再试");
|
||||
new BiliLogin(qq).loginAsQQ();
|
||||
return;
|
||||
}
|
||||
if (biliUtils.checkLiveRoom(roomId) && roomId != 0) {
|
||||
|
@ -44,9 +44,7 @@ public class BiliBiliMangeSign extends Model {
|
||||
}
|
||||
QQBotManager.getInstance().sendMessage(qq, msg);
|
||||
} else {
|
||||
String url = new BiliLogin(user).login().getString("url");
|
||||
File code = QRCodeUtils.createQRCode("bili_login", url);
|
||||
QQBotManager.getInstance().sendMessage(code, qq, "B站未登录,请扫码登陆后再试");
|
||||
new BiliLogin(user).loginAsQQ();
|
||||
}
|
||||
} else if (msg.equals(QQFromCommands.BILI_MANGA_PAY)) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user