Skip to content

Commit

Permalink
Merge pull request hubotio#141 from cadwallion/irc_user_compat
Browse files Browse the repository at this point in the history
Update IrcAdapter to handle userState for brain
  • Loading branch information
Tom Bell committed Nov 2, 2011
2 parents 5b5ae7f + 6721eab commit 4c1bab0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hubot/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ class IrcBot extends Robot

bot.addListener 'message', (from, to, message) ->
console.log "From #{from} to #{to}: #{message}"

user = self.userForName from
unless user?
id = (new Date().getTime() / 1000).toString().replace('.','')
user = self.userForId id
user.name = from

if message.match new RegExp "^#{options.nick}", "i"
unless user_id[from]
user_id[from] = next_id
next_id = next_id + 1

user = new Robot.User user_id[from]
user.name = from
if to.match(/^[&#]/)
user.room = to
console.log "#{to} <#{from}> #{message}"
else
user.room = null
console.log "msg <#{from}> #{message}"

self.receive new Robot.TextMessage(user, message)
Expand Down

0 comments on commit 4c1bab0

Please sign in to comment.