Commit 71a1a409 authored by Him188's avatar Him188

Rename tryLogin to login

parent db77227d
......@@ -145,8 +145,8 @@ object MiraiServer {
getLogger().info("Initializing [Bot] " + section.getString("account"));
try {
Bot bot = new Bot(section);
var state = bot.network.tryLogin$mirai_core().of();
//bot.network.tryLogin$mirai_core().whenComplete((state, e) -> {
var state = bot.network.login$mirai_core().of();
//bot.network.login$mirai_core().whenComplete((state, e) -> {
if (state == LoginState.SUCCESS) {
Bot.instances.add(bot);
getLogger().green(" Login Succeed");
......@@ -175,7 +175,7 @@ object MiraiServer {
val strings = it.split("----").dropLastWhile { it.isEmpty() }.toTypedArray()
val bot = Bot(BotAccount(strings[0].toLong(), strings[1]), Console())
if (runBlocking { bot.network.tryLogin(200) } === LoginState.SUCCESS) {
if (runBlocking { bot.network.login(200) } === LoginState.SUCCESS) {
bot.green("Login succeed")
return bot
}
......
......@@ -27,7 +27,7 @@ val Bot.qqs: ContactList<QQ> get() = this.contacts.qqs
//NetworkHandler
suspend fun Bot.sendPacket(packet: ClientPacket) = this.network.socket.sendPacket(packet)
suspend fun Bot.login(touchingTimeoutMillis: Long = 200): LoginState = this.network.tryLogin()
suspend fun Bot.login(touchingTimeoutMillis: Long = 200): LoginState = this.network.login()
//BotAccount
......
......@@ -58,7 +58,7 @@ interface BotNetworkHandler {
*
* @param touchingTimeoutMillis 连接每个服务器的 timeout
*/
suspend fun tryLogin(touchingTimeoutMillis: Long = 200): LoginState
suspend fun login(touchingTimeoutMillis: Long = 200): LoginState
/**
* 添加一个临时包处理器
......
......@@ -48,7 +48,7 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
temporaryPacketHandlers.add(temporaryPacketHandler)
}
override suspend fun tryLogin(touchingTimeoutMillis: Long): LoginState {
override suspend fun login(touchingTimeoutMillis: Long): LoginState {
return loginInternal(touchingTimeoutMillis, LinkedList(TIMProtocol.SERVER_IP))
}
......
......@@ -13,6 +13,8 @@ import net.mamoe.mirai.message.defaults.PlainText
import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState
import net.mamoe.mirai.utils.BotAccount
import net.mamoe.mirai.utils.Console
import net.mamoe.mirai.utils.MiraiLogger
import kotlin.system.exitProcess
/**
* @author Him188moe
......@@ -24,7 +26,10 @@ suspend fun main() {
), Console())
bot.login().let {
check(it == LoginState.SUCCESS) { "Login failed: " + it.name }
if(it != LoginState.SUCCESS) {
MiraiLogger.error("Login failed: " + it.name)
exitProcess(0)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment