mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
support log level setting; remove git submodule _book; bug fix.
- update dependencies - messiva: 0.1.0.1 -> 0.1.1 - add param -d/--dbg/--debug to enable the Debug/Trace log output. - fix UniversalCommand occurs ArrayOutOfBounds while the quotes not closed.
This commit is contained in:
parent
9c03a59512
commit
e153d9e47f
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "_book"]
|
||||
path = _book
|
||||
url = https://storage.sukazyo.cc/Eyre_S/morny-book.git
|
@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||
|
||||
VERSION = 1.0.0-RC3.5
|
||||
VERSION = 1.0.0-RC3.6
|
||||
|
||||
USE_DELTA = false
|
||||
VERSION_DELTA =
|
||||
@ -16,7 +16,7 @@ CODENAME = beiping
|
||||
|
||||
libSpotbugsVersion = 4.7.3
|
||||
|
||||
libMessivaVersion = 0.1.0.1
|
||||
libMessivaVersion = 0.1.1
|
||||
|
||||
libJavaTelegramBotApiVersion = 6.2.0
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cc.sukazyo.cono.morny;
|
||||
|
||||
import cc.sukazyo.messiva.Logger;
|
||||
import cc.sukazyo.messiva.formatter.SimpleFormatter;
|
||||
import cc.sukazyo.messiva.log.LogLevel;
|
||||
import cc.sukazyo.messiva.logger.Logger;
|
||||
import cc.sukazyo.messiva.appender.ConsoleAppender;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@ -16,7 +18,29 @@ public class Log {
|
||||
* messiva 更新
|
||||
* @since 0.4.1.1
|
||||
*/
|
||||
public static final Logger logger = new Logger(new ConsoleAppender());
|
||||
public static final Logger logger = new Logger(new ConsoleAppender(new SimpleFormatter())).minLevel(LogLevel.INFO);
|
||||
|
||||
/**
|
||||
* Is the Debug mode enabled.
|
||||
*
|
||||
* @return if the minimal log level is equal or lower than DEBUG level.
|
||||
*/
|
||||
public static boolean debug () {
|
||||
return logger.levelSetting.minLevel().level <= LogLevel.DEBUG.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the Debug log output enabled.
|
||||
* <p>
|
||||
* if enable the debug log output, all the Log regardless of LogLevel will be output.
|
||||
* As default, if the debug log output is disabled, Logger will ignore the Logs level lower than INFO.
|
||||
*
|
||||
* @param debug switch enable the debug log output as true, or disable it as false.
|
||||
*/
|
||||
public static void debug (boolean debug) {
|
||||
if (debug) logger.minLevel(LogLevel.ALL);
|
||||
else logger.minLevel(LogLevel.INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常的堆栈信息.
|
||||
|
@ -5,6 +5,8 @@ import cc.sukazyo.cono.morny.util.CommonFormat;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cc.sukazyo.cono.morny.Log.logger;
|
||||
|
||||
@ -93,11 +95,17 @@ public class ServerMain {
|
||||
|
||||
config.eventOutdatedTimestamp = systemStartupTime;
|
||||
|
||||
List<String> unknownArgs = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
|
||||
if (args[i].startsWith("-")) {
|
||||
|
||||
switch (args[i]) {
|
||||
case "-d", "--dbg", "--debug" -> {
|
||||
Log.debug(true);
|
||||
continue;
|
||||
}
|
||||
case "--outdated-block", "-ob" -> {
|
||||
config.eventIgnoreOutdated = true;
|
||||
continue;
|
||||
@ -188,10 +196,17 @@ public class ServerMain {
|
||||
|
||||
}
|
||||
|
||||
logger.warn("Can't understand arg to some meaning :\n " + args[i]);
|
||||
unknownArgs.add(args[i]);
|
||||
|
||||
}
|
||||
|
||||
unknownArgs.forEach(arg -> logger.warn("Can't understand arg to some meaning :\n " + arg));
|
||||
|
||||
if (Log.debug())
|
||||
logger.warn("Debug log output enabled.\n It may lower your performance, make sure that you are not in production environment.");
|
||||
|
||||
logger.debug("Debug log output enabled.");
|
||||
|
||||
String propToken = null;
|
||||
String propTokenKey = null;
|
||||
for (String iKey : MornyConfig.PROP_TOKEN_KEY) {
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cc.sukazyo.cono.morny.Log.logger;
|
||||
import static cc.sukazyo.cono.morny.util.tgapi.formatting.NamedUtils.inlineIds;
|
||||
|
||||
public class ShareToolBilibili implements ITelegramQuery {
|
||||
@ -32,25 +33,25 @@ public class ShareToolBilibili implements ITelegramQuery {
|
||||
final Matcher regex = REGEX_BILI_VIDEO.matcher(event.inlineQuery().query());
|
||||
if (regex.matches()) {
|
||||
|
||||
// logger.debug(String.format(
|
||||
// "====== ok\n1: %s\n2: %s\n3: %s\n4: %s\n5: %s\n6: %s\n7: %s",
|
||||
// regex.group(1), regex.group(2), regex.group(3), regex.group(4),
|
||||
// regex.group(5), regex.group(6), regex.group(7)
|
||||
// ));
|
||||
logger.debug(String.format(
|
||||
"====== Share Tool Bilibili Catch ok\n1: %s\n2: %s\n3: %s\n4: %s\n5: %s\n6: %s\n7: %s",
|
||||
regex.group(1), regex.group(2), regex.group(3), regex.group(4),
|
||||
regex.group(5), regex.group(6), regex.group(7)
|
||||
));
|
||||
|
||||
// get video id from input, also get video part id
|
||||
String av = regex.group(2)==null ? regex.group(6)==null ? null : regex.group(6) : regex.group(2);
|
||||
String bv = regex.group(3)==null ? regex.group(7)==null ? null : regex.group(7) : regex.group(3);
|
||||
// logger.trace(String.format("catch id av[%s] bv[%s]", av, bv));
|
||||
logger.trace(String.format("catch id av[%s] bv[%s]", av, bv));
|
||||
final int part = regex.group(5)==null ? -1 : Integer.parseInt(regex.group(5));
|
||||
// logger.trace(String.format("catch part [%s]", part));
|
||||
logger.trace(String.format("catch part [%s]", part));
|
||||
if (av == null) {
|
||||
assert bv != null;
|
||||
av = String.valueOf(BiliTool.toAv(bv));
|
||||
// logger.trace(String.format("converted bv[%s] to av[%s]", bv, av));
|
||||
logger.trace(String.format("converted bv[%s] to av[%s]", bv, av));
|
||||
} else {
|
||||
bv = BiliTool.toBv(Long.parseLong(av));
|
||||
// logger.trace(String.format("converted av[%s] to bv[%s]", av, bv));
|
||||
logger.trace(String.format("converted av[%s] to bv[%s]", av, bv));
|
||||
}
|
||||
// build standard share links
|
||||
final String linkPartParam = part==-1 ? "" : "?p="+part;
|
||||
@ -58,7 +59,7 @@ public class ShareToolBilibili implements ITelegramQuery {
|
||||
final String linkBv = "https://www.bilibili.com/video/BV"+bv + linkPartParam;
|
||||
final String idAv = "av"+av;
|
||||
final String idBv = "BV"+bv;
|
||||
// logger.trace("built all data.");
|
||||
logger.trace("built all data.");
|
||||
|
||||
// build share message element
|
||||
List<InlineQueryUnit<?>> result = new ArrayList<>();
|
||||
|
@ -19,16 +19,18 @@ public class UniversalCommand {
|
||||
} else if (coma[i] == '"') {
|
||||
while (true) {
|
||||
i++;
|
||||
if (coma[i] == '"') {
|
||||
if (i >= coma.length) {
|
||||
break;
|
||||
} else if (coma[i] == '\\' && (coma[i+1] == '"' || coma[i+1] == '\\')) {
|
||||
} else if (coma[i] == '"') {
|
||||
break;
|
||||
} else if (coma[i] == '\\' && i+1 < coma.length && (coma[i+1] == '"' || coma[i+1] == '\\')) {
|
||||
i++;
|
||||
tmp.append(coma[i]);
|
||||
} else {
|
||||
tmp.append(coma[i]);
|
||||
}
|
||||
}
|
||||
} else if (coma[i] == '\\' && (coma[i+1] == ' ' || coma[i+1] == '"' || coma[i+1] == '\\')) {
|
||||
} else if (coma[i] == '\\' && i+1 < coma.length && (coma[i+1] == ' ' || coma[i+1] == '"' || coma[i+1] == '\\')) {
|
||||
i++;
|
||||
tmp.append(coma[i]);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user