Skip to content

Instantly share code, notes, and snippets.

@lopopolo
Created February 13, 2013 02:02
Show Gist options
  • Save lopopolo/4863319 to your computer and use it in GitHub Desktop.
Save lopopolo/4863319 to your computer and use it in GitHub Desktop.
Hubot script to replay the last bot command
# Description:
# Last asks Hubot to repeat the last command he received
#
# Commands:
# hubot !! - execute the last received command
# hubot last - execute the last received command
# hubot repeat - execute the last received command
Robot = require('hubot')
module.exports = (robot) ->
robot.respond /!!/i, (msg) ->
if robot.brain.data.last_command
robot.receive new Robot.TextMessage(msg.message.user, robot.brain.data.last_command, msg.id)
else
msg.send "No last command in mah memories"
robot.respond /last/i, (msg) ->
if robot.brain.data.last_command
robot.receive new Robot.TextMessage(msg.message.user, robot.brain.data.last_command, msg.id)
else
msg.send "No last command in mah memories"
robot.respond /repeat/i, (msg) ->
if robot.brain.data.last_command
robot.receive new Robot.TextMessage(msg.message.user, robot.brain.data.last_command, msg.id)
else
msg.send "No last command in mah memories"
robot.respond /(?!.*(!!|last|repeat))(.*)/i, (msg) ->
robot.brain.data.last_command = msg.match[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment