itd-sdk 2.4.4__tar.gz → 2.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/PKG-INFO +47 -44
  2. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/README.md +41 -40
  3. itd_sdk-2.5.0/itd/__init__.py +65 -0
  4. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/comments.py +5 -4
  5. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/hashtags.py +11 -4
  6. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/notifications.py +2 -2
  7. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/posts.py +11 -10
  8. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/users.py +25 -18
  9. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/base.py +49 -51
  10. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/clan.py +2 -3
  11. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/client.py +123 -61
  12. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/comment.py +81 -76
  13. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/file.py +7 -4
  14. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/hashtag.py +25 -15
  15. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/notification.py +14 -13
  16. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/pin.py +3 -2
  17. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/poll.py +4 -3
  18. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/post.py +52 -37
  19. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/report.py +6 -2
  20. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/request.py +4 -4
  21. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/session.py +7 -4
  22. itd_sdk-2.5.0/itd/span.py +22 -0
  23. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/user.py +137 -78
  24. itd_sdk-2.5.0/itd/utils.py +128 -0
  25. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/version.py +2 -1
  26. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/pyproject.toml +5 -3
  27. itd_sdk-2.4.4/itd/__init__.py +0 -14
  28. itd_sdk-2.4.4/itd/span.py +0 -10
  29. itd_sdk-2.4.4/itd/utils.py +0 -210
  30. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/_default.py +0 -0
  31. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/__init__.py +0 -0
  32. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/auth.py +0 -0
  33. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/dwell.py +0 -0
  34. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/etc.py +0 -0
  35. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/files.py +0 -0
  36. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/pins.py +0 -0
  37. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/platform.py +0 -0
  38. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/polls.py +0 -0
  39. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/reports.py +0 -0
  40. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/search.py +0 -0
  41. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/sessions.py +0 -0
  42. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/subscription.py +0 -0
  43. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/api/verification.py +0 -0
  44. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/enums.py +0 -0
  45. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/exceptions.py +1 -1
  46. {itd_sdk-2.4.4 → itd_sdk-2.5.0}/itd/logger.py +0 -0
@@ -1,19 +1,21 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: itd-sdk
3
- Version: 2.4.4
3
+ Version: 2.5.0
4
4
  Summary: ITD client for python
5
5
  Keywords: itd,itdsocial
6
- Author: firedotguy
7
- Author-email: firedotguy <nta16022013@gmail.com>
6
+ Author: fi-res
7
+ Author-email: fi-res <nta16022013@gmail.com>
8
8
  License-Expression: MIT
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Natural Language :: Russian
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Framework :: Pydantic :: 2
14
- Requires-Dist: requests~=2.32.5
14
+ Requires-Dist: requests>=2.32.5,<2.35.0
15
15
  Requires-Dist: pydantic>=2.12.5,<2.14.0
16
16
  Requires-Dist: sseclient-py~=1.9.0
17
+ Requires-Dist: telegramify-markdown>=0.5.4
18
+ Requires-Dist: lxml>=6.1.1
17
19
  Requires-Dist: dateparser>=1.2.2 ; extra == 'date'
18
20
  Requires-Dist: filetype>=1.2.0 ; extra == 'filetype'
19
21
  Requires-Dist: rich>=15.0.0 ; extra == 'logs'
@@ -26,43 +28,56 @@ Provides-Extra: logs
26
28
  Description-Content-Type: text/markdown
27
29
 
28
30
  # itd-sdk
