Advertisement
Exception_Prototype

Untitled

Aug 7th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. public class Main {
  2.  
  3.     public static final Logger logger = LogManager.getLogger("name");
  4.  
  5.     public static void main(String[] args) throws Exception {
  6.  
  7.         ApiContextInitializer.init();
  8.         TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
  9.         try {
  10.             telegramBotsApi.registerBot(new TelegramLongPollingBot() {
  11.                 @Override
  12.                 public String getBotToken() {
  13.                     return Reference.BOT_NAME;
  14.                 }
  15.  
  16.                 @Override
  17.                 public void onUpdateReceived(Update update) {
  18.                     if (update.hasMessage()) {
  19.                         if (update.getMessage().hasText()) {
  20.                             logger.info(update.getMessage().getText());
  21.                         }
  22.                     }
  23.                 }
  24.  
  25.                 @Override
  26.                 public String getBotUsername() {
  27.                     return Reference.BOT_TOKEN;
  28.                 }
  29.             });
  30.         } catch (TelegramApiException e) {
  31.             e.printStackTrace();
  32.         }
  33.  
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement