diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java index 0a88c573..90ab7f75 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/TelegramBotsApi.java @@ -100,6 +100,25 @@ public class TelegramBotsApi { } } + /** + * Register a bot in the api that will receive updates using webhook method + * @param bot Bot to register + * + * @apiNote The webhook url will be appended with `/callback/bot.getBotPath()` at the end + */ + public void registerBotWithoutToken(WebhookBot bot) throws TelegramApiException { + if (useWebhook) { + if (webhook == null) { + throw new TelegramApiException("This instance doesn't support Webhook bot, use correct constructor"); + } + if (StringUtils.isEmpty(bot.getBotUsername())) { + throw new TelegramApiException("Bot username can't be empty"); + } + bot.onRegister(); + webhook.registerWebhook(bot); + } + } + /** * Checks that the username and token are presented * @param telegramBot bot to register