From 053b789aff8b2e6a38ca95c602e1053f2db7b2fc Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Thu, 9 May 2024 23:04:46 +0800 Subject: [PATCH] delete deprecated -ob, add WIP --skip-login --- project/MornyConfiguration.scala | 2 +- .../sukazyo/cono/morny/core/MornyCoeur.scala | 2 +- .../sukazyo/cono/morny/core/MornyConfig.java | 10 ++++++ .../sukazyo/cono/morny/core/ServerMain.scala | 31 ++++++++++++++++--- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/project/MornyConfiguration.scala b/project/MornyConfiguration.scala index ec405d1..eb9ac72 100644 --- a/project/MornyConfiguration.scala +++ b/project/MornyConfiguration.scala @@ -8,7 +8,7 @@ object MornyConfiguration { val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono" val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s" - val VERSION = "2.0.0-alpha19" + val VERSION = "2.0.0-alpha20" val VERSION_DELTA: Option[String] = None val CODENAME = "xinzheng" diff --git a/src/main/scala/cc/sukazyo/cono/morny/core/MornyCoeur.scala b/src/main/scala/cc/sukazyo/cono/morny/core/MornyCoeur.scala index fe973c9..20fdd58 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/core/MornyCoeur.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/core/MornyCoeur.scala @@ -416,7 +416,7 @@ class MornyCoeur (modules: List[MornyModule])(using val config: MornyConfig)(tes private case class LoginResult(account: TelegramBot, username: String, userid: Long) - private def login (): Option[LoginResult] = { + private def login (skip_login: Boolean = false): Option[LoginResult] = { val builder = TelegramBot.Builder(config.telegramBotKey) var api_bot = config.telegramBotApiServer diff --git a/src/main/scala/cc/sukazyo/cono/morny/core/MornyConfig.java b/src/main/scala/cc/sukazyo/cono/morny/core/MornyConfig.java index 1e7db07..0a0ec32 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/core/MornyConfig.java +++ b/src/main/scala/cc/sukazyo/cono/morny/core/MornyConfig.java @@ -61,6 +61,14 @@ public class MornyConfig { */ @Nullable public final String telegramBotUsername; + /** + * 是否在启动的时候跳过登录过程。 + *

+ * 这将能够在没有联网的情况下也能够启动 Coeur 程序,但是可能会引发一些初始化过程中不可预知的 + * 错误。 + */ + public final boolean telegramSkipLogin; + /* ======================================= * * morny trusted config * * ======================================= */ @@ -186,6 +194,7 @@ public class MornyConfig { this.httpPort = prototype.httpPort; this.debugMode = prototype.debugMode; this.inlineQueryCacheTimeMax = prototype.inlineQueryCacheTimeMax; + this.telegramSkipLogin = prototype.telegramSkipLogin; } public static class CheckFailure extends RuntimeException { @@ -219,6 +228,7 @@ public class MornyConfig { public int httpPort = 30179; public boolean debugMode = false; public int inlineQueryCacheTimeMax = 300; + public boolean telegramSkipLogin = false; } diff --git a/src/main/scala/cc/sukazyo/cono/morny/core/ServerMain.scala b/src/main/scala/cc/sukazyo/cono/morny/core/ServerMain.scala index 5138d71..3633239 100644 --- a/src/main/scala/cc/sukazyo/cono/morny/core/ServerMain.scala +++ b/src/main/scala/cc/sukazyo/cono/morny/core/ServerMain.scala @@ -47,9 +47,9 @@ object ServerMain { case "--version" | "-v" => mode_echoVersion = true // deprecated: use --outdated-ignore instead - case "--outdated-block" | "-ob" => - config.eventIgnoreOutdated = true - deprecatedArgs += "--outdated-block" -> "--outdated-ignore" +// case "--outdated-block" | "-ob" => +// config.eventIgnoreOutdated = true +// deprecatedArgs += "--outdated-block" -> "--outdated-ignore" case "--outdated-ignore" | "-oig" => config.eventIgnoreOutdated = true case "--api" | "-a" => i += 1; config.telegramBotApiServer = args(i) @@ -86,6 +86,9 @@ object ServerMain { config.commandLoginRefresh = true config.commandLogoutClear = true + case "--skip-login" => + config.telegramSkipLogin = true + case _ => unknownArgs append args(i) } @@ -129,8 +132,8 @@ object ServerMain { | | Since 2.0.0, this mode is the combined of the two following options: | --debug-run enable coeur debug mode, that will disabled all the caches. - | --verbose-logging enable the logger to output debug/trace logs.""" - .stripMargin + | --verbose-logging enable the logger to output debug/trace logs. + |""".stripMargin else if (config.debugMode) logger `warn` """Coeur Debug mode enabled. @@ -146,6 +149,24 @@ object ServerMain { | so make sure that you are not in production environment.""" .stripMargin + if (config.telegramSkipLogin) + logger `notice` + s"""Skip Login feature enabled. + | + | This will skips the login process, means you can succeed start the coeur + | even if the telegram bot key / username / userid is wrong or there's no + | network connection at all. + | + | This may cause the bot runs in an unstable or even unworkable state, breaks + | many features and even occurred bugs. + | + | Make sure you know what you are doing, and be well. + | + |""".stripMargin + logger `warn` + s"""The Skip Login feature is not implemented yet! + |""".stripMargin + if (mode_echoVersion) { logger `info`