diff --git a/README.md b/README.md index 5be7464..9a29c90 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ print(c.get_me()) --- ### Скрипт на обновление имени +Этот код сейчас работает на @itd_sdk (обновляется имя и пост) ```python from itd import ITDClient from time import sleep @@ -36,7 +37,8 @@ c = ITDClient(None, '...') while True: c.update_profile(display_name=f'PYTHON ITD SDK | Рандом: {randint(1, 100)} | {datetime.now().strftime("%m.%d %H:%M:%S")}') - c.edit_post('82ea8a4f-a49e-485e-b0dc-94d7da9df990', f'рил ща {datetime.now(timezone.utc).isoformat(" ")} по UTC (обновляется каждую секунду)') + # редактирование поста + # c.edit_post('82ea8a4f-a49e-485e-b0dc-94d7da9df990', f'рил ща {datetime.now(timezone.utc).isoformat(" ")} по UTC (обновляется каждую секунду)') sleep(1) ``` diff --git a/itd/client.py b/itd/client.py index c387dd5..7f49264 100644 --- a/itd/client.py +++ b/itd/client.py @@ -1,14 +1,17 @@ +from _io import BufferedReader +from typing import cast + from requests.exceptions import HTTPError -from itd.users import get_user, update_profile, follow, unfollow, get_followers, get_following -from itd.etc import get_top_clans, get_who_to_follow, get_platform_status -from itd.comments import get_comments, add_comment, delete_comment, like_comment, unlike_comment -from itd.hashtags import get_hastags, get_posts_by_hastag -from itd.notifications import get_notifications, mark_as_read, mark_all_as_read, get_unread_notifications_count -from itd.posts import create_post, get_posts, get_post, edit_post, delete_post, pin_post, repost, view_post -from itd.reports import report -from itd.search import search -from itd.files import upload_file +from itd.routes.users import get_user, update_profile, follow, unfollow, get_followers, get_following +from itd.routes.etc import get_top_clans, get_who_to_follow, get_platform_status +from itd.routes.comments import get_comments, add_comment, delete_comment, like_comment, unlike_comment +from itd.routes.hashtags import get_hastags, get_posts_by_hastag +from itd.routes.notifications import get_notifications, mark_as_read, mark_all_as_read, get_unread_notifications_count +from itd.routes.posts import create_post, get_posts, get_post, edit_post, delete_post, pin_post, repost, view_post +from itd.routes.reports import report +from itd.routes.search import search +from itd.routes.files import upload_file from itd.request import refresh_auth @@ -195,5 +198,9 @@ class Client: @refresh_on_error - def upload_file(self, name: str, data: bytes): - return upload_file(self.token, name, data) \ No newline at end of file + def upload_file(self, name: str, data: BufferedReader): + return upload_file(self.token, name, data) + + def update_banner(self, name: str): + id = self.upload_file(name, cast(BufferedReader, open(name, 'rb')))['id'] + return self.update_profile(banner_id=id) \ No newline at end of file diff --git a/itd/request.py b/itd/request.py index 8138cc7..742df91 100644 --- a/itd/request.py +++ b/itd/request.py @@ -1,9 +1,11 @@ +from _io import BufferedReader + from requests import Session s = Session() -def fetch(token: str, method: str, url: str, params: dict = {}, files: dict[str, tuple[str, bytes]] = {}): +def fetch(token: str, method: str, url: str, params: dict = {}, files: dict[str, tuple[str, BufferedReader]] = {}): base = f'https://xn--d1ah4a.com/api/{url}' headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", diff --git a/itd/comments.py b/itd/routes/comments.py similarity index 100% rename from itd/comments.py rename to itd/routes/comments.py diff --git a/itd/etc.py b/itd/routes/etc.py similarity index 100% rename from itd/etc.py rename to itd/routes/etc.py diff --git a/itd/files.py b/itd/routes/files.py similarity index 53% rename from itd/files.py rename to itd/routes/files.py index 6d4af1d..d13f48f 100644 --- a/itd/files.py +++ b/itd/routes/files.py @@ -1,5 +1,7 @@ +from _io import BufferedReader + from itd.request import fetch -def upload_file(token: str, name: str, data: bytes): +def upload_file(token: str, name: str, data: BufferedReader): return fetch(token, 'post', 'files/upload', files={'file': (name, data)}) \ No newline at end of file diff --git a/itd/hashtags.py b/itd/routes/hashtags.py similarity index 100% rename from itd/hashtags.py rename to itd/routes/hashtags.py diff --git a/itd/notifications.py b/itd/routes/notifications.py similarity index 100% rename from itd/notifications.py rename to itd/routes/notifications.py diff --git a/itd/posts.py b/itd/routes/posts.py similarity index 100% rename from itd/posts.py rename to itd/routes/posts.py diff --git a/itd/reports.py b/itd/routes/reports.py similarity index 100% rename from itd/reports.py rename to itd/routes/reports.py diff --git a/itd/search.py b/itd/routes/search.py similarity index 100% rename from itd/search.py rename to itd/routes/search.py diff --git a/itd/users.py b/itd/routes/users.py similarity index 100% rename from itd/users.py rename to itd/routes/users.py diff --git a/nowkie.gif b/nowkie.gif new file mode 100644 index 0000000..0f18b89 Binary files /dev/null and b/nowkie.gif differ