diff --git a/README.md b/README.md
index f32cc47..e32f026 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,8 @@ TelegramBot
* [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ Boolean
* [.getMe()](#TelegramBot+getMe) ⇒ Promise
* [.setWebHook(url, [options])](#TelegramBot+setWebHook)
+ * [.deleteWebHook()](#TelegramBot+deleteWebHook) ⇒ Promise
+ * [.getWebHookInfo()](#TelegramBot+getWebHookInfo) ⇒ Promise
* [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ Promise
* [.processUpdate(update)](#TelegramBot+processUpdate)
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ Promise
@@ -202,6 +204,24 @@ that is being deprecated.
| [options] | Object
| Additional Telegram query options |
| [options.certificate] | String
| stream.Stream
| PEM certificate key (public). |
+
+
+### telegramBot.deleteWebHook() ⇒ Promise
+Use this method to remove webhook integration if you decide to
+switch back to getUpdates. Returns True on success.
+
+**Kind**: instance method of [TelegramBot](#TelegramBot)
+**See**: https://core.telegram.org/bots/api#deletewebhook
+
+
+### telegramBot.getWebHookInfo() ⇒ Promise
+Use this method to get current webhook status.
+On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
+If the bot is using getUpdates, will return an object with the
+url field empty.
+
+**Kind**: instance method of [TelegramBot](#TelegramBot)
+**See**: https://core.telegram.org/bots/api#getwebhookinfo
### telegramBot.getUpdates([options]) ⇒ Promise
diff --git a/src/telegram.js b/src/telegram.js
index f76d441..9f7674d 100644
--- a/src/telegram.js
+++ b/src/telegram.js
@@ -335,6 +335,28 @@ class TelegramBot extends EventEmitter {
});
}
+ /**
+ * Use this method to remove webhook integration if you decide to
+ * switch back to getUpdates. Returns True on success.
+ * @return {Promise}
+ * @see https://core.telegram.org/bots/api#deletewebhook
+ */
+ deleteWebHook() {
+ return this._request('deleteWebhook');
+ }
+
+ /**
+ * Use this method to get current webhook status.
+ * On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
+ * If the bot is using getUpdates, will return an object with the
+ * url field empty.
+ * @return {Promise}
+ * @see https://core.telegram.org/bots/api#getwebhookinfo
+ */
+ getWebHookInfo() {
+ return this._request('getWebhookInfo');
+ }
+
/**
* Use this method to receive incoming updates using long polling.
* This method has an [older, compatible signature][getUpdates-v0.25.0]
diff --git a/test/telegram.js b/test/telegram.js
index 80ee7cb..3364448 100644
--- a/test/telegram.js
+++ b/test/telegram.js
@@ -250,6 +250,30 @@ describe('Telegram', function telegramSuite() {
});
});
+ describe('#deleteWebHook', function deleteWebHookSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'deleteWebHook', this);
+ });
+ it('should delete webhook', function test() {
+ return bot.deleteWebHook().then(resp => {
+ assert.equal(resp, true);
+ });
+ });
+ });
+
+ describe('#getWebHookInfo', function getWebHookInfoSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'getWebHookInfo', this);
+ });
+ it('should return WebhookInfo', function test() {
+ return bot.getWebHookInfo().then(resp => {
+ assert.ok(is.object(resp));
+ assert.ok(is.boolean(resp.has_custom_certificate));
+ assert.ok(is.number(resp.pending_update_count));
+ });
+ });
+ });
+
describe('#getUpdates', function getUpdatesSuite() {
const opts = {
timeout: 0,
@@ -258,7 +282,7 @@ describe('Telegram', function telegramSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setWebHook', this);
utils.handleRatelimit(bot, 'getUpdates', this);
- return bot.setWebHook('');
+ return bot.deleteWebHook();
});
it('should return an Array', function test() {
return bot.getUpdates(opts).then(resp => {