Skip to content

Commit

Permalink
ExceptionHandler for TelegramBot.
Browse files Browse the repository at this point in the history
  • Loading branch information
bivashy committed Jun 11, 2022
1 parent 687bcdc commit cde2877
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public TelegramCommandRegistry() {
context -> new TelegramCommandActorWrapper(context.actor()));
registerCommands();

TELEGRAM_HOOK.getTelegramBot().setUpdatesListener(new TelegramCommandUpdatesListener());
TELEGRAM_HOOK.getTelegramBot().setUpdatesListener(new TelegramCommandUpdatesListener(), exception -> {
exception.printStackTrace();
if(exception.response().errorCode()==409) {// Multiple bot instances error.
TELEGRAM_HOOK.getTelegramBot().removeGetUpdatesListener();
System.err.println("Telegram bot disabled because you are already running another bot instance!");
System.err.println("Please use another token if you need to run multiple bot instances");
}
});
}
}

0 comments on commit cde2877

Please sign in to comment.