Skip to content

Commit

Permalink
Merge pull request #328 from HarryZalessky/master
Browse files Browse the repository at this point in the history
Updated readme about new setUpdatesListener usage
  • Loading branch information
pengrad authored May 2, 2023
2 parents 2755e47 + e216f52 commit bea9e3c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ bot.setUpdatesListener(updates -> {
// ... process updates
// return id of last processed update or confirm them all
return UpdatesListener.CONFIRMED_UPDATES_ALL;
// Create Exception Handler
}, e -> {
if (e.response() != null) {
// got bad response from telegram
e.response().errorCode();
e.response().description();
} else {
// probably network error
e.printStackTrace();
}
});

// Send messages
Expand Down Expand Up @@ -197,6 +207,20 @@ bot.setUpdatesListener(new UpdatesListener() {

return UpdatesListener.CONFIRMED_UPDATES_ALL;
}
// Create Exception Handler
}, new ExceptionHandler() {
@override
public void onException(TelegramException e)
{
if (e.response() != null) {
// got bad response from telegram
e.response().errorCode();
e.response().description();
} else {
// probably network error
e .printStackTrace();
}
}
});
```

Expand Down
28 changes: 27 additions & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,21 @@ TelegramBot bot = new TelegramBot("BOT_TOKEN");

// Подписка на обновления
bot.setUpdatesListener(updates -> {
// ... process updates

// Обработка обновлений

// return id of last processed update or confirm them all
return UpdatesListener.CONFIRMED_UPDATES_ALL;
// Создание Обработчика ошибок
}, e -> {
if (e.response() != null) {
// Ошибка из Телеграма
e.response().errorCode();
e.response().description();
} else {
// Как видно проблема сети
e.printStackTrace();
}
});

// Отправка сообщений
Expand Down Expand Up @@ -198,6 +210,20 @@ bot.setUpdatesListener(new UpdatesListener() {

return UpdatesListener.CONFIRMED_UPDATES_ALL;
}
// Создание Обработчика ошибок
}, new ExceptionHandler() {
@override
public void onException(TelegramException e)
{
if (e.response() != null) {
// Ошибка из Телеграма
e.response().errorCode();
e.response().description();
} else {
// Как видно проблема сети
e .printStackTrace();
}
}
});
```

Expand Down

0 comments on commit bea9e3c

Please sign in to comment.