Bug:
During polling, deleting the already-set webhook, caused
the `TelegramBotPolling#_getUpdates()` return an unexpected
value.
We expect the method to return an array (in the `.then()` clause).
However, deleting the webhook returns its value, which is an object,
from the method `_getUpdates()`.
Fix:
Simply retry the polling request and return the promise.
Notes:
Should we use recursion? I do not think so.
Why? The chances of getting the error (having a webhook set) AGAIN
is quite rare. And if it happens, there must be some problem with
different instances invoking polling and webhook simultaneously.
In that case, we wont struggle to recover from such a scenario.
User is on their own! Isht!
References:
* Bug report: https://github.com/yagop/node-telegram-bot-api/issues/284
* Reported by: @dcparga
Bug:
Array#findIndex() is unavailable in Node.js v0.x.
Since we are deprecating Node.js v0.x already, we
can use a shim in the mean time.
Once we stop supporting that version range, we can
drop the shim entirely.
tags: deprecate/node-v0.x
Bug:
On certain errors, during polling, cause the following error to be
thrown:
TypeError: Cannot read property 'statusCode' of undefined
This is caused when we try to access the 'response' property on
the error object in the error handler (`catch(error)`). It goes
missing when the error was fatal, for example, network error, thus
no server response available.
References:
* Issue #281: https://github.com/yagop/node-telegram-bot-api/issues/281
* Reported-by: @dimawebmaker
Feature:
To be more RFC compliant, particularly when sending
files, we are going to default to using POST requests.
We have been using GET requests (even when uploading files).
PS: This causes major problems with PWRTelegram API
Feature:
Polling and WebHook are mutually exclusive. Therefore, return an
error whenever the user tries to start polling, and the instance has
an open webhook, or user tries to open a webhook, and the instance
is already polling.
Feature:
The constructor option, 'filepath', allows us to remove
the TelegramBot's behaviour of allowing users to pass in
file-paths as arguments, as it involves some operations
that might be (are) strongly against what a programmer wishes
to achieve with the library.
Expect this to be documented better in the near future.
Implementation:
* Backwards compatible: The default behavior is not changed!
Bug:
The method TelegramBot#_formatSendData() throws an error
if the Buffer file type is NOT supported. We need to handle
it, by returning a Promise that is reject with the originally
thrown exception.
References:
* PR trying to achieve the same: https://github.com/yagop/node-telegram-bot-api/pull/66
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())