2
0
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:
GochoMugo
2017-01-02 13:58:46 +03:00
parent 69b059a4d7
commit 8edd5f4c6d
3 changed files with 86 additions and 2 deletions

View File

@@ -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;