2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 14:25:57 +00:00

[webhook,polling] Improve starting, stopping of webhook, polling

Feature:

  The different mechanisms of fetching updates, i.e. polling
  and webhook, have had their implementations improved:

  * the TelegramBot instance needs to create the polling and
    webhook instances once, and when necessary
  * returning promises from TelegramBot#openWebHook() and
    TelegramBot#startPolling() allows more precise control

  Also,

  * TelegramBot#initPolling() is being deprecated in favor of
    TelegramBot#startPolling() to ensure consistency (as the
    opposite action of TelegramBot#stopPolling())
This commit is contained in:
GochoMugo
2017-01-09 15:57:34 +03:00
parent 4735518116
commit 97c8130d93
5 changed files with 159 additions and 61 deletions

View File

@@ -178,10 +178,11 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#initPolling', function initPollingSuite() {
describe('#startPolling', function initPollingSuite() {
it('initiates polling', function test() {
testbot.initPolling();
return utils.isPollingMockServer(pollingPort);
return testbot.startPolling().then(() => {
return utils.isPollingMockServer(pollingPort);
});
});
});
@@ -213,8 +214,9 @@ describe('TelegramBot', function telegramSuite() {
describe('#openWebHook', function openWebHookSuite() {
it('opens webhook', function test() {
testbot.openWebHook();
return utils.hasOpenWebHook(webHookPort);
return testbot.openWebHook().then(() => {
return utils.hasOpenWebHook(webHookPort);
});
});
});