Add custom method
This commit is contained in:
parent
9b8c41dab1
commit
228e583c26
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user