mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-09-01 06:45:41 +00:00
[polling,webhook] Add methods controlling polling, webhook
Feature: For finer control over bot's polling and web-hook, the following methods have been added: * TelegramBot#isPolling() * TelegramBot#openWebHook() * TelegramBot#closeWebHook() * TelegramBot#hasOpenWebHook() Please read README.md for more information on the new methods.
This commit is contained in:
@@ -3,6 +3,7 @@ const https = require('https');
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const bl = require('bl');
|
||||
const Promise = require('bluebird');
|
||||
|
||||
|
||||
class TelegramBotWebHook {
|
||||
@@ -98,6 +99,19 @@ class TelegramBotWebHook {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the webHook
|
||||
* @return {Promise}
|
||||
*/
|
||||
close() {
|
||||
const self = this;
|
||||
return new Promise(function closePromise(resolve, reject) {
|
||||
self._webServer.close(function closeCb(error) {
|
||||
if (error) return reject(error);
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TelegramBotWebHook;
|
||||
|
Reference in New Issue
Block a user