diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-01-28 20:38:18 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | b7a3eb918171ac2049dda68c1c1dda19a1319162 (patch) | |
tree | d465421cfe340060aa9d68b5d9369fb9eaacb5fa /slack | |
parent | a4e5f0612c09b337b85a83a18cf9127c6f814739 (diff) | |
download | wee-slack-b7a3eb918171ac2049dda68c1c1dda19a1319162.tar.gz |
Remove unnecessary id parameters
Diffstat (limited to 'slack')
-rw-r--r-- | slack/slack_user.py | 12 | ||||
-rw-r--r-- | slack/slack_workspace.py | 16 |
2 files changed, 11 insertions, 17 deletions
diff --git a/slack/slack_user.py b/slack/slack_user.py index 871c1ef..c2e4b23 100644 --- a/slack/slack_user.py +++ b/slack/slack_user.py @@ -43,15 +43,14 @@ def format_bot_nick(nick: str, colorize: bool = False) -> str: class SlackUser: - def __init__(self, workspace: SlackWorkspace, id: str, info: SlackUserInfo): + def __init__(self, workspace: SlackWorkspace, info: SlackUserInfo): self.workspace = workspace - self.id = id self._info = info @classmethod async def create(cls, workspace: SlackWorkspace, id: str): info_response = await workspace.api.fetch_user_info(id) - return cls(workspace, id, info_response["user"]) + return cls(workspace, info_response["user"]) @property def _api(self) -> SlackApi: @@ -72,7 +71,7 @@ class SlackUser: return name_from_user_info_without_spaces(self.workspace, self._info) def _nick_color(self) -> str: - if self.id == self.workspace.my_user.id: + if self._info["id"] == self.workspace.my_user._info["id"]: return weechat.config_string( weechat.config_get("weechat.color.chat_nick_self") ) @@ -81,15 +80,14 @@ class SlackUser: class SlackBot: - def __init__(self, workspace: SlackWorkspace, id: str, info: SlackBotInfo): + def __init__(self, workspace: SlackWorkspace, info: SlackBotInfo): self.workspace = workspace - self.id = id self._info = info @classmethod async def create(cls, workspace: SlackWorkspace, id: str): info_response = await workspace.api.fetch_bot_info(id) - return cls(workspace, id, info_response["bot"]) + return cls(workspace, info_response["bot"]) @property def _api(self) -> SlackApi: diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py index 39101d9..f044f8d 100644 --- a/slack/slack_workspace.py +++ b/slack/slack_workspace.py @@ -55,7 +55,7 @@ class SlackItem( ) -> SlackItemClass: if items_info_task: items_info = await items_info_task - return self._create_item_from_info(item_id, items_info[item_id]) + return self._create_item_from_info(items_info[item_id]) else: return await self._item_class.create(self.workspace, item_id) @@ -66,9 +66,7 @@ class SlackItem( raise NotImplementedError() @abstractmethod - def _create_item_from_info( - self, item_id: str, item_info: SlackItemInfo - ) -> SlackItemClass: + def _create_item_from_info(self, item_info: SlackItemInfo) -> SlackItemClass: raise NotImplementedError() @@ -82,10 +80,8 @@ class SlackUsers(SlackItem[SlackUser, SlackUserInfo]): response = await self.workspace.api.fetch_users_info(item_ids) return {info["id"]: info for info in response["users"]} - def _create_item_from_info( - self, item_id: str, item_info: SlackUserInfo - ) -> SlackUser: - return self._item_class(self.workspace, item_id, item_info) + def _create_item_from_info(self, item_info: SlackUserInfo) -> SlackUser: + return self._item_class(self.workspace, item_info) class SlackBots(SlackItem[SlackBot, SlackBotInfo]): @@ -98,8 +94,8 @@ class SlackBots(SlackItem[SlackBot, SlackBotInfo]): response = await self.workspace.api.fetch_bots_info(item_ids) return {info["id"]: info for info in response["bots"]} - def _create_item_from_info(self, item_id: str, item_info: SlackBotInfo) -> SlackBot: - return self._item_class(self.workspace, item_id, item_info) + def _create_item_from_info(self, item_info: SlackBotInfo) -> SlackBot: + return self._item_class(self.workspace, item_info) class SlackWorkspace: |