Skip to content

Commit

Permalink
Index users by ID instead of name (#156)
Browse files Browse the repository at this point in the history
* Index users by ID instead of name
  • Loading branch information
Roach committed Jan 19, 2017
1 parent 6ab243f commit 4b7f996
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions slackclient/_server.py
Expand Up @@ -151,8 +151,8 @@ def websocket_safe_read(self):
raise
return data.rstrip()

def attach_user(self, name, channel_id, real_name, tz):
self.users.update({name: User(self, name, channel_id, real_name, tz)})
def attach_user(self, name, user_id, real_name, tz):
self.users.update({user_id: User(self, name, user_id, real_name, tz)})

def attach_channel(self, name, channel_id, members=None):
if members is None:
Expand Down
8 changes: 4 additions & 4 deletions slackclient/_util.py
Expand Up @@ -19,12 +19,12 @@ def find(self, name):

class SearchDict(dict):
def find(self, search_string):
# Find the user by name
# Find the user by ID
user = self.get(search_string)
if user:
return user
else:
# If the user can't be found by name, try searching by ID
for name, user in self.items():
if str(user.id) == search_string:
# If the user can't be found by ID, try searching by name
for id, user in self.items():
if str(user.name) == search_string:
return user

0 comments on commit 4b7f996

Please sign in to comment.