     search msg, msg.match[2], (text) ->
       msg.reply text
   
-  robot.hear /(\w+-[0-9]+)/ig, (msg) ->
+  robot.hear /([^\w\-]|^)(\w+-[0-9]+)([^\w]|$)/ig, (msg) ->
     if msg.message.user.id is robot.name
       return
-    
+
+    if (ignoredusers.some (user) -> user == msg.message.user.name)
+      console.log 'ignoring user due to blacklist:', msg.message.user.name
+      return
+   
     for matched in msg.match
-      if !recentissues.contains msg.message.user.room+matched
-        info msg, matched, (text) ->
+      ticket = (matched.match /(\w+-[0-9]+)/)[0]
+      if !recentissues.contains msg.message.user.room+ticket
+        info msg, ticket, (text) ->
           msg.send text
-        recentissues.add msg.message.user.room+matched
+        recentissues.add msg.message.user.room+ticket
 
   robot.respond /save filter (.*) as (.*)/i, (msg) ->
     filter = filters.get msg.match[2]

    @issues[issue]?

  add: (issue,time) ->
    time = time || (new Date()).getTime()
    @issues[issue] = time



module.exports = (robot) ->
  filters = new IssueFilters robot

  # which version of the API being used
  useV2 = process.env.HUBOT_JIRA_USE_V2 || false
  # max number of issues to list during a search
  maxlist = process.env.HUBOT_JIRA_MAXLIST || 10
  # how long (seconds) to wait between repeating the same JIRA issue link
  issuedelay = process.env.HUBOT_JIRA_ISSUEDELAY || 30

  get = (msg, where, cb) ->
    console.log(process.env.HUBOT_JIRA_URL + "/rest/api/latest/" + where)

class RecentIssues
  constructor: (@maxage) ->
    @issues = []
  
  cleanup: ->
    for issue,time of @issues
      age = Math.round(((new Date()).getTime() - time) / 1000)
      if age > @maxage 
        #console.log 'removing old issue', issue
        delete @issues[issue]
    0
