feat: add cant follow yourself error
This commit is contained in:
@@ -3,7 +3,7 @@ from _io import BufferedReader
|
||||
from requests import Session
|
||||
from requests.exceptions import JSONDecodeError
|
||||
|
||||
from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded
|
||||
from itd.exceptions import InvalidToken, InvalidCookie, RateLimitExceeded, Unauthorized
|
||||
|
||||
s = Session()
|
||||
|
||||
@@ -35,10 +35,13 @@ def fetch(token: str, method: str, url: str, params: dict = {}, files: dict[str,
|
||||
try:
|
||||
if res.json().get('error', {}).get('code') == 'RATE_LIMIT_EXCEEDED':
|
||||
raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0))
|
||||
if res.json().get('error', {}).get('code') == 'UNAUTHORIZED':
|
||||
raise Unauthorized()
|
||||
except JSONDecodeError:
|
||||
pass
|
||||
|
||||
print(res.text)
|
||||
if not res.ok:
|
||||
print(res.text)
|
||||
return res
|
||||
|
||||
|
||||
@@ -82,8 +85,10 @@ def auth_fetch(cookies: str, method: str, url: str, params: dict = {}, token: st
|
||||
try:
|
||||
if res.json().get('error', {}).get('code') == 'RATE_LIMIT_EXCEEDED':
|
||||
raise RateLimitExceeded(res.json()['error'].get('retryAfter', 0))
|
||||
if res.json().get('error', {}).get('code') in ('SESSION_NOT_FOUND', 'REFRESH_TOKEN_MISSING'):
|
||||
raise InvalidCookie()
|
||||
if res.json().get('error', {}).get('code') in ('SESSION_NOT_FOUND', 'REFRESH_TOKEN_MISSING', 'SESSION_REVOKED'):
|
||||
raise InvalidCookie(res.json()['error']['code'])
|
||||
if res.json().get('error', {}).get('code') == 'UNAUTHORIZED':
|
||||
raise Unauthorized()
|
||||
except JSONDecodeError:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user