mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 18:07:16 +00:00
Add deleteWebHook, getWebHookInfo (#246)
This commit is contained in:
parent
bc7549599e
commit
215e0dc23b
20
README.md
20
README.md
@ -79,6 +79,8 @@ TelegramBot
|
||||
* [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ <code>Boolean</code>
|
||||
* [.getMe()](#TelegramBot+getMe) ⇒ <code>Promise</code>
|
||||
* [.setWebHook(url, [options])](#TelegramBot+setWebHook)
|
||||
* [.deleteWebHook()](#TelegramBot+deleteWebHook) ⇒ <code>Promise</code>
|
||||
* [.getWebHookInfo()](#TelegramBot+getWebHookInfo) ⇒ <code>Promise</code>
|
||||
* [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
||||
* [.processUpdate(update)](#TelegramBot+processUpdate)
|
||||
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
||||
@ -202,6 +204,24 @@ that is being deprecated.
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
| [options.certificate] | <code>String</code> | <code>stream.Stream</code> | PEM certificate key (public). |
|
||||
|
||||
<a name="TelegramBot+deleteWebHook"></a>
|
||||
|
||||
### telegramBot.deleteWebHook() ⇒ <code>Promise</code>
|
||||
Use this method to remove webhook integration if you decide to
|
||||
switch back to getUpdates. Returns True on success.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#deletewebhook
|
||||
<a name="TelegramBot+getWebHookInfo"></a>
|
||||
|
||||
### telegramBot.getWebHookInfo() ⇒ <code>Promise</code>
|
||||
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 <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#getwebhookinfo
|
||||
<a name="TelegramBot+getUpdates"></a>
|
||||
|
||||
### telegramBot.getUpdates([options]) ⇒ <code>Promise</code>
|
||||
|
@ -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]
|
||||
|
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user