更新QQ机器人版本

新增扫码登录
This commit is contained in:
yutou 2023-06-25 10:26:13 +08:00
parent 3d3046f1d7
commit 4aa0a53cc5
3 changed files with 9 additions and 4 deletions

View File

@ -35,7 +35,7 @@
<dependency> <dependency>
<groupId>net.mamoe</groupId> <groupId>net.mamoe</groupId>
<artifactId>mirai-core-jvm</artifactId> <artifactId>mirai-core-jvm</artifactId>
<version>2.14.0</version> <version>2.15.0-RC</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jetbrains.kotlinx</groupId> <groupId>org.jetbrains.kotlinx</groupId>

View File

@ -6,6 +6,7 @@ import com.yutou.qqbot.Listeners.QQMessageListener;
import com.yutou.qqbot.utlis.*; import com.yutou.qqbot.utlis.*;
import net.mamoe.mirai.Bot; import net.mamoe.mirai.Bot;
import net.mamoe.mirai.BotFactory; import net.mamoe.mirai.BotFactory;
import net.mamoe.mirai.auth.BotAuthorization;
import net.mamoe.mirai.event.GlobalEventChannel; import net.mamoe.mirai.event.GlobalEventChannel;
import net.mamoe.mirai.message.MessageReceipt; import net.mamoe.mirai.message.MessageReceipt;
import net.mamoe.mirai.message.data.*; import net.mamoe.mirai.message.data.*;
@ -47,9 +48,11 @@ public class QQBotManager {
System.out.println("qq = " + qq); System.out.println("qq = " + qq);
System.out.println("password = " + password); System.out.println("password = " + password);
FixProtocolVersion.fix(); FixProtocolVersion.fix();
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
bot = BotFactory.INSTANCE.newBot(qq, BotAuthorization.byQRCode(),new BotConfiguration() {
{ {
setProtocol(MiraiProtocol.ANDROID_PAD);
setProtocol(MiraiProtocol.ANDROID_WATCH);
fileBasedDeviceInfo("qq_bot_devices_info.json"); fileBasedDeviceInfo("qq_bot_devices_info.json");
if ("nas".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) { if ("nas".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
noBotLog(); noBotLog();
@ -148,8 +151,10 @@ public class QQBotManager {
public MessageReceipt<?> sendMessage(Long group, MessageChainBuilder builder) { public MessageReceipt<?> sendMessage(Long group, MessageChainBuilder builder) {
if (bot != null) { if (bot != null) {
if (QQNumberManager.getManager().isGroup(group)) { 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 { } else {
System.out.println("发个人");
return Objects.requireNonNull(bot.getFriend(group)).sendMessage(builder.asMessageChain()); return Objects.requireNonNull(bot.getFriend(group)).sendMessage(builder.asMessageChain());
} }
} }

View File

@ -271,7 +271,7 @@ public class TurnipProphet extends Model {
out.append("网页版:").append("\n").append(url).append("\n"); out.append("网页版:").append("\n").append(url).append("\n");
out.append("祝好运 :)"); out.append("祝好运 :)");
Log.i("TurnipProphet", out.toString()); Log.i("TurnipProphet", out.toString()+"\n 发送QQ"+sendQQ);
QQBotManager.getInstance().sendMessage(sendQQ, getMessage(out.toString())); QQBotManager.getInstance().sendMessage(sendQQ, getMessage(out.toString()));
return prArray.getJSONObject(0).getString(TurnipData.MODEL); return prArray.getJSONObject(0).getString(TurnipData.MODEL);
} }