Permalink
Browse files

Use the default mention behavior for hipchat

Hipchat autocompletes using the first name of the person ie:
Hubot, I autocompletes to @hubot

so take the default behavior to use in the listener.
  • Loading branch information...
cesar-zz committed Oct 26, 2011
1 parent 29792dd commit 79df1b93270c0eda06e8edd3431bb653c18fb7ce
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/hubot/hipchat.coffee
View
@@ -25,6 +25,7 @@ class HipChat extends Robot
console.log "Options:", @options
bot = new Wobot(jid: @options.jid, name: @options.name, password: @options.password)
+ mention='@'+@options.name.split(' ')[0]
console.log "Bot:", bot
bot.onConnect =>
@@ -49,11 +50,11 @@ class HipChat extends Robot
console.log "Can't list rooms: #{err}"
bot.onError (message, stanza)->
console.log "Received error from HipChat:", message, stanza
- bot.onMessage RegExp('@'+@name,'i'), (channel, from, message)->
+ bot.onMessage RegExp(mention,'i'), (channel, from, message)->
author = self.userForName(from)
author.room = channel
console.log "#{from}@#{channel}: #{message}"
- hubot_msg=message.replace(RegExp("@#{self.name}",'i'),"#{self.name}: ")
+ hubot_msg=message.replace(RegExp(mention,'i'),"#{self.name}: ")
self.receive new Robot.Message(author, hubot_msg)
bot.onPrivateMessage (from, message)=>
author = self.userForId(from.match(/_(\d+)@/)[1])

0 comments on commit 79df1b9

Please sign in to comment.