使 Morny 在更新命令表时会先执行一遍命令表删除

This commit is contained in:
A.C.Sukazyo Eyre 2022-02-09 12:40:46 +08:00
parent e3c026d16a
commit 60bf104e94
Signed by: Eyre_S
GPG Key ID: EFB47D98FE082FAD
4 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,6 @@
## Core
VERSION = 0.5.1.0
VERSION = 0.5.1.1
# dependencies

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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) {