Skip to content

Commit

Permalink
Merge pull request slackapi#74 from elementc/fix-send-messages
Browse files Browse the repository at this point in the history
api_call should update server state in rtm mode
  • Loading branch information
Christo Goosen authored and committed-name committed Feb 28, 2016
2 parents f3214cd + 063f82b commit 57cac1e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion slackclient/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ def rtm_connect(self):
return False

def api_call(self, method, **kwargs):
return self.server.api_call(method, **kwargs)
result = json.loads(self.server.api_call(method, **kwargs))
if self.server:
if method == 'im.open':
if "ok" in result and result["ok"]:
self.server.attach_channel(kwargs["user"], result["channel"]["id"])
elif method in ('mpim.open', 'groups.create', 'groups.createchild'):
if "ok" in result and result["ok"]:
self.server.attach_channel(result['group']['name'], result['group']['id'], result['group']['members'])
elif method in ('channels.create', 'channels.join'):
if 'ok' in result and result['ok']:
self.server.attach_channel(result['channel']['name'], result['channel']['id'], result['channel']['members'])
return result

def rtm_read(self):
# in the future, this should handle some events internally i.e. channel
Expand Down

0 comments on commit 57cac1e

Please sign in to comment.