Don't merge yet: Keep on listening to Telegram's updates even if requests with telegram server fail #40

Merged
laurynas-karvelis merged 2 commits from master into master 2018-02-18 17:21:07 +00:00
Showing only changes of commit 6e2a728e76 - Show all commits

View File

@ -1,13 +1,17 @@
export default function poll(bot) {
return bot.api.getUpdates(bot.update).then(response => {
if (!response.result.length) {
return poll(bot);
}
bot.emit('update', response.result);
return bot.api.getUpdates(bot.update)
.then(response => {
if (!response.result.length) {
return poll(bot);
}
bot.emit('update', response.result);
if (bot._stop) {
return null;
}
return poll(bot);
});
if (bot._stop) {
return null;
}
return poll(bot);
})
.catch(() => {
return poll(bot);
});
}