29
- Клиент ITD для python
30
- Документация (beta): https://itdsdk.qzz.io/docs
31
+
32
+ [![ncruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/fi-res/ncruff)
33
+
34
+ SDK для работы с [https://xn--d1ah4a.com](итд.com) на python.
35
+
36
+ Документация: https://itdsdk.qzz.io/docs (wip)
31
37
 
32
38
  ## Установка
33
39
 
34
40
  ```bash
35
- pip install itd-sdk
41
+ uv add itd-sdk
36
42
  ```
37
43
 
38
- ## Пример
39
-
40
- ```python
41
- from itd import ITDClient, Me
44
+ или через pip:
42
45
 
43
- c = ITDClient('token')
44
- print(Me())
46
+ ```bash
47
+ pip install itd-sdk
45
48
  ```
46
- <!--
47
- > [!NOTE]
48
- > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
49
- > ![cookie](cookie-screen.png) -->
50
49
 
51
- ### Получение cookies
50
+ ## Вход
51
+
52
+ Сейчас есть 3 способа авторизации в SDK:
52
53
 
53
- Для получения access_token требуются cookies с `refresh_token`. Как их получить:
54
+ 1. Без авторизации. Доступен поиск и хэштэги.
55
+ 2. Авторизация через `access_token`. Доступны все запросы кроме тех, которые связаны с авторизацией. Токен действует 15 минут.
56
+ 3. Авторизация через `refresh_token`. Доступны все запросы. Токен действует 7 дней.
57
+
58
+ ### Получение `refresh_token`
54
59
 
55
60
  1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
56
- 2. Откройте DevTools (F12)
57
- 3. Перейдите на вкладку **Network**
61
+ 2. Откройте DevTools (<kbd>F12</kbd>)
62
+ 3. Перейдите на вкладку **"Network"** \ **"Сеть"**
58
63
  4. Обновите страницу
59
- 5. Найдите запрос к `/auth/refresh`
60
- 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
64
+ 5. Найдите запрос к `/v1/auth/refresh`
65
+ 6. Скопируйте значение **refresh_token** из **Cookies** \ **Куки**
66
+
67
+ ![token](get-rtoken.png)
68
+
69
+ ### Получение `access_token`
61
70
 
62
- ![cookie](cookie-screen.png)
71
+ 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
72
+ 2. Откройте DevTools (<kbd>F12</kbd>)
73
+ 3. Перейдите на вкладку **"Network"** \ **"Сеть"**
74
+ 4. Откройте любой запрос (если запросов нету, подождите 1-3сек - итд постоянно посылает запросы на обновление статистики постов)
75
+ 5. Скопируйте значение **authozation** из **Request headers** \ **Заголовки запроса**
63
76
 
77
+ ![token](get-atoken.png)
64
78
 
65
79
  ## API
80
+
66
81
  ```python
67
82
  from itd import Me, User, Post, Posts, File, Hashtag, Notifications
68
83
 
@@ -75,6 +90,7 @@ user.follow()
75
90
  post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
76
91
  post.like()
77
92
  post.add_comment('тест комент 6 7')
93
+ Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
78
94
 
79
95
  posts = Posts() # получить посты из ленты
80
96
  for i, post in enumerate(Posts()):
@@ -104,28 +120,15 @@ def on_like(notification):
104
120
  notifications.stop_stream()
105
121
  notifications.on_like = on_like
106
122
  stream = notifications.stream_bg() # background SSE
107
-
108
- Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
109
-
110
123
  ```
111
124
 
112
- ### Кастомные запросы
113
-
114
- ```python
115
- from itd.request import fetch
116
-
117
- fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
118
- ```
119
- Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
120
- К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
121
-
122
- > [!NOTE]
123
- > `xn--d1ah4a.com` - punycode от "итд.com"
125
+ Весь API - https://itdsdk.qzz.io/docs/
124
126
 
125
127
  ## Прочее
126
- - Лицезия: [MIT](./LICENSE)
127
- - Автор:
128
- - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
129
- - ТГ: [@desicars](https://t.me/desicars)
130
128
 
131
- [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
129
+ - Лицезия: [MIT](./LICENSE)
130
+ - Автор:
131
+ - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
132
+ - ТГ: [@desicars](https://t.me/desicars)
133
+
134
+ [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
@@ -1,41 +1,54 @@
1
1
  # itd-sdk
2
- Клиент ITD для python
3
- Документация (beta): https://itdsdk.qzz.io/docs
2
+
3
+ [![ncruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/fi-res/ncruff)
4
+
5
+ SDK для работы с [https://xn--d1ah4a.com](итд.com) на python.
6
+
7
+ Документация: https://itdsdk.qzz.io/docs (wip)
4
8
 
5
9
  ## Установка
6
10
 
7
11
  ```bash
8
- pip install itd-sdk
12
+ uv add itd-sdk
9
13
  ```
10
14
 
11
- ## Пример
12
-
13
- ```python
14
- from itd import ITDClient, Me
15
+ или через pip:
15
16
 
16
- c = ITDClient('token')
17
- print(Me())
17
+ ```bash
18
+ pip install itd-sdk
18
19
  ```
19
- <!--
20
- > [!NOTE]
21
- > Берите refresh_token из запроса /auth/refresh. В остальных запросах нету refresh_token
22
- > ![cookie](cookie-screen.png) -->
23
20
 
24
- ### Получение cookies
21
+ ## Вход
22
+
23
+ Сейчас есть 3 способа авторизации в SDK:
25
24
 
26
- Для получения access_token требуются cookies с `refresh_token`. Как их получить:
25
+ 1. Без авторизации. Доступен поиск и хэштэги.
26
+ 2. Авторизация через `access_token`. Доступны все запросы кроме тех, которые связаны с авторизацией. Токен действует 15 минут.
27
+ 3. Авторизация через `refresh_token`. Доступны все запросы. Токен действует 7 дней.
28
+
29
+ ### Получение `refresh_token`
27
30
 
28
31
  1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
29
- 2. Откройте DevTools (F12)
30
- 3. Перейдите на вкладку **Network**
32
+ 2. Откройте DevTools (<kbd>F12</kbd>)
33
+ 3. Перейдите на вкладку **"Network"** \ **"Сеть"**
31
34
  4. Обновите страницу
32
- 5. Найдите запрос к `/auth/refresh`
33
- 6. Скопируйте значение **refresh_token** из **Cookie** из Request Headers
35
+ 5. Найдите запрос к `/v1/auth/refresh`
36
+ 6. Скопируйте значение **refresh_token** из **Cookies** \ **Куки**
37
+
38
+ ![token](get-rtoken.png)
39
+
40
+ ### Получение `access_token`
34
41
 
35
- ![cookie](cookie-screen.png)
42
+ 1. Откройте [итд.com](https://xn--d1ah4a.com) в браузере
43
+ 2. Откройте DevTools (<kbd>F12</kbd>)
44
+ 3. Перейдите на вкладку **"Network"** \ **"Сеть"**
45
+ 4. Откройте любой запрос (если запросов нету, подождите 1-3сек - итд постоянно посылает запросы на обновление статистики постов)
46
+ 5. Скопируйте значение **authozation** из **Request headers** \ **Заголовки запроса**
36
47
 
48
+ ![token](get-atoken.png)
37
49
 
38
50
  ## API
51
+
39
52
  ```python
40
53
  from itd import Me, User, Post, Posts, File, Hashtag, Notifications
41
54
 
@@ -48,6 +61,7 @@ user.follow()
48
61
  post = Post('725681ba-2aaa-42d8-87fb-490c0f44e162') # получить пост
49
62
  post.like()
50
63
  post.add_comment('тест комент 6 7')
64
+ Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
51
65
 
52
66
  posts = Posts() # получить посты из ленты
53
67
  for i, post in enumerate(Posts()):
@@ -77,28 +91,15 @@ def on_like(notification):
77
91
  notifications.stop_stream()
78
92
  notifications.on_like = on_like
79
93
  stream = notifications.stream_bg() # background SSE
80
-
81
- Post('02bcbba4-f365-4b98-9291-d0bc1fb36fe4').poll.vote('тест') # голосования в опросах
82
-
83
94
  ```
84
95
 
85
- ### Кастомные запросы
86
-
87
- ```python
88
- from itd.request import fetch
89
-
90
- fetch(c, 'метод', 'эндпоинт', {'данные': 'данные'})
91
- ```
92
- Из методов поддерживается `get`, `post`, `put` итд, которые есть в `requests`
93
- К названию эндпоинта добавляется домен итд и `api`, то есть в этом примере отправится `https://xn--d1ah4a.com/api/эндпоинт`.
94
-
95
- > [!NOTE]
96
- > `xn--d1ah4a.com` - punycode от "итд.com"
96
+ Весь API - https://itdsdk.qzz.io/docs/
97
97
 
98
98
  ## Прочее
99
- - Лицезия: [MIT](./LICENSE)
100
- - Автор:
101
- - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
102
- - ТГ: [@desicars](https://t.me/desicars)
103
99
 
104
- [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
100
+ - Лицезия: [MIT](./LICENSE)
101
+ - Автор:
102
+ - ИТД: [@itd_sdk](https://xn--d1ah4a.com/@itd_sdk) или [@fdg](https://xn--d1ah4a.com/@pingbot)
103
+ - ТГ: [@desicars](https://t.me/desicars)
104
+
105
+ [![Star History Chart](https://api.star-history.com/chart?repos=itd-sdk/itd-sdk&type=date&legend=top-left)](https://www.star-history.com/?repos=itd-sdk%2Fitd-sdk&type=date&legend=top-left)
@@ -0,0 +1,65 @@
1
+ # ###################### ####
2
+ #### ## ###################### ########
3
+ #### #### #### #### ####
4
+ #### ###### #### #### ####
5
+ #### ####### #### #### ####
6
+ #### ######### #### #### ####
7
+ #### ##### #### #### #### ####
8
+ #### ##### #### #### #### ####
9
+ #### ##### #### #### #### ####
10
+ ######### #### #### #### #### +---- +----\ | /
11
+ ####### #### #### ################################## | | | | /
12
+ ##### #### #### #################################### - +---+ | | ++
13
+ ### #### #### #### #### | | | | \
14
+ # #### ### #### #### ----+ +----/ | \
15
+ """
16
+ |]]]]<<<<<]]<<]]]]]]]]]]]]]]<<<<<]]
17
+
18
+ |]]]]<<<]]]]]]<<<<<]]<<<<<<<]]<]]
19
+
20
+ |]]]]<]]]]<]]]]<<<<<]]<<<<<<]]<<<]]
21
+
22
+ |]]]]]]<<<]]]]<<<<<]]<<<]]]]]]]]]]]]]]]]]]]]]]
23
+
24
+ |]]<<<<<]]]]<<<<<]]<<<]]<<<<<<<<]]
25
+ """
26
+
27
+ from importlib.metadata import version
28
+
29
+ __version__ = version("itd-sdk")
30
+
31
+ from itd.clan import Clan, TopClans
32
+ from itd.client import Client as ITDClient
33
+ from itd.client import Config as ITDConfig
34
+ from itd.file import File
35
+ from itd.hashtag import Hashtag, Hashtags
36
+ from itd.notification import Notifications
37
+ from itd.poll import NewPoll
38
+ from itd.post import HashtagPosts, LikedPosts, Post, Posts, UserPosts
39
+ from itd.session import Sessions
40
+ from itd.user import Me, User, Users, get_follow_status
41
+ from itd.version import Apps, Changelog
42
+
43
+ __all__ = [
44
+ 'Changelog',
45
+ 'Apps',
46
+ 'ITDClient',
47
+ 'ITDConfig',
48
+ 'Clan',
49
+ 'TopClans',
50
+ 'File',
51
+ 'Hashtag',
52
+ 'Hashtags',
53
+ 'Notifications',
54
+ 'Post',
55
+ 'Posts',
56
+ 'UserPosts',
57
+ 'HashtagPosts',
58
+ 'LikedPosts',
59
+ 'NewPoll',
60
+ 'Sessions',
61
+ 'User',
62
+ 'Me',
63
+ 'Users',
64
+ 'get_follow_status'
65
+ ]
@@ -1,9 +1,10 @@
1
1
  from __future__ import annotations
2
- from uuid import UUID
2
+
3
3
  from typing import TYPE_CHECKING
4
+ from uuid import UUID
4
5
 
5
6
  from itd.base import catch_errors, rate_limit
6
- from itd.exceptions import ValidationError, NotFoundError, AlreadyDeletedError, BannedWordError, ForbiddenError, RequiresSubscriptionError
7
+ from itd.exceptions import AlreadyDeletedError, BannedWordError, ForbiddenError, NotFoundError, RequiresSubscriptionError, ValidationError
7
8
 
8
9
  if TYPE_CHECKING:
9
10
  from itd.client import Client
@@ -62,5 +63,5 @@ def delete_comment(client: Client, comment_id: UUID):
62
63
 
63
64
  @rate_limit()
64
65
  @catch_errors(ValidationError(), NotFoundError('Comment'))
65
- def get_replies(client: Client, comment_id: UUID, page: int = 1, limit: int = 50, sort: str = 'oldest'):
66
- return client.request('get', f'comments/{comment_id}/replies', {'page': page, 'limit': limit, 'sort': sort})
66
+ def get_replies(client: Client, comment_id: UUID, page: int = 1, limit: int = 50):
67
+ return client.request('get', f'comments/{comment_id}/replies', {'page': page, 'limit': limit})
@@ -1,22 +1,29 @@
1
1
  from __future__ import annotations
2
- from uuid import UUID
2
+
3
3
  from typing import TYPE_CHECKING
4
+ from uuid import UUID
4
5
 
5
- from itd.exceptions import TooLargeError, NotFoundError
6
6
  from itd.base import catch_errors, rate_limit
7
7
  from itd.enums import AuthLevel
8
+ from itd.exceptions import NotFoundError, TooLargeError, ValidationError
8
9
 
9
10
  if TYPE_CHECKING:
10
11
  from itd.client import Client
11
12
 
12
13
 
13
14
  @rate_limit()
14
- @catch_errors()
15
+ @catch_errors(ValidationError())
16
+ def search_hashtags(client: Client, query: str, limit: int = 10):
17
+ return client.request('get', 'hashtags', {'q': query, 'limit': limit}, level=AuthLevel.NO)
18
+
19
+
20
+ @rate_limit()
21
+ @catch_errors(ValidationError())
15
22
  def get_hashtags(client: Client, limit: int = 10):
16
23
  return client.request('get', 'hashtags/trending', {'limit': limit}, level=AuthLevel.NO)
17
24
 
18
25
 
19
26
  @rate_limit()
20
- @catch_errors(TooLargeError('Hashtag'), NotFoundError('Hashtag', json_check=lambda json: json.get('data', {}).get('hashtag', '') is None))
27
+ @catch_errors(TooLargeError('Hashtag'), NotFoundError('Hashtag', json_check=lambda json: json.get('data', {}).get('hashtag', '') is None), ValidationError())
21
28
  def get_posts_by_hashtag(client: Client, hashtag: str, cursor: UUID | None = None, limit: int = 20):
22
29
  return client.request('get', f'hashtags/{hashtag}/posts', {'limit': limit, 'cursor': cursor}, level=AuthLevel.NO)
@@ -1,8 +1,8 @@
1
1
  from __future__ import annotations
2
- from uuid import UUID
2
+
3
3
  from typing import TYPE_CHECKING
4
+ from uuid import UUID
4
5
 
5
- from itd.request import fetch_stream
6
6
  from itd.base import catch_errors, rate_limit
7
7
  from itd.exceptions import NotFoundError
8
8
 
@@ -1,22 +1,23 @@
1
1
  from __future__ import annotations
2
+
2
3
  from datetime import datetime
3
- from uuid import UUID
4
4
  from typing import TYPE_CHECKING
5
+ from uuid import UUID
5
6
 
7
+ from itd.base import catch_errors, rate_limit
6
8
  from itd.enums import PostsTab, UserPostSorting
7
- from itd.poll import NewPoll
8
9
  from itd.exceptions import (
9
- NotFoundError,
10
- ForbiddenError,
11
- RequiresSubscriptionError,
12
- ValidationError,
13
10
  AlreadyRepostedError,
11
+ BannedWordError,
14
12
  CantRepostYourselfError,
15
- NotPinnedError,
16
13
  EditExpiredError,
17
- BannedWordError
14
+ ForbiddenError,
15
+ NotFoundError,
16
+ NotPinnedError,
17
+ RequiresSubscriptionError,
18
+ ValidationError
18
19
  )
19
- from itd.base import rate_limit, catch_errors
20
+ from itd.poll import NewPoll
20
21
 
21
22
  if TYPE_CHECKING:
22
23
  from itd.client import Client
@@ -54,7 +55,7 @@ def create_post(
54
55
  @rate_limit()
55
56
  @catch_errors(ValidationError())
56
57
  def get_posts(client: Client, cursor: str | datetime | None = None, limit: int = 20, tab: PostsTab = PostsTab.POPULAR):
57
- data = {'limit': limit, 'tab': tab.value}
58
+ data: dict = {'limit': limit, 'tab': tab.value}
58
59
  if cursor is not None:
59
60
  data['cursor'] = cursor
60
61
  return client.request('get', 'posts', data)
@@ -1,25 +1,26 @@
1
1
  from __future__ import annotations
2
- from uuid import UUID
2
+
3
3
  from typing import TYPE_CHECKING
4
+ from uuid import UUID
4
5
 
5
- from itd.enums import Unset, UNSET, AccessType
6
+ from itd.base import catch_errors, rate_limit
7
+ from itd.enums import UNSET, AccessType, Unset
6
8
  from itd.exceptions import (
7
- NotFoundError,
8
- TooLargeError,
9
- ValidationError,
10
- RequiresVerificationError,
11
- UsernameTakenError,
12
- AlreadyFollowingError,
13
- AlreadyDeletedError,
14
- NotDeletedError,
15
9
  AlreadyBlockedError,
16
- NotBlockedError,
10
+ AlreadyDeletedError,
11
+ AlreadyFollowingError,
12
+ CantBlockYourselfError,
17
13
  CantFollowYourselfError,
14
+ NotBlockedError,
15
+ NotDeletedError,
16
+ NotFoundError,
17
+ RequiresVerificationError,
18
+ TargetUserBannedError,
19
+ TooLargeError,
18
20
  UserBlockedError,
19
- CantBlockYourselfError,
20
- TargetUserBannedError
21
+ UsernameTakenError,
22
+ ValidationError
21
23
  )
22
- from itd.base import catch_errors, rate_limit
23
24
 
24
25
  if TYPE_CHECKING:
25
26
  from itd.client import Client
@@ -93,14 +94,14 @@ def unfollow(client: Client, username_or_id: str | UUID):
93
94
 
94
95
  @rate_limit()
95
96
  @catch_errors(NotFoundError('User'), ValidationError(), TooLargeError('Username'), TargetUserBannedError())
96
- def get_followers(client: Client, username_or_id: str | UUID, page: int = 1): # !! page not works if not me
97
- return client.request('get', f'users/{username_or_id}/followers', {'page': page})
97
+ def get_followers(client: Client, username_or_id: str | UUID, page: int = 1, limit: int = 20): # !! page not works if not me
98
+ return client.request('get', f'users/{username_or_id}/followers', {'page': page, 'limit': limit})
98
99
 
99
100
 
100
101
  @rate_limit()
101
102
  @catch_errors(NotFoundError('User'), ValidationError(), TooLargeError('Username'), TargetUserBannedError())
102
- def get_following(client: Client, username_or_id: str | UUID, page: int = 1): # !! page not works if not me
103
- return client.request('get', f'users/{username_or_id}/following', {'page': page})
103
+ def get_following(client: Client, username_or_id: str | UUID, page: int = 1, limit: int = 20): # !! page not works if not me
104
+ return client.request('get', f'users/{username_or_id}/following', {'page': page, 'limit': limit})
104
105
 
105
106
 
106
107
  @rate_limit()
@@ -137,3 +138,9 @@ def get_blocked(client: Client, page: int = 1, limit: int = 20):
137
138
  @catch_errors()
138
139
  def get_follow_status(client: Client, user_ids: list[UUID]):
139
140
  return client.request('post', 'users/follow-status', {'userIds': list(map(str, user_ids))})
141
+
142
+
143
+ @rate_limit()
144
+ @catch_errors()
145
+ def search_users(client: Client, query: str, limit: int = 10):
146
+ return client.request('get', 'users/search', {'q': query, 'limit': limit})