From 35fa1ed5c4179f1d6a2fce8624b80a6a2c9c380c Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Thu, 19 May 2022 15:44:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BA=86=E4=BB=8E=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E8=AE=BE=E7=BD=AE=20token=20#34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../cono/morny/GradleProjectConfigures.java | 4 +-- .../cc/sukazyo/cono/morny/ServerMain.java | 34 ++++++++++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 791e9a4..ad8c396 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.7.0.5 +VERSION = 0.7.0.6 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index ad433d0..c4542ff 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.7.0.5"; - public static final long COMPILE_TIMESTAMP = 1652944218716L; + public static final String VERSION = "0.7.0.6"; + public static final long COMPILE_TIMESTAMP = 1652946142762L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java index b7d9d78..b434bc7 100644 --- a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java +++ b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java @@ -15,10 +15,8 @@ import static cc.sukazyo.cono.morny.Log.logger; */ public class ServerMain { - private static boolean versionEchoMode = false; - private static boolean welcomeEchoMode = false; - - private static boolean showWelcome = true; + public static final String PROP_TOKEN_KEY = "TELEGRAM_BOT_API_TOKEN"; + public static final String PROP_TOKEN_MORNY_KEY = "MORNY_TG_TOKEN"; /** * 程序入口,也是参数处理器
@@ -71,6 +69,13 @@ public class ServerMain { */ public static void main (@Nonnull String[] args) { + //# + //# 启动参数设置区块 + //# + + boolean versionEchoMode = false; + boolean welcomeEchoMode = false; + boolean showWelcome = true; String key = null; String username = null; boolean outdatedBlock = false; @@ -136,6 +141,19 @@ public class ServerMain { } + String propToken = null; + String propTokenKey = null; + for (String iKey : new String[]{PROP_TOKEN_KEY, PROP_TOKEN_MORNY_KEY}) { + if (System.getenv(iKey) != null) { + propToken = System.getenv(iKey); + propTokenKey = iKey; + } + } + + //# + //# 启动相关参数的检查和处理 + //# + if (versionEchoMode) { logger.info(String.format(""" @@ -159,6 +177,14 @@ public class ServerMain { if (showWelcome) logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII); if (welcomeEchoMode) return; + //# + //# Coeur 参数检查和正式启动主程序 + //# + + if (propToken != null) { + key = propToken; + logger.info("Parameter set by EnvVar $"+propTokenKey); + } if (key == null) { logger.info("Parameter required has no value:\n --token."); return;