diff --git a/machine/plugins/base.py b/machine/plugins/base.py index 359a8a9a..ae244818 100644 --- a/machine/plugins/base.py +++ b/machine/plugins/base.py @@ -64,6 +64,18 @@ def users(self) -> dict[str, User]: """ return self._client.users + @property + def users_by_email(self) -> dict[str, User]: + """Dictionary of all users in the Slack workspace by email + + **Note**: not every user might have an email address in their profile, so this + dictionary might not contain all users in the Slack workspace + + :return: a dictionary of all users in the Slack workspace, where the key is the email and + the value is a [`User`][machine.models.user.User] object + """ + return self._client.users + @property def channels(self) -> dict[str, Channel]: """List of all channels in the Slack workspace @@ -101,6 +113,22 @@ def find_channel_by_name(self, channel_name: str) -> Channel | None: return c return None + def get_user_by_id(self, user_id: str) -> User | None: + """Get a user by their ID. + + :param user_id: The ID of the user to retrieve. + :return: The user if found, None otherwise. + """ + return self.users.get(user_id) + + def get_user_by_email(self, email: str) -> User | None: + """Get a user by their email address. + + :param email: The email address of the user to retrieve. + :return: The user if found, None otherwise. + """ + return self._client.get_user_by_email(email) + @property def bot_info(self) -> dict[str, Any]: """Information about the bot user in Slack