Advertisement
emodev

Bot Class

Jan 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.22 KB | None | 0 0
  1. import org.telegram.telegrambots.bots.TelegramLongPollingBot;
  2. import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
  3. import org.telegram.telegrambots.meta.api.objects.Chat;
  4. import org.telegram.telegrambots.meta.api.objects.Message;
  5. import org.telegram.telegrambots.meta.api.objects.Update;
  6. import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
  7.  
  8. public class JustBot extends TelegramLongPollingBot {
  9.  
  10.  
  11.     public void onUpdateReceived(Update update) {
  12.         if (update.hasMessage() && update.getMessage().hasText()) {
  13.             SendMessage message = new SendMessage() // Create a SendMessage object with mandatory fields
  14.                     .setChatId(update.getMessage().getChatId());
  15.  
  16.  
  17.             if (update.getMessage().getText().contains("/start")) {
  18.                 message.setText("Hey! What's up?\nSearch for something: /search" +
  19.                         "\n Want photo of a sexy girl? /sexy");
  20.             } else if (update.getMessage().getText().contains("/search")) {
  21.                 message.setText("https://google.com");
  22.             } else if (update.getMessage().getText().contains("/sexy")) {
  23.                 message.setText("http://bit.ly/2SWsomR");
  24.             } else if (update.getMessage().getText().contains("/kane")) {
  25.                 message.setText("Hey! What's up?\nSearch for something: /search" +
  26.                         "\n Want photo of a sexy girl? /sexy");
  27.             } else if (update.getMessage().getText().contains("/commands")) {
  28.                 message.setText("List of all commands\n" +
  29.                         "No, You can't command me!!.....return....\n" +
  30.                         "Do I?!\n" +
  31.                         "/search - search engine\n" +
  32.                         "/sexy - sexy girls\n" +
  33.                         "/commands - show all commands");
  34.             }
  35.             try {
  36.                 execute(message); // Call method to send the message
  37.             } catch (TelegramApiException e) {
  38.                 e.printStackTrace();
  39.             }
  40.         }
  41.     }
  42.  
  43.     public String getBotUsername() {
  44.         return "theDemonic_bot";
  45.     }
  46.  
  47.     public String getBotToken() {
  48.         return "609519037:AAGbPiLeQWYM8i0d6H-G_ylA_O3bNe71UNw";
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement