mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
Merge tag '0.1.2@mvn' into release
This commit is contained in:
commit
9f394bef66
@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cc.sukazyo'
|
||||
version '0.1.1'
|
||||
version '0.1.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cc.sukazyo.cono.morny;
|
||||
|
||||
import cc.sukazyo.cono.morny.util.StringUtils;
|
||||
|
||||
public class Logger {
|
||||
|
||||
public static final Logger logger = new Logger();
|
||||
@ -16,15 +18,15 @@ public class Logger {
|
||||
System.out.println(formatMessage(message, "WARN"));
|
||||
}
|
||||
|
||||
public void error (String message) {
|
||||
System.out.println(formatMessage(message, "ERRO"));
|
||||
}
|
||||
|
||||
private String formatMessage (String message, String level) {
|
||||
String levelStr = "\n["+level+"]";
|
||||
return String.format(
|
||||
"[%d][%s][%s]%s",
|
||||
System.currentTimeMillis(),
|
||||
Thread.currentThread().getName(),
|
||||
level,
|
||||
message.replaceAll("\\n", levelStr)
|
||||
);
|
||||
String prompt = String.format("[%s][%s]", System.currentTimeMillis(), Thread.currentThread().getName());
|
||||
String levelStr = String.format("[%s]", level);
|
||||
String newline = "\n" + StringUtils.repeatChar('\'', prompt.length()) + levelStr;
|
||||
return prompt + levelStr + message.replaceAll("\\n", newline);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cc.sukazyo.cono.morny;
|
||||
|
||||
import cc.sukazyo.cono.morny.bot.api.OnUpdate;
|
||||
import cc.sukazyo.cono.morny.bot.event.EventListeners;
|
||||
import cc.sukazyo.cono.morny.data.MornyHello;
|
||||
import com.pengrad.telegrambot.TelegramBot;
|
||||
import com.pengrad.telegrambot.request.GetMe;
|
||||
|
||||
@ -13,11 +14,13 @@ public class MornyCoeur {
|
||||
|
||||
public static void main (String[] args) {
|
||||
|
||||
logger.info(MornyHello.MORNY_PREVIEW_IMAGE_ASCII);
|
||||
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.");
|
||||
|
||||
@ -38,7 +41,7 @@ public class MornyCoeur {
|
||||
return account;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.out);
|
||||
logger.info("login failed.");
|
||||
logger.error("login failed.");
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Login failed..");
|
||||
|
8
src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java
Normal file
8
src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java
Normal file
File diff suppressed because one or more lines are too long
13
src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java
Normal file
13
src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user