Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jsbilsbrough
Last active December 17, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsbilsbrough/83fc7f42fdbd6d338f9b to your computer and use it in GitHub Desktop.
Save jsbilsbrough/83fc7f42fdbd6d338f9b to your computer and use it in GitHub Desktop.
Blowing Up Our Hubot - Kirk Style!
module.exports = (robot) ->
actions = [
"Warp Core overload",
"massive movie explosion",
"massive Joel hissy fit",
"End of William Shatner's career"
]
halfWayMessage = [
"Maybe time to get to the escape pods / transporter room?",
"Klingons have just boarded the ship!"
]
robot.respond /request(ing)* security access/i, (res) ->
if robot.auth.hasRole res.message.user, 'jedi'
res.send "Identity confirmed, #{res.message.user.name}"
setTimeout ->
res.reply "Awaiting your instructions…"
, 1000
robot.brain.set 'destruct_authorised', true
setTimeout ->
robot.brain.set 'destruct_authorised', false
, 5 * 60 * 1000
else
res.reply "You're not authorised. Go suck a lemon!"
robot.respond /destruct sequence ([1-3])\,* code (.*)/i, (res) ->
if robot.auth.hasRole res.message.user, 'jedi'
sequence = parseInt(res.match[1])
code = res.match[2].toUpperCase()
if robot.brain.get 'destruct_authorised'
switch sequence
when 1
if code is '11A'
res.reply "Confirmed, destruct sequence one accepted."
setTimeout ->
res.reply "Awaiting sequence two"
, 1000
robot.brain.set 'destruct_stage', 2
else
res.reply "Are you… trying to… blow me up?"
when 2
if code is '11A2B' and robot.brain.get('destruct_stage') is 2
res.reply "Confirmed, destruct sequence two accepted."
setTimeout ->
res.reply "Awaiting sequence three"
, 1000
robot.brain.set 'destruct_stage', 3
else
res.reply "You need to brush up on your Star Trek, laddy!"
when 3
if code is '1B2B3' and robot.brain.get('destruct_stage') is 3
res.reply "Destruct sequence completed and engaged"
robot.brain.set 'destruct_stage', 4
setTimeout ->
res.reply "Awaiting final code for one-minute countdown"
, 1000
else
res.reply "Ensign authorisation code 95 wictor wictor"
else
res.reply "Security authorisation required"
else
res.reply "You're not authorised."
robot.respond /code 000 destruct 0/i, (res) ->
if robot.auth.hasRole res.message.user, 'jedi'
if robot.brain.get('destruct_authorised') and robot.brain.get('destruct_stage') is 4
res.reply "Destruct sequence is activated"
setTimeout ->
res.send "#{res.random actions} in…"
timeLeft = 60
timer = setInterval ->
if timeLeft is 30
res.send "30… #{res.random halfWayMessage}"
else if timeLeft > 0
res.send timeLeft--
else
res.send "https://youtu.be/WCSKXugQrP0?t=223"
clearInterval timer
, 1000
, 1000
else
res.reply "Go easy on the Shatner impressions, eh?"
else
res.reply "You're not authorised."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment