Advertisement
Guest User

mega super kotlin inheritance

a guest
Dec 7th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import org.telegram.telegrambots.bots.TelegramLongPollingBot;
  2. import org.telegram.telegrambots.meta.api.interfaces.BotApiObject;
  3. import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
  4. import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
  5. import org.telegram.telegrambots.meta.api.objects.Update;
  6.  
  7. class ScratchBot extends TelegramLongPollingBot {
  8.     @Override public String getBotUsername() { return null; }
  9.     @Override public String getBotToken() { return null; }
  10.  
  11.     private final Action handler = new UpdateHandler();
  12.  
  13.     @Override public void onUpdateReceived(Update update) {
  14.         try {
  15.             execute(handler.createExecutableForChat(update.getMessage().getChatId()));
  16.         } catch (Exception ignored) {
  17.         }
  18.     }
  19. }
  20.  
  21. interface Action {
  22.     BotApiMethod<? extends BotApiObject> createExecutableForChat(long chatId);
  23. }
  24.  
  25. class UpdateHandler implements Action {
  26.  
  27.     @Override
  28.     public BotApiMethod<? extends BotApiObject> createExecutableForChat(long chatId) {
  29.         return new SendMessage();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement