fix: add BannedAccount error
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ __pycache__/
|
||||
dist
|
||||
itd_sdk.egg-info
|
||||
nowkie.gif
|
||||
g.gif
|
||||
@@ -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: Пост не найден
|
||||
|
||||
@@ -114,3 +114,7 @@ class NoContent(Exception):
|
||||
class AlreadyFollowing(Exception):
|
||||
def __str__(self) -> str:
|
||||
return 'Already following user'
|
||||
|
||||
class AccountBanned(Exception):
|
||||
def __str__(self) -> str:
|
||||
return 'Account has been deactivated'
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user