Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to post to channels/users for RocketChat #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion octoprint_Octoslack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4240,7 +4240,25 @@ def send_slack_message(
##def send_message(self, message, room_id, **kwargs):
##def upload_file(self, room_id, description, file, message, mime_type='text/plain', **kwargs):

rc_room_id = rc.get_room_id(channel)
rc_room_id = None
if channel[0] == "#":
public_channels = rc.get_public_rooms()
for public_channel in public_channels:
if channel[1:] == public_channel["name"]:
rc_room_id = public_channel["id"]
break
if rc_room_id is None:
raise Exception("No matching channel found for " + channel[1:])
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
if rc_room_id is None:
raise Exception("No matching user found for " + channel[1:])
else: #backwards compatibility with no # or @ to post to groups
rc_room_id = rc.get_room_id(channel) #groups
self._logger.debug(
"Rocket.Chat channel: "
+ channel
Expand Down