Permalink
Browse files

brb - natural availability tracking

  • Loading branch information...
1 parent 3dd2d4a commit ff646f4b665975063fa7e717bfcf23bb597b98e4 @jmhobbs jmhobbs committed Jan 18, 2013
Showing with 34 additions and 0 deletions.
  1. +34 −0 src/scripts/brb.coffee
View
@@ -0,0 +1,34 @@
+# Description:
+# Natural availability tracking.
+#
+# Dependencies:
+# None
+#
+# Configuration:
+# None
+#
+# Commands:
+# brb
+#
+# Author:
+# jmhobbs
+
+module.exports = (robot) ->
+
+ users_away = {}
+
+ robot.hear( /./i, (msg) ->
+ if users_away[msg.message.user.name] and msg.message.text != 'brb'
+ msg.send "Welcome back " + msg.message.user.name + "!"
+ delete users_away[msg.message.user.name]
+ else
+ for user, state of users_away
+ substr = msg.message.text.substring(0, user.length+1)
+ if substr == user + ':'
+ msg.send user + " is currently away."
+ break
+ )
+
+ robot.hear /brb/i, (msg) ->
+ users_away[msg.message.user.name] = true
+

0 comments on commit ff646f4

Please sign in to comment.