From 60bf104e9461a53d4feb518d7dc861bebf2e339f Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Wed, 9 Feb 2022 12:40:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=20Morny=20=E5=9C=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=A8=E6=97=B6=E4=BC=9A=E5=85=88=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=B8=80=E9=81=8D=E5=91=BD=E4=BB=A4=E8=A1=A8=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../cc/sukazyo/cono/morny/GradleProjectConfigures.java | 4 ++-- src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java | 3 +-- .../cc/sukazyo/cono/morny/bot/command/MornyCommands.java | 7 +++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1f62c17..0aad69a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.5.1.0 +VERSION = 0.5.1.1 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index c052959..fd967ea 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.1.0"; - public static final long COMPILE_TIMESTAMP = 1644381263800L; + public static final String VERSION = "0.5.1.1"; + public static final long COMPILE_TIMESTAMP = 1644381533694L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 2a7d03c..07ff390 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -162,8 +162,7 @@ public class MornyCoeur { TrackerDataManager.DAEMON.interrupt(); TrackerDataManager.trackingLock.lock(); if (isRemoveCommandListWhenExit) { - extra().exec(new DeleteMyCommands()); - logger.info("cleaned up command list."); + commandManager.automaticRemoveList(); } } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java index d8979eb..fa4c7f8 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java @@ -8,6 +8,7 @@ import cc.sukazyo.cono.morny.data.TelegramStickers; import cc.sukazyo.untitled.telegram.api.formatting.TGToString; import cc.sukazyo.untitled.util.telegram.object.InputCommand; import com.pengrad.telegrambot.model.BotCommand; +import com.pengrad.telegrambot.model.DeleteMyCommands; import com.pengrad.telegrambot.model.Update; import com.pengrad.telegrambot.model.request.ParseMode; import com.pengrad.telegrambot.request.SendMessage; @@ -90,12 +91,18 @@ public class MornyCommands { public void automaticUpdateList () { BotCommand[] commandList = getCommandListTelegram(); + automaticRemoveList(); MornyCoeur.extra().exec(new SetMyCommands( commandList )); logger.info("automatic updated telegram command list :\n" + commandListToString(commandList)); } + public void automaticRemoveList () { + MornyCoeur.extra().exec(new DeleteMyCommands()); + logger.info("cleaned up command list."); + } + private String commandListToString (@Nonnull BotCommand[] list) { StringBuilder builder = new StringBuilder(); for (BotCommand signal : list) {