Improve event log

This commit is contained in:
Karlatemp 2021-08-26 22:28:33 +08:00
parent 7358d00bcf
commit 66c209381d
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8
2 changed files with 30 additions and 2 deletions

View File

@ -61,12 +61,20 @@ public sealed class ImageUploadEvent : BotEvent, BotActiveEvent, AbstractEvent()
override val target: Contact,
override val source: ExternalResource,
val image: Image
) : ImageUploadEvent()
) : ImageUploadEvent() {
override fun toString(): String {
return "ImageUploadEvent.Succeed(target=$target, source=$source, image=$image)"
}
}
public data class Failed @MiraiInternalApi constructor(
override val target: Contact,
override val source: ExternalResource,
val errno: Int,
val message: String
) : ImageUploadEvent()
) : ImageUploadEvent() {
override fun toString(): String {
return "ImageUploadEvent.Failed(target=$target, source=$source, errno=$errno, message='$message')"
}
}
}

View File

@ -50,6 +50,10 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
public override val cause: Throwable?
) : BotOfflineEvent(), BotActiveEvent, CauseAware {
override val reconnect: Boolean get() = false
override fun toString(): String {
return "BotOfflineEvent.Active(bot=$bot, cause=$cause, reconnect=$reconnect)"
}
}
/**
@ -61,6 +65,10 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
public val message: String,
) : BotOfflineEvent(), Packet, BotPassiveEvent {
override var reconnect: Boolean = bot.configuration.autoReconnectOnForceOffline
override fun toString(): String {
return "BotOfflineEvent.Force(bot=$bot, title='$title', message='$message', reconnect=$reconnect)"
}
}
/**
@ -72,6 +80,10 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
public override val cause: Throwable?
) : BotOfflineEvent(), Packet, BotPassiveEvent, CauseAware {
override var reconnect: Boolean = true
override fun toString(): String {
return "BotOfflineEvent.MsfOffline(bot=$bot, cause=$cause, reconnect=$reconnect)"
}
}
/**
@ -82,6 +94,10 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
public override val cause: Throwable?
) : BotOfflineEvent(), Packet, BotPassiveEvent, CauseAware {
override var reconnect: Boolean = true
override fun toString(): String {
return "BotOfflineEvent.Dropped(bot=$bot, cause=$cause, reconnect=$reconnect)"
}
}
/**
@ -92,6 +108,10 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
public override val bot: Bot, override val cause: Throwable?,
) : BotOfflineEvent(), Packet, BotPassiveEvent, CauseAware {
override var reconnect: Boolean = true
override fun toString(): String {
return "BotOfflineEvent.RequireReconnect(bot=$bot, cause=$cause, reconnect=$reconnect)"
}
}
@MiraiExperimentalApi