Permalink
Browse files

Restrict username input

  • Loading branch information...
1 parent 414096d commit 48d7f9254483ac2dda8f87715f9ef80e6cd4de97 @jrhames jrhames committed Feb 14, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/scripts/namechanger.coffee
@@ -3,12 +3,12 @@
# call me <something> - Set your user name to something
# my name is <something> - Set your user name to something
module.exports = (robot) ->
- robot.respond /(call me|my name is) (.*)$/i, (msg) ->
+ robot.respond /(call me|my name is) ([\w\s]+)$/i, (msg) ->
msg.user.original_name = msg.user.name
# Capitalize just to be sure.
- msg.user.name = (msg.match[2].charAt(0).toUpperCase() +
- msg.match[2].substring(1).toLowerCase())
+ msg.user.name = (msg.match[2].trim().charAt(0).toUpperCase() +
+ msg.match[2].trim().substring(1).toLowerCase())
msg.send "From now on I'll call you #{msg.user.name}."

0 comments on commit 48d7f92

Please sign in to comment.