Currently, retrieving DMs with a given username requires several actions: first get the current user's ID; list all users and find the ID of the username; then scan all DM conversations and find the one with the current user's ID and the username's ID, to finally retrieve the messages using that conversation ID. This tool abstracts all that in a single call. PS: we'll implement a similar tool for multi-person DM conversations in a subsequent PR.
29 lines
953 B
Python
29 lines
953 B
Python
class SlackToolkitError(Exception):
|
|
"""Base class for all Slack toolkit errors."""
|
|
|
|
|
|
class PaginationTimeoutError(SlackToolkitError):
|
|
"""Raised when a timeout occurs during pagination."""
|
|
|
|
def __init__(self, timeout_seconds: int):
|
|
self.timeout_seconds = timeout_seconds
|
|
super().__init__(f"The pagination process timed out after {timeout_seconds} seconds.")
|
|
|
|
|
|
class ItemNotFoundError(SlackToolkitError):
|
|
"""Raised when an item is not found."""
|
|
|
|
|
|
class UsernameNotFoundError(SlackToolkitError):
|
|
"""Raised when a user is not found by the username searched"""
|
|
|
|
def __init__(self, usernames_found: list[str]) -> None:
|
|
self.usernames_found = usernames_found
|
|
|
|
|
|
class ConversationNotFoundError(SlackToolkitError):
|
|
"""Raised when a conversation is not found"""
|
|
|
|
|
|
class DirectMessageConversationNotFoundError(ConversationNotFoundError):
|
|
"""Raised when a direct message conversation searched is not found"""
|