diff --git a/gradle.properties b/gradle.properties index 70ddbdf..85b3955 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,12 +5,12 @@ MORNY_ARCHIVE_NAME = morny-coeur MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s -VERSION = 1.3.0-dev3 +VERSION = 1.3.0-dev4 USE_DELTA = false VERSION_DELTA = -CODENAME = xiongan +CODENAME = guanggu # dependencies diff --git a/src/main/scala/cc/sukazyo/cono/morny/MornyCoeur.scala b/src/main/scala/cc/sukazyo/cono/morny/MornyCoeur.scala index 79a5dc9..f88d9b4 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/MornyCoeur.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/MornyCoeur.scala @@ -96,7 +96,42 @@ class MornyCoeur (using val config: MornyConfig) { daemons.start() logger info "start telegram event listening" - account setUpdatesListener eventManager + import com.pengrad.telegrambot.TelegramException + account.setUpdatesListener(eventManager, (e: TelegramException) => { + + if (e.response != null) { + import com.google.gson.GsonBuilder + logger error + s"""Failed get updates: ${e.getMessage} + | server responses: + |${GsonBuilder().setPrettyPrinting().create.toJson(e.response) indent 4} + |""".stripMargin + } + + if (e.getCause != null) { + import java.net.{SocketException, SocketTimeoutException} + import javax.net.ssl.SSLHandshakeException + val caused = e.getCause + caused match + case e_timeout: (SSLHandshakeException|SocketException|SocketTimeoutException) => + import cc.sukazyo.messiva.log.Message + + import scala.collection.mutable + val log = mutable.ArrayBuffer(s"Failed get updates: Network Error") + var current: Throwable = e_timeout + log += s" due to: ${current.getMessage}" + while (current.getCause != null) { + current = current.getCause + log += s" caused by: ${current.getClass.getSimpleName}: ${current.getMessage}" + } + logger error Message(log mkString "\n") + case e_other => + logger error exceptionLog(e_other) + this.daemons.reporter exception e_other + } + + }) + if config.commandLoginRefresh then logger info "resetting telegram command list" commands.automaticTGListUpdate() diff --git a/src/main/scala/cc/sukazyo/cono/morny/util/schedule/Scheduler.scala b/src/main/scala/cc/sukazyo/cono/morny/util/schedule/Scheduler.scala index 4eb066e..4a07a24 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/util/schedule/Scheduler.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/util/schedule/Scheduler.scala @@ -141,7 +141,7 @@ class Scheduler { */ //noinspection ScalaWeakerAccess def runnerName: String = - this.toString + s"${this.getClass.getSimpleName}@${this.hashCode.toHexString}" /** Add one task to scheduler task queue. * @return this scheduler for chained call. @@ -199,11 +199,11 @@ class Scheduler { runtime.getState /** Manually update the task scheduler. - * + * * If the inner state of the scheduler somehow changed and cannot automatically * update schedule states to schedule the new state, you can call this method * to manually let the task scheduler reschedule it. - * + * * You can also use it with some tick-guard like [[cc.sukazyo.cono.morny.util.time.WatchDog]] * to make the scheduler avoid fails when machine fall asleep or some else conditions. */