Extract the timeline to its own class
Opened this issue · 0 comments
Take a look here: https://github.com/luinix/enriquetor/blob/master/slack/channel.rb#L42-L58
Because we are using async, adding an active wait blocks the thread so the control never goes back to the Slack client and the message is sent. Because of that, if you sleep the typing time, nothing is sent, and everything is sent in one go when you free the thread.
Because of that, I'm using the EventMachine
timers, so I setup a "timeline" of what should be sent and when, and then free the thread as soon as I finish. But that also means that, if the enriquetor gets triggered for a reply BEFORE it finishes saying its last bullshit, it just sends both replies at the same time, mixing the messages.
We should extract the timeline to an object that belongs to the channel, and that keeps all the timing correctly.