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

api_call should update server state in rtm mode #74

Merged
2 commits merged into from
Feb 28, 2016
Merged
Changes from 1 commit
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
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'], [])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both here and line 32 I think you should pass through the members attribute rather than an empty array or passing a None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was emulating the style of _client.py:SlackClient:process_changes, which also passes an empty. I'll update it, one moment.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not 100% familiar with the python client yet, so I think you should pass the members array, but that's not canon.

elif method in ('channels.create', 'channels.join'):
if 'ok' in result and result['ok']:
self.server.attach_channel(result['channel']['name'], result['channel']['id'])
return result

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