-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CronJob to call a function #707
Comments
Check out https://github.com/github/hubot/blob/master/docs/scripting.md#timeouts-and-intervals for some examples of doing things on an interval. |
I tried this module.exports = (robot) ->
loopIntervalId = null
robot.respond /begintalking/, (msg) ->
if loopIntervalId
msg.send "I am still talking....and wont stop until you tell me"
return
msg.send "I will begin to talk every minute now!"
loopIntervalId = setInterval () ->
msg.send "I am still talking....and wontstop until you tell me"
, 1000
robot.respond /shutup/, (msg) ->
if loopIntervalId
msg.send "okay okay ill stop"
clearInterval(loopIntervalId)
loopIntervalId = null
else
msg.send "You have the power to stop me, just say it!" But it does not seem to be doing anything |
I can't tell if it's a bad copy paste or not, but it looks like the code in |
Even when I move the /begintalking/ above the loopintervalId it still is not working. module.exports = (robot) ->
loopIntervalId = null
robot.respond /begintalking/, (msg) ->
msg.send "I will begin to talk every minute now!"
loopIntervalId = setInterval () ->
msg.send "I am still talking....and wontstop until you tell me"
, 1000
if loopIntervalId
msg.send "I am still talking....and wont stop until you tell me"
return
robot.respond /shutup/, (msg) ->
if loopIntervalId
msg.send "okay okay ill stop"
clearInterval(loopIntervalId)
loopIntervalId = null
else
msg.send "You have the power to stop me, just say it!" |
nevermind. It works. It was indentation issue |
Excellent! I think we can close this out, unless you have any suggestions on how to make it easier to find the documentation and whatnot? Maybe use the word 'cron' somewhere so it's searchable? |
Trying to get Hubot to call a function (could be in the same script or from a different script) periodically every few minutes.
Currently I am able to say "hubot totalviewers" in a hipchat room and hubot will respond with the results from a function.
I would like hubot to call function "totalviewers" every few minutes without having the user required to initiate the command.
I cant seem to find any solid documentation on this.
The text was updated successfully, but these errors were encountered: