Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. package com.joshyflightbot;
  2.  
  3. import org.apache.logging.log4j.LogManager;
  4. import org.apache.logging.log4j.Logger;
  5. import org.telegram.telegrambots.bots.TelegramLongPollingBot;
  6. import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
  7. import org.telegram.telegrambots.meta.api.objects.Update;
  8. import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
  9.  
  10. import java.util.List;
  11.  
  12. public class JoshyFlightDealsBot extends TelegramLongPollingBot {
  13. private static final Logger LOG = LogManager.getLogger(JoshyFlightDealsBot.class);
  14.  
  15. public JoshyFlightDealsBot(){
  16. LOG.info("Created a new bot");
  17. System.out.println("created a new bot");
  18. }
  19.  
  20. public void onUpdateReceived(Update update) {
  21. // We check if the update has a message and the message has text
  22. LOG.info(update.getMessage());
  23. System.out.println("update " + update.getMessage());
  24. if (update.hasMessage() && update.getMessage().hasText()) {
  25. SendMessage message = new SendMessage() // Create a SendMessage object with mandatory fields
  26. .setChatId(update.getMessage().getChatId())
  27. .setText(update.getMessage().getText());
  28. try {
  29. execute(message); // Call method to send the message
  30. } catch (TelegramApiException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. }
  35.  
  36. public void onUpdatesReceived(List<Update> updates) {
  37.  
  38. }
  39.  
  40. public String getBotUsername() {
  41. return "name";
  42. }
  43.  
  44. public String getBotToken() {
  45. return "s:AAH-assd";
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement