Search in sources :

Example 1 with BotSession

use of org.telegram.telegrambots.generics.BotSession in project telegram-notifications-plugin by jenkinsci.

the class TelegramBotThread method run.

@Override
public void run() {
    try {
        // Start bot session
        BotSession session = TELEGRAM_BOTS_API.registerBot(bot);
        LOGGER.finest("BotSession was started");
        while (true) {
            if (isInterrupted()) {
                // If thread was interrupted bot session should be closed
                session.stop();
                LOGGER.finest("BotSession was closed");
                break;
            }
        }
    } catch (TelegramApiException e) {
        LOGGER.log(Level.SEVERE, "Telegram API error", e);
        interrupt();
    }
}
Also used : TelegramApiException(org.telegram.telegrambots.exceptions.TelegramApiException) BotSession(org.telegram.telegrambots.generics.BotSession)

Aggregations

TelegramApiException (org.telegram.telegrambots.exceptions.TelegramApiException)1 BotSession (org.telegram.telegrambots.generics.BotSession)1