diff --git a/.gitignore b/.gitignore index 060af60..e4d0eb1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ venv/ __pycache__/ dist itd_sdk.egg-info -nowkie.gif \ No newline at end of file +nowkie.gif +g.gif \ No newline at end of file diff --git a/itd/client.py b/itd/client.py index 62f19bb..7105c0b 100644 --- a/itd/client.py +++ b/itd/client.py @@ -454,13 +454,13 @@ class Client: @refresh_on_error def get_replies(self, comment_id: UUID, limit: int = 50, page: int = 1, sort: str = 'oldest') -> tuple[list[Comment], Pagination]: - """Получить список комментариев + """Получить список ответов на комментарий Args: comment_id (UUID): UUID поста limit (int, optional): Лимит. Defaults to 50. page (int, optional): Курсор (сколько пропустить). Defaults to 1. - sort (str, optional): Сортировка. Defaults to 'oldesr'. + sort (str, optional): Сортировка. Defaults to 'oldest'. Raises: NotFound: Пост не найден diff --git a/itd/exceptions.py b/itd/exceptions.py index e8a8b51..376a30c 100644 --- a/itd/exceptions.py +++ b/itd/exceptions.py @@ -113,4 +113,8 @@ class NoContent(Exception): class AlreadyFollowing(Exception): def __str__(self) -> str: - return 'Already following user' \ No newline at end of file + return 'Already following user' + +class AccountBanned(Exception): + def __str__(self) -> str: + return 'Account has been deactivated' \ No newline at end of file diff --git a/itd/request.py b/itd/request.py index c634258..df888fc 100644 --- a/itd/request.py +++ b/itd/request.py @@ -3,7 +3,7 @@ from _io import BufferedReader from requests import Session from requests.exceptions import JSONDecodeError -from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized +from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized, AccountBanned s = Session() @@ -39,6 +39,8 @@ def fetch(token: str, method: str, url: str, params: dict = {}, files: dict[str, raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0)) if res.json().get('error', {}).get('code') == 'UNAUTHORIZED': raise Unauthorized() + if res.json().get('error', {}).get('code') == 'ACCOUNT_BANNED': + raise AccountBanned() except (JSONDecodeError, AttributeError): pass # todo