dev_该合并了 #8
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
68
src/main/java/com/yutou/qqbot/utlis/FixProtocolVersion.java
Normal file
68
src/main/java/com/yutou/qqbot/utlis/FixProtocolVersion.java
Normal file
@ -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<BotConfiguration.MiraiProtocol, Object> protocols = (EnumMap<BotConfiguration.MiraiProtocol, Object>)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<String, Object> padData = new HashMap<String, Object>(){{
|
||||
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<String, Object> phoneData = new HashMap<String, Object>(){{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user