First time writing a hubot script and using coffeescript, so excuse the messy code.
I wrote a script for automating responses on slack, it works great using a local redis server, but when I run it on heroku using the redis cloud some of the logic doesn't work. Any idea what might cause this?
# respond when corresponding trigger is heard.
robot.hear /(.*)/i, (res) ->
# check if robot.brain.data.responses are allowed in this channel,
if robot.brain.data.channels[res.message.room]
# get current time, -0 becasue otherwise 'new Date()' returns a string.
robot.brain.data.channels[res.message.room].timeNow = new Date() - 0
for comm of robot.brain.data.responses
if !robot.brain.data.responses[comm][res.message.room]
robot.brain.data.responses[comm][res.message.room] = new Channel res.message.room
# cheack if hubot is allowed to post in this channel
# and check the current time is more than TIMELIMIT minutes from the last time this message was posted,
# and check that there has been at least LINECOUNT lines posted since the last time this message was posted.
if robot.brain.data.channels[res.message.room] and robot.brain.data.channels[res.message.room].timeNow - robot.brain.data.responses[comm][res.message.room].lastTime > TIMELIMIT and robot.brain.data.channels[res.message.room].lineCount - robot.brain.data.responses[comm][res.message.room].lastLine > LINECOUNT
for trig of robot.brain.data.responses[comm].triggers
if res.match[1].includes(robot.brain.data.responses[comm].triggers[trig])
res.send robot.brain.data.responses[comm].response
robot.brain.data.responses[comm][res.message.room].lastTime = robot.brain.data.channels[res.message.room].timeNow
robot.brain.data.responses[comm][res.message.room].lastLine = robot.brain.data.channels[res.message.room].lineCount
break
First time writing a hubot script and using coffeescript, so excuse the messy code.
I wrote a script for automating responses on slack, it works great using a local redis server, but when I run it on heroku using the redis cloud some of the logic doesn't work. Any idea what might cause this?
Here's a link to my script: https://github.com/auryn-macmillan/spam_free_slackbot/tree/master
here is the code that is broken on heroku.