diff --git a/gradle.properties b/gradle.properties index f185b84..c5986dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.5.0.3 +VERSION = 0.5.0.4 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 00ef497..7686e07 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny; * the final field that will be updated by gradle automatically. */ public class GradleProjectConfigures { - public static final String VERSION = "0.5.0.3"; - public static final long COMPILE_TIMESTAMP = 1643617049492L; + public static final String VERSION = "0.5.0.4"; + public static final long COMPILE_TIMESTAMP = 1643885546609L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 321b14c..2a7d03c 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -88,7 +88,7 @@ public class MornyCoeur { } try { - final LogInResult loginResult = login(botKey); + final LogInResult loginResult = login(botKey, botUsername); this.account = loginResult.account; this.username = loginResult.username; this.trusted = new MornyTrusted(master, trustedChat); @@ -158,6 +158,7 @@ public class MornyCoeur { * 用于退出时进行缓存的任务处理等进行安全退出 */ private void exitCleanup () { + logger.info("clean:save tracker data."); TrackerDataManager.DAEMON.interrupt(); TrackerDataManager.trackingLock.lock(); if (isRemoveCommandListWhenExit) { @@ -184,15 +185,15 @@ public class MornyCoeur { * @return 成功登录后的 {@link TelegramBot} 对象 */ @Nonnull - private LogInResult login (@Nonnull String key) { + private static LogInResult login (@Nonnull String key, @Nullable String requireName) { final TelegramBot account = new TelegramBot(key); logger.info("Trying to login..."); for (int i = 1; i < 4; i++) { if (i != 1) logger.info("retrying..."); try { final String username = account.execute(new GetMe()).user().username(); - if (this.username != null && !this.username.equals(username)) - throw new RuntimeException("Required the bot @" + this.username + " but @" + username + " logged in!"); + if (requireName != null && !requireName.equals(username)) + throw new RuntimeException("Required the bot @" + requireName + " but @" + username + " logged in!"); logger.info("Succeed login to @" + username); return new LogInResult(account, username); } catch (Exception e) { diff --git a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java index 09590b9..b7d9d78 100644 --- a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java +++ b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java @@ -130,17 +130,6 @@ public class ServerMain { } } - } else { - - if (key == null) { - key = args[i]; - continue; - } - if (username == null) { - username = args[i]; - continue; - } - } logger.warn("Can't understand arg to some meaning :\n " + args[i]); @@ -170,7 +159,10 @@ public class ServerMain { if (showWelcome) logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII); if (welcomeEchoMode) return; - assert key != null; + if (key == null) { + logger.info("Parameter required has no value:\n --token."); + return; + } MornyCoeur.main( key, username, master, trustedChat, diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java index c53e746..f7d136f 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java @@ -13,8 +13,6 @@ import com.pengrad.telegrambot.response.GetChatMemberResponse; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml; - public class GetUsernameAndId implements ITelegramCommand { @Nonnull @Override public String getName () { return "/user"; } diff --git a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java index 06945ab..7b2372f 100644 --- a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java +++ b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java @@ -43,7 +43,7 @@ public class TrackerDataManager { logger.info("CALLED TO EXIT! writing cache."); } if (record.size() != 0) { - save(reset()); + save(); } else logger.info("nothing to do yet"); } while (!postProcess);