From 703ef816c6394801685f94f063866ec2b057633b Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sun, 7 Nov 2021 17:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=A1=8Clog=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E5=BC=80=E5=B1=8F=E5=AD=97=E7=AC=A6=E7=94=BB=E8=BE=93?= =?UTF-8?q?=E5=87=BA=EF=BC=8C=E7=99=BB=E5=BD=95=E9=94=99=E8=AF=AF=E6=8D=95?= =?UTF-8?q?=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../java/cc/sukazyo/cono/morny/Logger.java | 18 ++++++++++-------- .../java/cc/sukazyo/cono/morny/MornyCoeur.java | 9 ++++++--- .../cc/sukazyo/cono/morny/data/MornyHello.java | 8 ++++++++ .../sukazyo/cono/morny/util/StringUtils.java | 13 +++++++++++++ 5 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java create mode 100644 src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java diff --git a/build.gradle b/build.gradle index a4e5f41..8eb1d4e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group 'cc.sukazyo' -version '0.1.1' +version '0.1.2' repositories { mavenCentral() diff --git a/src/main/java/cc/sukazyo/cono/morny/Logger.java b/src/main/java/cc/sukazyo/cono/morny/Logger.java index d9b6514..9727f55 100644 --- a/src/main/java/cc/sukazyo/cono/morny/Logger.java +++ b/src/main/java/cc/sukazyo/cono/morny/Logger.java @@ -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); } } diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 20e3c34..1b339ff 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -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.."); diff --git a/src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java b/src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java new file mode 100644 index 0000000..f8be6e3 --- /dev/null +++ b/src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java @@ -0,0 +1,8 @@ +package cc.sukazyo.cono.morny.data; + +@SuppressWarnings("all") +public class MornyHello { + + public static final String MORNY_PREVIEW_IMAGE_ASCII = "ttt///t/////fucj(\\tvnxtf{< .' .. .:i` . . ^!`l|-^i+,!_[:1/|{i?//\\//jf\\\\\\///\\\\\\\\//\\\\\\//////\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\\\\\\\\/\\\\\\\\/\\\\//\\\\\\///\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\fnncvvU0O00QCx!!\". .. ` \n" + "tt//////////\\jzjrucnjt/?{j,,\"' . .' .. .\":. .;{: ' \"`.,1(<.\"i?)\\(-}\\\\\\(((\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///\\//////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\\\\\\\///\\\\///\\\\\\\\\\\\\\\\|\\\\\\\\\\\\|\\\\\\\\\\\\\\\\tvXvuXcxn/[Il)({_:.. .\"` ., \n" + "//////////////////\\////|)/([}-_<+[]>.^^\"\"[<'`^` .''\"\"`'.`'`\"i! ^!>l:' :<\" !!.IiI`+l^^`i>_<`??)1;^{\\\\\\\\\\{|({({|/\\]I)\\\\()\\(]}|\\\\||\\|||\\/\\\\\\\\\\\\|||\\\\\\\\\\\\\\\\//\\\\\\\\/\\\\\\\\||\\\\\\\\\\\\\\\\//\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\\\\\\\\\\\\\\\\\\\\\\\\////\\\\\\\\\\\\\\\\\\//|{{?{|)[[-;\n" + "ttt/tt//////////////////{)(\\t(/tt/1~I}{-1\\_^])1_+[{|(?\"<1~>>+!+[}11)}[(1}]};^1\\|~_1}{I:-1(I+)(|))|\\\\/////////\\\\////\\\\\\/////\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\//\\\\///\\//||\\////|)(//\\\\///){\\/\\(11|///({)//({[1\\\\\\\\\\\\\\\\\\\\|\\/\\\\\\/\\//////////\\\\\\\\\\\\\\\\\\//\\\\\\\\\\///////\\|\\\\\\\\//////\\\\///\\\n" + "tttt/////////////\\///////\\||///////t//|(|)|}|\\/(\\\\(//(l_{{. ... \">+<^'I!: ^<(\\\\1}1//\\\\\\//////////\\\\///\\/\\///\\\\\\\\\\\\//\\\\//\\\\\\\\\\\\\\\\\\\\\\\\\\\\///\\(/\\{\n" + "t////////////////////////////////////////////////////////\\/\\\\///////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\||\\|\\\\\\\\\\|\\\\\\\\/\\\\|\\\\\\\\\\\\////((|///}!:,\":,^`. .;' ' '^..':. ^!;. .^^ '^^`. '' ...I[{!>:^;_i:'~\\ttt/////tt//\\\\////////////\\\\\\\\/\\\\\\\\\\\\/\\\\\\\\/\\\\\\\\\\)}-+[+I??i\n" + "ttt////////////////////////////////////////////////////////\\\\//\\//\\\\/\\\\\\\\\\\\\\\\\\\\//\\\\\\\\\\\\||\\\\\\/\\//\\\\\\\\\\\\\\\\\\/\\|\\\\\\////\\1;``^;<>+!\">__+I `' .. \"'. .;\" ;;. .:^ ``,,;'` .;]I ,-_-|\\////t////t///////\\/\\\\\\\\//\\\\\\\\\\\\//\\\\\\///////-II1ttt///tttt/////////\\/\\/////\\\\\\\\////t|+<}?!-]l<{[[1-+]\n" + "t//////////////////////////////////////\\/////////\\////////////////\\//////\\//tttttttttt//////////////////////////)_)t)|}1f/{<.^,^:~: . .. '''^:-|/> '-/}-_?\\/)-{?(//\\(\\tt////\\///\\\\\\\\\\\\\\///t1.;); .l~` '\"\n" + "///////////////////////////////////////////tt/t(|tt//]+{t\\{][|////\\//////////ttttt///t//t/////////////\\//////|//{[|f}!l>~++~<<\\//]l~?])tt//\\\\\\\\\\/\\\\///\\\\|?<_}[\"^!;I^;]:. .\n" + "////////////////////////////////tttt/|{[1)]~!!+>!<_(/|[-<\"i!l,]tt//ttt/t////ttt//t///ttttttt////////t//t//ttt){+. :?^ '. l_-!+l;;;|!!>~~il!lllllllllll!!lI:`'. .' :I;]_}>,?tf:.+fft)l+1//\\~`'I-(//\\/t/|/(-1[)/?>>II:' '.`';-'` \n" + "/////////////////////////t//()\\1_<>il^'''' ,!>;.,.'{tti `~tf(`'-(|fffftttttttttt/tttttttttttt///tttft//(t|]?-+!^ .\"`. `. ;!I,. .?{il-\\_!~<>>!lII;IllIIIIIllllllllllI;;:,:,' '\"^`(f{+{>' .<{t(I!}/||t> ^(//}>;:1\\]: \"[:\"` ^<: . II.'.. \n" + "///////////////ttt//tt((-!+}\"'^. I, ,?<:' ,:;!>~',!_~{}-1]`^!}_+\\ttttttt/tttttttfff/tt\\(||]-?+;,:\"l\" '..'.. ?]l:\" -(lI;,~?~!IIIlllI:IIlI;IIIIlllllllIIIIIllII!; . . '^^;~), \"~!}\\/t//\\\\/_. '\". '_i !i''' \n" + "tt//t///ttt///(]<>l>][l\"'.`,. ^.^. ii ;; ~>>>. .i~I'^^<}), .;|tfftttttttttttf\\]}t-!,,I` .^ '. !: . .\",I;. ^,I<)/-l:;llllllI;lIll;;IIIIlllIllIlIIlIllI;><. ' .;}\". '.:+](ft\\}(t/t{;<\\{l^>}!^l\\/{>1/t(lI:I!+<<\". ':\" \n" + "t//tttt|?+!I!:' '` .`. ...... `^ \"<^.;`^\"'`,!\".,^^^.,?)!. [f/+>(/tttft\\tff|+^,!' '^: >[,++:`' .I^ . _?!:^. ;~{/?//)! __::. ':. '. \n" + "t/\\}[{]\",il'`!-<-]:`'^` .. '' .^+:'. .^'\"i:`^. ';`:<_|>'.?/t/!\"<)ffftf)]]!'II.,l ^' ''. '\";\" .' `Il, ;]>]j_;lI;ll;!!llIII>~IIIIII;: ;,~.',.<:`, 'I_|\\; .i|/]^ ?(}\\/////\\i' '' ....'^ \n" + "tf1<}i `^. `I` .I?\"'. . . ^' .^' .'` .\". >}_.I|t{_(tf({~,~(); ')t};.><,. .. . .. . . .]}^{j1IlllIlI!1IlllII?{IIIIIlI;[1!I;IIllIIlIIllI<]_;+/t\\(|\\/1,' \"` ... \n" + ")+::((:^' ll .,` . . ..'. ' :+'`{tj{,l: ^;\"..;!\"^.I?' '~; .` .'. . `1+ [x?-:lIlll!]r-IllI~~{~I>lllll[i\\--+;;I~IIIII!l;x] \"I\"-<<_> >i.' l{}:itf/}[/\\)(\\}))|(:^^..'. `\". \n" + ">.._f|i.:l,;^^''__. .^' `' \"+,`]1i`!1_. ^l: .\". .` '1I +JIt!IIlll;]\\) >1}c(_i(!IllI_l;(f. ,_\";~~+^ .. .;-i '+([i+: !//1](||/\\(?:^..^^ \n" + "i'\"}_,.` ''^... '. `. ^<`_> .. +x??_~]:[|!,.ll` . {+ ;Y[^|,>~IlIIf\\ {/;I!\\ [[-'<+l-{ _??]f\\n]lllI[!;1v` `+\"]-}]~\" ..'`l, ''i-` l+?\\\\\\/t{!)t[:' .^^ \n" + ";,:: :,^..;:. . i+..;^ `_ ]]<-?l``-]' I>]?+. ^-|\\\\_I?]{t/?` .... \n" + "^(\\]I^~?;.\"!\" . .. . ^<^ :( >t) _[il>|+:(U<1nYQ0Xx\\> . .~xcXXYzx(n?IllI}\">xCI .:1]_-\" . .^. `}>!}((1-^,+?\" .. \n" + "1+,~I.(l' . ... ~|r:;`.+I?\\};+t) \"\".-?;lI>(;]xn. '_>]!+. '^'`l:11l[|((+?: . \n" + "[-`.':;..\"\"' lv|. .:_(;I!u> ^,\",^. .;?I]?IlI}n[^ ')(I' `tlII>x1\" <}1{)l \"~+ |[II;\\[:~zl .i;. .... `\"i\\\\}]..!' ^.... \n" + "-\" ` ' . \":` .|+<<;!\\U)>^ '^`' ^\"I?)c-;j/ <1I~;` .!}\\(: .;\"`' \n" + "' 'l, .' ~[><+;!f()nn|]!:' ..^:!+1fcjx}}v!_)})>|n` ~^ ^;\"'` .<+I<)/||\\i'\"<\"'^ `. \n" + " II ^}_'+_!fI?_/-jJjUr\\\\ucJJz\\|J>}?-j{]^ni\" .;](),.;-<`' .^ .^' \n" + " +[\" +]{.`i;I; ::.\"!??l.^Ywj}<, (n, ,~_:` .,, ` `` ' '... ^+-l,]}]}\\j/!. . ` 'I<~`'{tl..^` \n" + " '' .,<{[>\" i/i\" `-[; ,<_[>^i_l,:^_! ',+l.. ^,:,,. ;~>l;^ l> ',;I^???~,'l\".. .. \n" + " ;{?l. !+ .. .<1i '^' \"}|{:-+-;?\\[)-] ^:l1-:. '' '`, . ';.`~^ '. ..^`. \n" + " 'i+;]}!,. <))\\!<|ji >((_}}?t)}\\\\v|]?jI!), \"lf!l. ... .^ . \". \n" + " .+{>` l/z\\!,>\"\"I+~_){]vQjut_~~>>>_-<]<-)f\":l_v){\\/1}}}{t/\\0?z~. ^' `-l . . .. . \n" + " l\\ :_>>i:^+\\)_-]!:>-+l'...`^;1!^ 'l>})l\\n\\Qt?]?]})1{][[(XC>^ ...\n" + " ^-+^.i-((?!\"`:>l<[~<]nQY+?????][{\\cmO||l . ''..\n" + " '|: '^[{~)\\_+++))1{uxnvt(t){{[[u0\\1|({1()){-?|xfc: .. \n" + " .<-, ]-]]]})11)){{{{}{{)|{}}{1{111{11{{}}]_!\"x\\]Xf \n" + " ,]<\\}][[[[[[[[[[[[[[[]][[[[[[[[][[[[[[]?-+!YC{z} .`\n" + " \"_[}?]][[[[[[[[[[[[[[[[[[][[[[[[[[[[[[[[[]vn\\?. ^\n" + " ^. ;{_(_??][[[[[[[[[[[[[[[[[|[[[[[[[[[[[[[[[[v_(]^ \n" + " .' '. :t>/?[[[[[[[[[[[[[[[[[[[]t\\][[[[[[[[[[][]?u;()_ .. .'. . .\n" + " `. .` :)!j_]][[[]]]]][[[[[[[[[[}j(/{[[[[[][[}1{~n!)ft . .. .. . .. .\n" + " \". ..' .` . \"' .^\":;~ti{\\1]][]]]??]]]]][]]??[){[}[[[[?+}]!^':``^``,`;I.!<>?>:??i:;-;,<_..^,Ii: 'l,i+```' ..'!; ''. ?~.'<+ .li!:,1?}[[[[[[[[[[[[[[[[[[[[)1}]t[:, \"O\" . .' . ^!' . \". i+' . \n" + "^. . .':`'`~/1,-<-~^'^'^^,`..\"i_>^. `1t]!,^I]l^;`,I::_?]?[!:;`.`\"'`l!l<1f{~>;]\\1(]I>~l!l[<,,;`lI,~},^>!>l'...'\": 'x' ]l>i .:I1[~]]]]}}}}}[[}}[}}}}}[[]]]??1}}[}~;:>vx. :;..:??,.' ^` I;>.\";:\"^' .. ^'.^\"\" ' .!},' .\n" + "~!;:!\".\":i\"^_/|]^li(\\1;;it{' .[\\fft+<}(/{}/)|f||'.^{/[)?!:(?+-,I+fjtil\"'\"+fj{i:',!!;!!^:.`r. r; !l'\"i1?!i>~+_?][[[?-???]][[]?-+-]??+~<_{[_l?> ''^l;l`-}<`^.i>+l ``;I\":+?!~-l ,>>l.'.;. ':!!(/!\":,I\n" + "/t1ffft+{jff/ttff)];)?1(/tt\\/t/tfttttfftf/1\\|t\\|/?<_]_]{<_]/f({fffjttf/[i>1//|tft|\" :<~:+}, ]>if\" .:-~ >) ^`^l)f(_{/\\}-+1\\()t-{j/]!:^'l<]\\)+ .\"_?I_{\n" + "ffft)|)(t[_-{tjjrjrj/{(||}(rjj\\1)I<\\((ffj/rjffttjffftrjfffrtfff/f[1jjffffftt//)}tttff/ttt[<{rj}tf1?<:~{/j)>)fttf|?)tfffftt1_;+tf1-1|~i1, >;:} '1_ ;( .. .. `:\"_1{}tjtvj)vjr/|jfff/<(tf)+1/)1j)~~-[j[l|[(/\\j{:-]]([}\\t"; + +} diff --git a/src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java b/src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java new file mode 100644 index 0000000..7190670 --- /dev/null +++ b/src/main/java/cc/sukazyo/cono/morny/util/StringUtils.java @@ -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); + } + +}