Octoslack icon indicating copy to clipboard operation
Octoslack copied to clipboard

RocketChat: only available for private groups

Open soundstorm opened this issue 4 years ago • 1 comments

It seems like rocket-python does implement the getRoomId function just for groups (endpoint /v1/groups.info, not /v1/rooms.info). I personally don't know why this should happen in a private group at all. So this should do it for public channels / private DMs:

if channel[0] == '#':
  public_channels = rc.get_public_channels()
  for public_channel in public_channels:
    if channel[1:] == public_channel['name']:
      rc_room_id = public_channel['id']
      break
  raise Exception("No matching channel found for "+channel)
elif channel[0] == '@':
  private_dms = rc.get_users()
  for private_dm in private_dms:
    if channel[1:] == private_dm['username']:
      rc_room_id = private_dm['id']
      break
  raise Exception("No matching user found for "+channel)
else: #backwards compatibility with no # or @ to post to groups
  rc_room_id = rc.get_room_id(channel) #groups

Will test and create a pull soon, just as reminder to myself.

Maybe a replacement of {octoprint_user} in the channel list would be handy to add DMs to @{octoprint_user}, but just a thought.

soundstorm avatar Jun 12 '20 22:06 soundstorm

Thanks for the PR @soundstorm - I'll look to review+integrate the PR in my next round of plugin updates.

fraschetti avatar Nov 20 '20 07:11 fraschetti