Browse files

Let Hubot respond to greetings.

  • Loading branch information...
1 parent 729982f commit 854bb560c8a480e4bd3cf820429993a905e0a2fb @noniq noniq committed Apr 24, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 scripts/greetings.coffee
View
19 scripts/greetings.coffee
@@ -0,0 +1,19 @@
+# Respond to greetings
+
+module.exports = (robot) ->
+ robot.enter (msg) ->
+ msg.send "Hallo!"
+
+ robot.hear /^(hallo|hi|hey|guten morgen)/i, (msg) ->
+ username = msg.message.user?.name
+ return if username == "Hubot" # Hubot shouldn't greet himself.
+ hour = new Date().getHours()
+ greeting = if 6 <= hour < 12
+ "Guten Morgen, #{username}!"
+ else if 12 <= hour < 18
+ "Hallo #{username}!"
+ else if 18 <= hour < 24
+ "Guten Abend, #{username}!"
+ else
+ "Um diese Uhrzeit, #{username}? Das ist nicht dein Ernst, oder?"
+ msg.send greeting

0 comments on commit 854bb56

Please sign in to comment.