From 360a9d350449aaa7b14f7624f85b052b82c5bade Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Tue, 7 Dec 2021 18:10:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E4=B8=8E?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 5 +++- .../cono/morny/GradleProjectConfigures.java | 3 ++- .../cc/sukazyo/cono/morny/MornyCoeur.java | 22 +++++++++++++--- .../morny/bot/event/OnCommandExecute.java | 26 ++++++++++++++----- 4 files changed, 45 insertions(+), 11 deletions(-) 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)); }