Merge tag '0.1.2@mvn' into release

This commit is contained in:
A.C.Sukazyo Eyre 2021-12-24 18:29:42 +08:00
commit 9f394bef66
Signed by: Eyre_S
GPG Key ID: EFB47D98FE082FAD
5 changed files with 38 additions and 12 deletions

View File

@ -3,7 +3,7 @@ plugins {
} }
group 'cc.sukazyo' group 'cc.sukazyo'
version '0.1.1' version '0.1.2'
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -1,5 +1,7 @@
package cc.sukazyo.cono.morny; package cc.sukazyo.cono.morny;
import cc.sukazyo.cono.morny.util.StringUtils;
public class Logger { public class Logger {
public static final Logger logger = new Logger(); public static final Logger logger = new Logger();
@ -16,15 +18,15 @@ public class Logger {
System.out.println(formatMessage(message, "WARN")); System.out.println(formatMessage(message, "WARN"));
} }
public void error (String message) {
System.out.println(formatMessage(message, "ERRO"));
}
private String formatMessage (String message, String level) { private String formatMessage (String message, String level) {
String levelStr = "\n["+level+"]"; String prompt = String.format("[%s][%s]", System.currentTimeMillis(), Thread.currentThread().getName());
return String.format( String levelStr = String.format("[%s]", level);
"[%d][%s][%s]%s", String newline = "\n" + StringUtils.repeatChar('\'', prompt.length()) + levelStr;
System.currentTimeMillis(), return prompt + levelStr + message.replaceAll("\\n", newline);
Thread.currentThread().getName(),
level,
message.replaceAll("\\n", levelStr)
);
} }
} }

View File

@ -2,6 +2,7 @@ package cc.sukazyo.cono.morny;
import cc.sukazyo.cono.morny.bot.api.OnUpdate; import cc.sukazyo.cono.morny.bot.api.OnUpdate;
import cc.sukazyo.cono.morny.bot.event.EventListeners; import cc.sukazyo.cono.morny.bot.event.EventListeners;
import cc.sukazyo.cono.morny.data.MornyHello;
import com.pengrad.telegrambot.TelegramBot; import com.pengrad.telegrambot.TelegramBot;
import com.pengrad.telegrambot.request.GetMe; import com.pengrad.telegrambot.request.GetMe;
@ -13,11 +14,13 @@ public class MornyCoeur {
public static void main (String[] args) { public static void main (String[] args) {
logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII);
logger.info("System Starting"); logger.info("System Starting");
logger.info("args key: " + args[0]); logger.info("args key:\n " + args[0]);
account = login(args[0]); try { account = login(args[0]); }
catch (Exception e) { logger.error("Cannot login to bot/api."); System.exit(-1); }
logger.info("Bot login succeed."); logger.info("Bot login succeed.");
@ -38,7 +41,7 @@ public class MornyCoeur {
return account; return account;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(System.out); e.printStackTrace(System.out);
logger.info("login failed."); logger.error("login failed.");
} }
} }
throw new RuntimeException("Login failed.."); throw new RuntimeException("Login failed..");

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
package cc.sukazyo.cono.morny.util;
import java.util.Arrays;
public class StringUtils {
public static String repeatChar (char c, int i) {
char[] chars = new char[i];
Arrays.fill(chars, c);
return new String(chars);
}
}