Created
February 13, 2013 02:02
-
-
Save lopopolo/4863319 to your computer and use it in GitHub Desktop.
Hubot script to replay the last bot command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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