slack-bridge: Update processing of members list according to new API.

This commit is contained in:
rht 2020-07-24 23:59:49 -04:00 committed by Tim Abbott
parent 89d0dd56b9
commit 47a4f258d7

View file

@ -75,7 +75,7 @@ class SlackBridge:
def run_slack_listener(self) -> None: def run_slack_listener(self) -> None:
# spawn a non-websocket client for getting the users list # spawn a non-websocket client for getting the users list
_wc = slack.WebClient(token=self.slack_config["token"]) _wc = slack.WebClient(token=self.slack_config["token"])
members = _wc.users_list() members = _wc.users_list()['members']
# See also https://api.slack.com/changelog/2017-09-the-one-about-usernames # See also https://api.slack.com/changelog/2017-09-the-one-about-usernames
self.slack_id_to_name = {u["id"]: u["profile"].get("display_name", u["profile"]["real_name"]) for u in members} self.slack_id_to_name = {u["id"]: u["profile"].get("display_name", u["profile"]["real_name"]) for u in members}
self.slack_name_to_id = {v: k for k, v in self.slack_id_to_name.items()} self.slack_name_to_id = {v: k for k, v in self.slack_id_to_name.items()}