benjick / meteor-telegram-bot

Telegram bot plugin for Meteor
24 stars 15 forks source link

Only parsePollResult if the method request succeeded #14

Closed shrmnk closed 8 years ago

shrmnk commented 8 years ago

I had an issue while developing a bot locally which caused duplicate commands along with my console window flooded with errors about how there was no result to parse in the setInterval. (I was on a weak wifi signal and this caused almost half my packets to be dropped)

Investigating further, I realised that any HTTP.get errors would only call a console.log with the exception, but parsePollResult will still be called.

I added a quick check if(result) before calling parsePollResult and it fixed all my above issues.

EDIT: Also added 2 more checks which prevent calling parsePollResult if there are no updates, and to check if there was duplicate poll data

Also took the chance to format the readme and add missing semicolons.