node-telegram-api/lib/functions/poll.js
2015-11-08 06:52:06 +03:30

12 lines
264 B
JavaScript

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);
if (bot._stop) return null;
return poll(bot);
});
}