Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.joshyflightbot;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import org.telegram.telegrambots.bots.TelegramLongPollingBot;
- import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
- import org.telegram.telegrambots.meta.api.objects.Update;
- import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
- import java.util.List;
- public class JoshyFlightDealsBot extends TelegramLongPollingBot {
- private static final Logger LOG = LogManager.getLogger(JoshyFlightDealsBot.class);
- public JoshyFlightDealsBot(){
- LOG.info("Created a new bot");
- System.out.println("created a new bot");
- }
- public void onUpdateReceived(Update update) {
- // We check if the update has a message and the message has text
- LOG.info(update.getMessage());
- System.out.println("update " + update.getMessage());
- if (update.hasMessage() && update.getMessage().hasText()) {
- SendMessage message = new SendMessage() // Create a SendMessage object with mandatory fields
- .setChatId(update.getMessage().getChatId())
- .setText(update.getMessage().getText());
- try {
- execute(message); // Call method to send the message
- } catch (TelegramApiException e) {
- e.printStackTrace();
- }
- }
- }
- public void onUpdatesReceived(List<Update> updates) {
- }
- public String getBotUsername() {
- return "name";
- }
- public String getBotToken() {
- return "s:AAH-assd";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement