新增B站大会员积分签到

修复B站操作前没做登陆校验的问题
This commit is contained in:
Yutousama 2023-01-05 15:18:53 +08:00
parent fec901970a
commit 5d15f24847
4 changed files with 24 additions and 8 deletions

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class QQBotApplication {
public static final String version="QQBot v.1.4b";
public static final String version="QQBot v.1.4b.1";
public static void main(String[] args) {
System.out.println("version = " + version);
SpringApplication.run(QQBotApplication.class, args);

View File

@ -43,7 +43,7 @@ public class BiliBiliAppUtils {
}
private Map<String, String> sign(Map<String, String> map) {
map.putAll(getDefaultHeader());
map.putAll(getDefaultBody());
map = sort(map);
StringBuilder builder = new StringBuilder();
for (String key : map.keySet()) {
@ -54,7 +54,7 @@ public class BiliBiliAppUtils {
return map;
}
private Map<String, String> getDefaultHeader() {
private Map<String, String> getDefaultBody() {
Map<String, String> map = new TreeMap<>();
map.put("access_key", getAccessToken());
map.put("actionKey", "appkey");

View File

@ -332,14 +332,14 @@ public class BiliBiliUtils {
return jsonObject;
}
public void main(String[] args) {
public static void main(String[] args) {
/* String url="https://xy218x85x123x8xy.mcdn.bilivideo.cn:4483/upgcxcode/12/12/17281212/17281212-16-80.flv?e=ig8euxZM2rNcNbNBhbdVhwdlhbUghwdVhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1660538573&gen=playurlv2&os=mcdn&oi=2936701972&trid=00006f9623cac1514d8ea18fba3a15a756cau&mid=96300&platform=pc&upsig=25ddd1da610960e8e1d2e80dc97c2361&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&mcdnid=11000101&bvc=vod&nettype=0&orderid=0,2&agrr=1&bw=253116&logo=A0000400&requestFrom=BILIBILI_HELPER_2.5.8";
File file=download(url,"16.mp4",false);
System.out.println("file.getAbsolutePath() = " + file.getAbsolutePath());*/
/* System.out.println(getLiveRoom(42062));
System.out.println("--------------------------------------------");
System.out.println(getUserInfo(730732));*/
String sign = liveSignIn();
String sign = new BiliBiliUtils(583819556).liveSignIn();
System.out.println("sign = " + sign);
}
@ -361,9 +361,10 @@ public class BiliBiliUtils {
JSONObject body = new JSONObject();
body.put("csrf", BiliLogin.getCookieToken(qq));
body.put("csrf_token", BiliLogin.getCookieToken(qq));
JSONObject post = http_post("https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin", HttpTools.toUrlParams(body));
JSONObject post_ = http_get("https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign");
return post.getString("message") + "|" + post_.getString("message");
JSONObject toCoin = http_post("https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin", HttpTools.toUrlParams(body));
JSONObject liveSign = http_get("https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign");
JSONObject vipSign = http_post("https://api.bilibili.com/pgc/activity/score/task/sign", null);
return "银瓜子兑换硬币:"+toCoin.getString("message") + "|" +"直播签到:"+ liveSign.getString("message")+"|大会员中心签到:"+vipSign.getString("message");
}
public JSONObject getLiveRoom(int roomId) {

View File

@ -5,10 +5,13 @@ import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.bilibili.AppUserTask;
import com.yutou.qqbot.bilibili.BiliBiliAppUtils;
import com.yutou.qqbot.bilibili.BiliBiliUtils;
import com.yutou.qqbot.bilibili.BiliLogin;
import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.QRCodeUtils;
import com.yutou.qqbot.utlis.RedisTools;
import net.mamoe.mirai.event.events.MessageEvent;
import java.io.File;
import java.util.Set;
@UseModel
@ -36,6 +39,12 @@ 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()){
String url = new BiliLogin(QQBotManager.defQQ).login().getString("url");
File code = QRCodeUtils.createQRCode("bili_login", url);
QQBotManager.getInstance().sendMessage(code, qq, "B站未登录,请扫码登陆后再试");
return;
}
signLive(QQBotManager.defQQ, qq);
}
}
@ -88,6 +97,12 @@ public class BiliBiliLive extends Model {
msg = "0";
}
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站未登录,请扫码登陆后再试");
return;
}
if (biliUtils.checkLiveRoom(roomId) && roomId != 0) {
if (isDel && RedisTools.list_isExist("bili_live", roomId + "")) {
RedisTools.list_remove("bili_live", roomId + "");