github/hubot — comment on commit fd0887f5c0d71557c307004e587b19757a330c1f
File:  line 0
By unixcharles:

I think this is an important feature for slick integration with talker

I couldn't get it to work.

if I understand right, it should allow more talker-like mention with @mention:

@hobot ping

and turn them into

hobot: ping

But the regex doesn't seem to work for me, here I tried from the console:

coffee> quoteRegex: (string) -> string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
{ quoteRegex: [Function] }
coffee> quoteRegex = (string) -> string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
[Function]

coffee> name = 'hubot'
'hubot'

coffee> quoteRegex = (string) -> string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
[Function]
coffee> regexp = new RegExp("\\b@#{quoteRegex(name)}\\b", 'i')
/\b@hubot\b/i

coffee> content = '@hubot ping'
'@hubot ping'
coffee> content.replace(regexp, "#{name}: ")
'@hubot ping'

Why not just?

regexp = new RegExp "@#{self.name}", 'i'
message.content.replace(regexp, "#{self.name}:")

I don't understand what the quoteRegex function is doing?