更新QQ机器人
修复机器人协议问题
This commit is contained in:
@@ -12,6 +12,7 @@ import net.mamoe.mirai.message.MessageReceipt;
|
||||
import net.mamoe.mirai.message.data.*;
|
||||
import net.mamoe.mirai.utils.BotConfiguration;
|
||||
import net.mamoe.mirai.utils.ExternalResource;
|
||||
import xyz.cssxsh.mirai.tool.FixProtocolVersion;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -47,12 +48,12 @@ 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();
|
||||
FixProtocolVersion.load(BotConfiguration.MiraiProtocol.ANDROID_PAD);
|
||||
|
||||
bot = BotFactory.INSTANCE.newBot(qq, BotAuthorization.byQRCode(),new BotConfiguration() {
|
||||
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
|
||||
{
|
||||
|
||||
setProtocol(MiraiProtocol.ANDROID_WATCH);
|
||||
setProtocol(MiraiProtocol.ANDROID_PAD);
|
||||
fileBasedDeviceInfo("qq_bot_devices_info.json");
|
||||
if ("nas".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
|
||||
noBotLog();
|
||||
@@ -96,7 +97,7 @@ public class QQBotManager {
|
||||
}
|
||||
|
||||
private Image getImage(File file, Long qq) {
|
||||
if(file==null){
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
if (bot != null) {
|
||||
@@ -152,7 +153,7 @@ public class QQBotManager {
|
||||
if (bot != null) {
|
||||
if (QQNumberManager.getManager().isGroup(group)) {
|
||||
System.out.println("发群");
|
||||
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
||||
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
||||
} else {
|
||||
System.out.println("发个人");
|
||||
return Objects.requireNonNull(bot.getFriend(group)).sendMessage(builder.asMessageChain());
|
||||
@@ -176,7 +177,7 @@ public class QQBotManager {
|
||||
if (image != null) {
|
||||
builder.append(image);
|
||||
}
|
||||
List<String> list=PatternTools.getQQ(text);
|
||||
List<String> list = PatternTools.getQQ(text);
|
||||
if (!list.isEmpty()) {
|
||||
for (String _qq : list) {
|
||||
String[] tmp = text.split(_qq);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class GetSeTu extends Model {
|
||||
url = url.replace("&r18=0", "&r18=2").replace("&r18=1", "&r18=2");
|
||||
}
|
||||
System.out.println("url = " + url);
|
||||
String ret = HttpTools.http_get(url, null, true);
|
||||
String ret = HttpTools.http_get(url, null, false);
|
||||
JSONObject json = JSON.parseObject(ret);
|
||||
if (json.getJSONArray("data").size() == 0) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user