mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-23 03:27:39 +08:00
支持了从环境变量设置 token #34
This commit is contained in:
parent
16d74a3af5
commit
35fa1ed5c4
@ -1,6 +1,6 @@
|
|||||||
## Core
|
## Core
|
||||||
|
|
||||||
VERSION = 0.7.0.5
|
VERSION = 0.7.0.6
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny;
|
|||||||
* the final field that will be updated by gradle automatically.
|
* the final field that will be updated by gradle automatically.
|
||||||
*/
|
*/
|
||||||
public class GradleProjectConfigures {
|
public class GradleProjectConfigures {
|
||||||
public static final String VERSION = "0.7.0.5";
|
public static final String VERSION = "0.7.0.6";
|
||||||
public static final long COMPILE_TIMESTAMP = 1652944218716L;
|
public static final long COMPILE_TIMESTAMP = 1652946142762L;
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,8 @@ import static cc.sukazyo.cono.morny.Log.logger;
|
|||||||
*/
|
*/
|
||||||
public class ServerMain {
|
public class ServerMain {
|
||||||
|
|
||||||
private static boolean versionEchoMode = false;
|
public static final String PROP_TOKEN_KEY = "TELEGRAM_BOT_API_TOKEN";
|
||||||
private static boolean welcomeEchoMode = false;
|
public static final String PROP_TOKEN_MORNY_KEY = "MORNY_TG_TOKEN";
|
||||||
|
|
||||||
private static boolean showWelcome = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 程序入口,也是参数处理器<br>
|
* 程序入口,也是参数处理器<br>
|
||||||
@ -71,6 +69,13 @@ public class ServerMain {
|
|||||||
*/
|
*/
|
||||||
public static void main (@Nonnull String[] args) {
|
public static void main (@Nonnull String[] args) {
|
||||||
|
|
||||||
|
//#
|
||||||
|
//# 启动参数设置区块
|
||||||
|
//#
|
||||||
|
|
||||||
|
boolean versionEchoMode = false;
|
||||||
|
boolean welcomeEchoMode = false;
|
||||||
|
boolean showWelcome = true;
|
||||||
String key = null;
|
String key = null;
|
||||||
String username = null;
|
String username = null;
|
||||||
boolean outdatedBlock = false;
|
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) {
|
if (versionEchoMode) {
|
||||||
|
|
||||||
logger.info(String.format("""
|
logger.info(String.format("""
|
||||||
@ -159,6 +177,14 @@ public class ServerMain {
|
|||||||
if (showWelcome) logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII);
|
if (showWelcome) logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII);
|
||||||
if (welcomeEchoMode) return;
|
if (welcomeEchoMode) return;
|
||||||
|
|
||||||
|
//#
|
||||||
|
//# Coeur 参数检查和正式启动主程序
|
||||||
|
//#
|
||||||
|
|
||||||
|
if (propToken != null) {
|
||||||
|
key = propToken;
|
||||||
|
logger.info("Parameter <token> set by EnvVar $"+propTokenKey);
|
||||||
|
}
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
logger.info("Parameter required has no value:\n --token.");
|
logger.info("Parameter required has no value:\n --token.");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user