diff --git a/mvnw b/mvnw old mode 100644 new mode 100755 diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index b70931b..11e7bbb 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -6,7 +6,6 @@ import com.yutou.qqbot.Listeners.QQMessageListener; import com.yutou.qqbot.utlis.*; import net.mamoe.mirai.Bot; import net.mamoe.mirai.BotFactory; -import net.mamoe.mirai.contact.Group; import net.mamoe.mirai.event.GlobalEventChannel; import net.mamoe.mirai.message.MessageReceipt; import net.mamoe.mirai.message.data.*; @@ -47,6 +46,7 @@ public class QQBotManager { String password = ConfigTools.load(ConfigTools.CONFIG, "qq_password", String.class); System.out.println("qq = " + qq); System.out.println("password = " + password); + FixProtocolVersion.fix(); bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() { { setProtocol(MiraiProtocol.ANDROID_PAD); 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 4c18894..870db6d 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliBiliLive.java @@ -135,4 +135,8 @@ public class BiliBiliLive extends Model { QQBotManager.getInstance().sendMessage(qq, message.toString()); } + + public static void main(String[] args) { + new BiliBiliLive().signLive(QQBotManager.defQQ, 0); + } } diff --git a/src/main/java/com/yutou/qqbot/utlis/FixProtocolVersion.java b/src/main/java/com/yutou/qqbot/utlis/FixProtocolVersion.java new file mode 100644 index 0000000..d32b853 --- /dev/null +++ b/src/main/java/com/yutou/qqbot/utlis/FixProtocolVersion.java @@ -0,0 +1,68 @@ +package com.yutou.qqbot.utlis; + +import net.mamoe.mirai.utils.BotConfiguration; + +import java.lang.reflect.Field; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.Map; + +public class FixProtocolVersion { + public static void fix(){ + try { + + Class MiraiProtocolInternal = Class.forName("net.mamoe.mirai.internal.utils.MiraiProtocolInternal"); + Field field = MiraiProtocolInternal.getFields()[0]; + Object companion = field.get(Object.class); + + EnumMap protocols = (EnumMap)companion.getClass().getMethod("getProtocols$mirai_core").invoke(companion); + Object pad = protocols.get(BotConfiguration.MiraiProtocol.ANDROID_PAD); + /* + * apkId: String, + id: Long, + ver: String, + sdkVer: String, + miscBitMap: Int, + subSigMap: Int, + mainSigMap: Int, + sign: String, + buildTime: Long, + ssoVersion: Int, + canDoQRCodeLogin: Boolean = false, + * */ + Class padClass = pad.getClass(); + Map padData = new HashMap(){{ + put("id", 537151218); + put("ver", "8.9.33.10335"); + put("sdkVer", "6.0.0.2534"); + put("buildTime", 1673599898L); + }}; + for (Field f : padClass.getFields()) { + f.setAccessible(true); + if(padData.containsKey(f.getName())){ + f.set(pad, padData.get(f.getName())); + } + f.setAccessible(false); + } + + Object phone = protocols.get(BotConfiguration.MiraiProtocol.ANDROID_PHONE); + Map phoneData = new HashMap(){{ + put("id", 537151682); + put("ver", "8.9.33.10335"); + put("sdkVer", "6.0.0.2534"); + put("buildTime", 1673599898L); + }}; + for (Field f : padClass.getFields()) { + f.setAccessible(true); + if(padData.containsKey(f.getName())){ + f.set(phone, phoneData.get(f.getName())); + } + f.setAccessible(false); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} +