Skip to content

Commit

Permalink
warn about anchors not working with respond, fixes hubotio#10
Browse files Browse the repository at this point in the history
  • Loading branch information
atmos committed Oct 11, 2011
1 parent f796552 commit ce149d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/hubot/shell.coffee
Expand Up @@ -13,7 +13,6 @@ class Shell extends Robot
console.log "Hubot: the Shell."

user = @userForId('1', {name: "Shell"})
console.log user

process.stdin.resume()
process.stdin.on 'data', (txt) =>
Expand Down
8 changes: 6 additions & 2 deletions src/robot.coffee
Expand Up @@ -37,10 +37,14 @@ class Robot
# Returns nothing.
respond: (regex, callback) ->
re = regex.toString().split("/")
if re[1] and re[1][0] == "^"
console.log "\nWARNING: Anchors don't work well with respond, perhaps you want to use 'hear'"
console.log "WARNING: The regex in question was #{regex.toString()}\n"

if @enableSlash
newRegex = new RegExp("(\/|#{@name}:?)\\s*#{re[1]}", re[2])
newRegex = new RegExp("^(\/|#{@name}:?)\\s*#{re[1]}", re[2])
else
newRegex = new RegExp("#{@name}:?\\s*#{re[1]}", re[2])
newRegex = new RegExp("^#{@name}:?\\s*#{re[1]}", re[2])
@listeners.push new Listener(@, newRegex, callback)

# Public: Passes the given message to any interested Listeners.
Expand Down

0 comments on commit ce149d9

Please sign in to comment.