diff --git a/build.gradle b/build.gradle index f20c6e7..9877449 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group 'cc.sukazyo' -version '0.3.4.2' +version '0.3.4.3' project.ext.archiveBaseName = 'Coeur_Morny_Cono' project.ext.artifactId = 'morny-coeur' mainClassName = 'cc.sukazyo.cono.morny.MornyCoeur' @@ -31,6 +31,9 @@ task updateVersionCode { ant.replaceregexp(match:'VERSION = ["a-zA-Z0-9.\\-_+@]+;', replace:"VERSION = \"$project.version\";", flags:'g', byline:true) { fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java') } + ant.replaceregexp(match:'COMPILE_TIMESTAMP = [0-9]+L;', replace:"COMPILE_TIMESTAMP = ${System.currentTimeMillis()}L;", flags:'g', byline:true) { + fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java') + } } compileJava.dependsOn updateVersionCode diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 4ab2324..85f85a5 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,5 +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.3.4.2"; + public static final String VERSION = "0.3.4.3"; + public static final long COMPILE_TIMESTAMP = 1638871718439L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 72943f6..ff5ed18 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -8,6 +8,12 @@ import com.pengrad.telegrambot.request.GetMe; import javax.annotation.Nonnull; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; + import static cc.sukazyo.cono.morny.Logger.logger; /** @@ -45,9 +51,19 @@ public class MornyCoeur { if ("--version".equals(args[0])) { logger.info(String.format(""" Morny Cono Version - - version : %s - - md5hash : %s - """, MornySystem.VERSION, MornySystem.getJarMd5() + - version : + %s + - md5hash : + %s + - co.time : + %d + %s [UTC]""", + MornySystem.VERSION, + MornySystem.getJarMd5(), + GradleProjectConfigures.COMPILE_TIMESTAMP, + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS").format(LocalDateTime.ofInstant( + Instant.ofEpochMilli(GradleProjectConfigures.COMPILE_TIMESTAMP), + ZoneId.ofOffset("UTC", ZoneOffset.UTC))) )); return; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java index cc7ee14..a80293c 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java @@ -1,5 +1,6 @@ package cc.sukazyo.cono.morny.bot.event; +import cc.sukazyo.cono.morny.GradleProjectConfigures; import cc.sukazyo.cono.morny.MornyCoeur; import cc.sukazyo.cono.morny.MornySystem; import cc.sukazyo.cono.morny.MornyTrusted; @@ -13,6 +14,12 @@ import com.pengrad.telegrambot.request.SendSticker; import javax.annotation.Nonnull; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; + import static cc.sukazyo.cono.morny.Logger.logger; public class OnCommandExecute extends EventListener { @@ -96,13 +103,20 @@ public class OnCommandExecute extends EventListener { private void onCommandVersionExec (@Nonnull Update event) { MornyCoeur.getAccount().execute(new SendMessage( event.message().chat().id(), - String.format( - "version:\n" + - "\t%s\n" + - "core md5_hash:\n" + - "\t%s", + String.format(""" + version: + %s + core md5_hash: + %s + compile timestamp: + %d + %s [UTC]""", MornySystem.VERSION, - MornySystem.getJarMd5() + MornySystem.getJarMd5(), + GradleProjectConfigures.COMPILE_TIMESTAMP, + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS").format(LocalDateTime.ofInstant( + Instant.ofEpochMilli(GradleProjectConfigures.COMPILE_TIMESTAMP), + ZoneId.ofOffset("UTC", ZoneOffset.UTC))) ) ).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML)); }