hubot-archive / hubot-tell

Hubot plugin to send a user a message the next time they are present in the room
MIT License
26 stars 15 forks source link

Make hubot-tell work with Hipchat #2

Closed sneat closed 9 years ago

sneat commented 9 years ago

In Hipchat, the msg.message.user.room value referenced in robot.enter is different to the msg.message.user.room value referenced in robot.respond.

robot.respond receives a packet like:

{ reply_to: '12345_stuff@conf.hipchat.com', room: 'stuff' }

whereas robot.enter receives just the '12345_stuff@conf.hipchat.com' style room name.

This PR makes the script store against the '12345_stuff@conf.hipchat.com' style room name.

lorenzhs commented 9 years ago

Ugh, thanks. Not quite sure but shouldn't the condition read if msg.message.user.reply_to? then (with a question mark?). @xhochy, my coffeescript is getting rusty, can you check this please? Or maybe something like msg.message.user.reply_to || msg.message.user.room or whatever that would look like in CoffeeScript...

sneat commented 9 years ago

Possibly. My coffeescript isn't great, so I was just doing a ternary.

xhochy commented 9 years ago

Yep || works here as we access entries of an object.

parkr commented 8 years ago

This seems to break hubot-slack. The reply_to is like C02EKKBLG instead of devops so looking up the room fails.

lorenzhs commented 8 years ago

Yikes. Seems like either HipChat or Slack is ignoring the hubot spec somewhere (or it's rubbery enough to allow broken behaviour like this...) - but why on earth would reply_to have a value to which you can't reply? That seems plain broken to me.

parkr commented 8 years ago

Yikes. Seems like either HipChat or Slack is ignoring the hubot spec somewhere (or it's rubbery enough to allow broken behaviour like this...) - but why on earth would reply_to have a value to which you can't reply? That seems plain broken to me.

The reply_to value overrides the room name. The reply_to seems to encode both the room and the user sending the message so it changes per user. When the enter hook is triggered, it looks up the room name with no reply_to, which would, of course look different. So the flow is:

  1. Receive a message in #devops that matches regexp for telling.
  2. Extract reply_to (C02EKKBLG) and username (parkr)
  3. Save message to localstorage["C02EKKBLG"]["parkr"].
  4. Later, parkr enters #devops. Receive EnterMessage with room devops and username parkr.
  5. Look up localstorate["devops"]["parkr"], but nothing is there.
lorenzhs commented 8 years ago

Yeah I see what's happening in the case of Slack, I'm just wondering whether it's the hubot plugin for Slack or for HipChat that's misbehaving here, because apparently in HipChat it's exactly the other way around.