fix: add BannedAccount error

This commit is contained in:
firedotguy
2026-02-12 18:25:25 +03:00
parent 7cc343dab5
commit c1042d32ae
4 changed files with 12 additions and 5 deletions

3
.gitignore vendored
View File

@@ -4,4 +4,5 @@ venv/
__pycache__/ __pycache__/
dist dist
itd_sdk.egg-info itd_sdk.egg-info
nowkie.gif nowkie.gif
g.gif

View File

@@ -454,13 +454,13 @@ class Client:
@refresh_on_error @refresh_on_error
def get_replies(self, comment_id: UUID, limit: int = 50, page: int = 1, sort: str = 'oldest') -> tuple[list[Comment], Pagination]: def get_replies(self, comment_id: UUID, limit: int = 50, page: int = 1, sort: str = 'oldest') -> tuple[list[Comment], Pagination]:
"""Получить список комментариев """Получить список ответов на комментарий
Args: Args:
comment_id (UUID): UUID поста comment_id (UUID): UUID поста
limit (int, optional): Лимит. Defaults to 50. limit (int, optional): Лимит. Defaults to 50.
page (int, optional): Курсор (сколько пропустить). Defaults to 1. page (int, optional): Курсор (сколько пропустить). Defaults to 1.
sort (str, optional): Сортировка. Defaults to 'oldesr'. sort (str, optional): Сортировка. Defaults to 'oldest'.
Raises: Raises:
NotFound: Пост не найден NotFound: Пост не найден

View File

@@ -113,4 +113,8 @@ class NoContent(Exception):
class AlreadyFollowing(Exception): class AlreadyFollowing(Exception):
def __str__(self) -> str: def __str__(self) -> str:
return 'Already following user' return 'Already following user'
class AccountBanned(Exception):
def __str__(self) -> str:
return 'Account has been deactivated'

View File

@@ -3,7 +3,7 @@ from _io import BufferedReader
from requests import Session from requests import Session
from requests.exceptions import JSONDecodeError from requests.exceptions import JSONDecodeError
from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized, AccountBanned
s = Session() 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)) raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0))
if res.json().get('error', {}).get('code') == 'UNAUTHORIZED': if res.json().get('error', {}).get('code') == 'UNAUTHORIZED':
raise Unauthorized() raise Unauthorized()
if res.json().get('error', {}).get('code') == 'ACCOUNT_BANNED':
raise AccountBanned()
except (JSONDecodeError, AttributeError): except (JSONDecodeError, AttributeError):
pass # todo pass # todo