From 5d15f24847231a8ba69307d2214e81d35f478429 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 5 Jan 2023 15:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EB=E7=AB=99=E5=A4=A7=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E7=A7=AF=E5=88=86=E7=AD=BE=E5=88=B0=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DB=E7=AB=99=E6=93=8D=E4=BD=9C=E5=89=8D=E6=B2=A1?= =?UTF-8?q?=E5=81=9A=E7=99=BB=E9=99=86=E6=A0=A1=E9=AA=8C=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yutou/qqbot/QQBotApplication.java | 2 +- .../yutou/qqbot/bilibili/BiliBiliAppUtils.java | 4 ++-- .../com/yutou/qqbot/bilibili/BiliBiliUtils.java | 11 ++++++----- .../yutou/qqbot/models/BiliBili/BiliBiliLive.java | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index a2e6f89..f27ab4a 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -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); diff --git a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliAppUtils.java b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliAppUtils.java index 0070530..4bbb6b9 100644 --- a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliAppUtils.java +++ b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliAppUtils.java @@ -43,7 +43,7 @@ public class BiliBiliAppUtils { } private Map sign(Map 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 getDefaultHeader() { + private Map getDefaultBody() { Map map = new TreeMap<>(); map.put("access_key", getAccessToken()); map.put("actionKey", "appkey"); diff --git a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliUtils.java b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliUtils.java index 6b4b23a..81b1ccc 100644 --- a/src/main/java/com/yutou/qqbot/bilibili/BiliBiliUtils.java +++ b/src/main/java/com/yutou/qqbot/bilibili/BiliBiliUtils.java @@ -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) { 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 5bf875d..053c18c 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java @@ -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 + "");