diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 1b339ff..26859e4 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -11,6 +11,7 @@ import static cc.sukazyo.cono.morny.Logger.logger; public class MornyCoeur { private static TelegramBot account; + public static final String USERNAME = "morny_cono_annie_bot"; public static void main (String[] args) { @@ -20,7 +21,7 @@ public class MornyCoeur { logger.info("args key:\n " + args[0]); try { account = login(args[0]); } - catch (Exception e) { logger.error("Cannot login to bot/api."); System.exit(-1); } + catch (Exception e) { logger.error("Cannot login to bot/api. :\n " + e.getMessage()); System.exit(-1); } logger.info("Bot login succeed."); @@ -37,7 +38,10 @@ public class MornyCoeur { for (int i = 1; i < 4; i++) { if (i != 1) logger.info("retrying..."); try { - logger.info("Succeed login to @" + account.execute(new GetMe()).user().username()); + String username = account.execute(new GetMe()).user().username(); + if (!USERNAME.equals(username)) + throw new RuntimeException("Required the bot @"+USERNAME + " but @"+username + "logged in!"); + logger.info("Succeed login to @" + username); return account; } catch (Exception e) { e.printStackTrace(System.out); diff --git a/src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java b/src/main/java/cc/sukazyo/cono/morny/MornyHello.java similarity index 99% rename from src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java rename to src/main/java/cc/sukazyo/cono/morny/MornyHello.java index f8be6e3..4004403 100644 --- a/src/main/java/cc/sukazyo/cono/morny/data/MornyHello.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyHello.java @@ -1,4 +1,4 @@ -package cc.sukazyo.cono.morny.data; +package cc.sukazyo.cono.morny; @SuppressWarnings("all") public class MornyHello { diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java index 4f2b9ea..a6653d2 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java @@ -22,13 +22,17 @@ public class OnCommandExecute extends EventListener { } switch (event.message().text()) { case "/o": + case "/o@" + MornyCoeur.USERNAME: onCommandOnExec(event); break; case "/hi": + case "/hi@" + MornyCoeur.USERNAME: case "/hello": + case "/hello@" + MornyCoeur.USERNAME: onCommandHelloExec(event); break; case "/exit": + case "/exit@" + MornyCoeur.USERNAME: onCommandExitExec(event); break; default: