Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 21af060

Browse files
committed
rebase of diff complete
1 parent f9f2fd5 commit 21af060

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

rtmbot/core.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,19 @@ def output(self):
116116
for plugin in self.bot_plugins:
117117
limiter = False
118118
for output in plugin.do_output():
119-
channel = self.slack_client.server.channels.find(output[0])
120-
if channel is not None and output[1] is not None:
119+
destination = output[0]
120+
message = output[1]
121+
# things that start with U are users. convert to an IM channel.
122+
if destination.startswith('U'):
123+
result = json.loads(self.slack_client.api_call('im.open', user=destination))
124+
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
125+
else:
126+
channel = self.slack_client.server.channels.find(destination)
127+
if channel != None and message != None:
121128
if limiter:
122129
time.sleep(.1)
123130
limiter = False
124-
channel.send_message(output[1])
131+
channel.send_message(message)
125132
limiter = True
126133

127134
def crons(self):

0 commit comments

Comments
 (0)