From 4ca18848313645d0bb7c166fe9f1ce0fbc3f9f21 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 29 Sep 2019 23:26:19 +0800 Subject: [PATCH] Update pom.xml --- .../main/java/net/mamoe/mirai/MiraiAPI.java | 5 -- mirai-core/pom.xml | 33 ------------- .../src/main/java/net/mamoe/mirai/Bot.java | 4 -- .../mirai/network/BotNetworkHandlerImpl.kt | 1 + .../java/net/mamoe/mirai/network/Protocol.kt | 2 +- mirai-core/src/test/java/BadQQFilter.kt | 46 +++++++++++-------- 6 files changed, 30 insertions(+), 61 deletions(-) diff --git a/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java index b074181b7..add6345c5 100644 --- a/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java +++ b/mirai-api/src/main/java/net/mamoe/mirai/MiraiAPI.java @@ -1,6 +1,5 @@ package net.mamoe.mirai; -import java.io.PrintStream; import java.util.ArrayList; import java.util.List; @@ -33,10 +32,6 @@ public class MiraiAPI { MiraiMain.main(args); } - public static void setLogger(PrintStream stream){ - MiraiServer.getInstance().getLogger().setOutPutStream(stream); - } - public static String getMiraiVersion(){ return MiraiServer.MIRAI_VERSION; } diff --git a/mirai-core/pom.xml b/mirai-core/pom.xml index 1d8de0d46..6b210cf6e 100644 --- a/mirai-core/pom.xml +++ b/mirai-core/pom.xml @@ -26,19 +26,6 @@ ${project.basedir}/lib/jpcap.jar - - org.pcap4j - pcap4j-core - 1.8.2 - compile - - - org.pcap4j - pcap4j-packetfactory-static - 1.8.2 - compile - - com.google.protobuf protobuf-java @@ -92,13 +79,6 @@ compile - - commons-httpclient - commons-httpclient - 3.1 - compile - - @@ -113,19 +93,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - - true - net.mamoe.mirai.MiraiMain - - - - - org.apache.maven.plugins maven-shade-plugin diff --git a/mirai-core/src/main/java/net/mamoe/mirai/Bot.java b/mirai-core/src/main/java/net/mamoe/mirai/Bot.java index 44b6b7c93..93b77a74e 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/Bot.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/Bot.java @@ -116,10 +116,6 @@ public final class Bot implements Closeable { this.contacts.qqs.clear(); } - public void addFriend(long qq) { - - } - /* PRIVATE */ private static final AtomicInteger _id = new AtomicInteger(0); diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt index d719ab212..68e226dc6 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/BotNetworkHandlerImpl.kt @@ -287,6 +287,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler { is ServerLoginResponseFailedPacket -> { socket.loginFuture?.complete(packet.loginState) + bot.close() return } diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt index 52dfe61cd..9e6b32e1b 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/Protocol.kt @@ -18,7 +18,7 @@ object Protocol { //add("183.60.56.29") arrayOf( - //"sz3.tencent.com", + "sz3.tencent.com", "sz4.tencent.com", "sz5.tencent.com", "sz6.tencent.com", diff --git a/mirai-core/src/test/java/BadQQFilter.kt b/mirai-core/src/test/java/BadQQFilter.kt index a6697ee51..ba6b3c08f 100644 --- a/mirai-core/src/test/java/BadQQFilter.kt +++ b/mirai-core/src/test/java/BadQQFilter.kt @@ -1,10 +1,12 @@ -import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import net.mamoe.mirai.Bot import net.mamoe.mirai.network.packet.login.LoginState import net.mamoe.mirai.utils.BotAccount import net.mamoe.mirai.utils.Console import java.util.* +import java.util.concurrent.TimeUnit /** * 筛选掉无法登录(冻结/设备锁/UNKNOWN)的 qq @@ -64,28 +66,36 @@ val qqList = "2535777366----abc123456\n" + "2534037598----abc123456\n" -fun main() { +suspend fun main() { val goodBotList = Collections.synchronizedList(mutableListOf()) - qqList.split("\n").forEach { - GlobalScope.launch { - val strings = it.split("----") - val bot = Bot(BotAccount(strings[0].toLong(), strings[1].let { password -> - if (password.endsWith(".")) { - return@let password.substring(0, password.length - 1) - } - return@let password - }), Console()) + withContext(Dispatchers.Default) { + qqList.split("\n") + .filterNot { it.isEmpty() } + .map { it.split("----") } + .map { Pair(it[0].toLong(), it[1]) } + .forEach { (qq, password) -> + launch { + val bot = Bot( + BotAccount( + qq, + if (password.endsWith(".")) password.substring(0, password.length - 1) else password + ), + Console() + ) - bot.network.tryLogin().whenComplete { state, _ -> - if (!(state == LoginState.BLOCKED || state == LoginState.DEVICE_LOCK || state == LoginState.WRONG_PASSWORD)) { - goodBotList.add(bot) + withContext(Dispatchers.IO) { + bot.network.tryLogin().get(3, TimeUnit.MILLISECONDS) + }.let { state -> + if (!(state == LoginState.BLOCKED || state == LoginState.DEVICE_LOCK || state == LoginState.WRONG_PASSWORD)) { + goodBotList.add(bot) + } else { + + } + } + } } - } - } } - Thread.sleep(9 * 3000) - println(goodBotList.joinToString("\n") { it.account.qqNumber.toString() + " " + it.account.password }) }