Closed arcturial closed 8 years ago
Solves issue #43
@lukefx please review.
I will run this on my setup for a day or so to test for any errors and will merge when all are happy.
With a fresh setup I'm getting endless messages from the bot... Strange...I'm using this code directly in my package.json
"hubot-telegram": "lukefx/hubot-telegram#issue-43"
Updated. Wasn't properly setting the offset
We can. However, if the handleUpdate
method is slow it might hold up the loop. For example, if you receive 5 messages and handling each message takes 1 second. If your setInterval
is 2 seconds, you will end up with atleast 2 duplicate messages. Does that make sense?
We can. However, if the handleUpdate method is slow it might hold up the loop. For example, if you receive 5 messages and handling each message takes 1 second. If your setInterval is 2 seconds, you will end up with atleast 2 duplicate messages. Does that make sense?
yepp absolutely...aaaaand, what about move offset just to the last update_id without a loop?
self.offset = result[result.length-1].update_id if result.length
for msg in result
self.handleUpdate msg
That will work, will update the PR a bit later.
To reduce duplicate messages, update the offset immediately when Telegram responds.