Skip to content

Commit

Permalink
fix: AutoLoginEvent.toString
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Jul 25, 2023
1 parent 3a03f60 commit d9755b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1288,16 +1288,17 @@ public final class net/mamoe/mirai/console/data/java/JavaAutoSavePluginData$Comp
}

public abstract class net/mamoe/mirai/console/events/AutoLoginEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/console/events/ConsoleEvent, net/mamoe/mirai/event/events/BotEvent {
public fun toString ()Ljava/lang/String;
}

public final class net/mamoe/mirai/console/events/AutoLoginEvent$Failure : net/mamoe/mirai/console/events/AutoLoginEvent {
public fun getBot ()Lnet/mamoe/mirai/Bot;
public final fun getCause ()Ljava/lang/Throwable;
public fun toString ()Ljava/lang/String;
}

public final class net/mamoe/mirai/console/events/AutoLoginEvent$Success : net/mamoe/mirai/console/events/AutoLoginEvent {
public fun getBot ()Lnet/mamoe/mirai/Bot;
public fun toString ()Ljava/lang/String;
}

public abstract interface class net/mamoe/mirai/console/events/ConsoleEvent : net/mamoe/mirai/event/Event {
Expand Down
15 changes: 8 additions & 7 deletions mirai-console/backend/mirai-console/src/events/AutoLoginEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ public sealed class AutoLoginEvent : BotEvent, ConsoleEvent, AbstractEvent() {
*/
public class Success @MiraiInternalApi constructor(
override val bot: Bot
) : AutoLoginEvent()
) : AutoLoginEvent() {
override fun toString(): String {
return "AutoLoginEvent.Success(bot=${bot.id}, protocol=${bot.configuration.protocol}, heartbeatStrategy=${bot.configuration.heartbeatStrategy})"
}
}

/**
* 登录失败
*/
public class Failure @MiraiInternalApi constructor(
override val bot: Bot,
public val cause: Throwable
) : AutoLoginEvent()

override fun toString(): String {
return when (this) {
is Success -> "AutoLoginEvent.Success(bot=${bot.id}, protocol=${bot.configuration.protocol}, heartbeatStrategy=${bot.configuration.heartbeatStrategy})"
is Failure -> "AutoLoginEvent.Failure(bot=${bot.id}, protocol=${bot.configuration.protocol}, message=${cause.message})"
) : AutoLoginEvent() {
override fun toString(): String {
return "AutoLoginEvent.Failure(bot=${bot.id}, protocol=${bot.configuration.protocol}, message=${cause.message})"
}
}
}

0 comments on commit d9755b3

Please sign in to comment.