mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
支持了从环境变量设置 token #34
This commit is contained in:
parent
16d74a3af5
commit
35fa1ed5c4
@ -1,6 +1,6 @@
|
||||
## Core
|
||||
|
||||
VERSION = 0.7.0.5
|
||||
VERSION = 0.7.0.6
|
||||
|
||||
# dependencies
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
||||
/**
|
||||
* 程序入口,也是参数处理器<br>
|
||||
@ -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 <token> set by EnvVar $"+propTokenKey);
|
||||
}
|
||||
if (key == null) {
|
||||
logger.info("Parameter required has no value:\n --token.");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user