libapitelethon 1.0__py3-none-any.whl
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.
- libapitelethon/__init__.py +6 -0
- libapitelethon/client/__init__.py +0 -0
- libapitelethon/client/api_telethon.py +77 -0
- libapitelethon/exceptions.py +2 -0
- libapitelethon/integrations/__init__.py +0 -0
- libapitelethon/models/__init__.py +8 -0
- libapitelethon/models/dict_user.py +62 -0
- libapitelethon/models/dict_user_aiogram.py +23 -0
- libapitelethon/py.typed +0 -0
- libapitelethon/types/__init__.py +10 -0
- libapitelethon/types/user_id.py +5 -0
- libapitelethon/types/user_id_or_username.py +8 -0
- libapitelethon/types/user_username.py +5 -0
- libapitelethon-1.0.dist-info/METADATA +28 -0
- libapitelethon-1.0.dist-info/RECORD +16 -0
- libapitelethon-1.0.dist-info/WHEEL +4 -0
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Literal, TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from ..types import UserId, UserUsername, UserIdOrUsername
|
|
6
|
+
from ..models import DictUser, DictUserAiogram
|
|
7
|
+
|
|
8
|
+
from aiohttp import ClientSession
|
|
9
|
+
|
|
10
|
+
from ..exceptions import ApiTelethonException
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ApiTelethon:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
protocol: Literal['http', 'https'] = 'http',
|
|
17
|
+
url: str = '127.0.0.1:8000'
|
|
18
|
+
) -> None:
|
|
19
|
+
self._url: str = protocol + '://' + url.rstrip('/') + '/'
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def _url_user(self) -> str:
|
|
23
|
+
return f'{self._url}user/'
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def _handle_error(data: dict) -> None:
|
|
27
|
+
error_message: str = ''
|
|
28
|
+
|
|
29
|
+
if 'error' in data['detail']:
|
|
30
|
+
error_message = data['detail']['error']['message']
|
|
31
|
+
else:
|
|
32
|
+
error_message = data['detail'][0]['msg']
|
|
33
|
+
|
|
34
|
+
raise ApiTelethonException(error_message)
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def _return_data(data: dict) -> dict:
|
|
38
|
+
if 'result' in data:
|
|
39
|
+
return data['result']
|
|
40
|
+
return data
|
|
41
|
+
|
|
42
|
+
async def _request(self, url: str) -> dict:
|
|
43
|
+
async with ClientSession() as session:
|
|
44
|
+
async with session.get(url) as response:
|
|
45
|
+
data = await response.json()
|
|
46
|
+
|
|
47
|
+
if response.status != 200:
|
|
48
|
+
self._handle_error(data)
|
|
49
|
+
|
|
50
|
+
return self._return_data(data)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def ping(self) -> bool:
|
|
54
|
+
url: str = self._url
|
|
55
|
+
return await self._request(url)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def get_user(self, uid: UserIdOrUsername) -> DictUser:
|
|
59
|
+
url: str = self._url_user + str(uid)
|
|
60
|
+
return await self._request(url)
|
|
61
|
+
|
|
62
|
+
async def get_user_aiogram(self, uid: UserIdOrUsername) -> DictUserAiogram:
|
|
63
|
+
url: str = self._url_user + str(uid) + '/aiogram'
|
|
64
|
+
return await self._request(url)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async def get_user_id(self, username: UserUsername) -> UserId:
|
|
68
|
+
url: str = self._url_user + username + '/id'
|
|
69
|
+
return await self._request(url)
|
|
70
|
+
|
|
71
|
+
async def get_user_username(self, id: UserId) -> UserUsername:
|
|
72
|
+
url: str = self._url_user + str(id) + '/username'
|
|
73
|
+
return await self._request(url)
|
|
74
|
+
|
|
75
|
+
async def get_user_usernames(self, uid: UserIdOrUsername) -> list[UserUsername]:
|
|
76
|
+
url: str = self._url_user + str(uid) + '/usernames'
|
|
77
|
+
return await self._request(url)
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import TypedDict, NotRequired
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class _Status(TypedDict):
|
|
6
|
+
type: str
|
|
7
|
+
expires: NotRequired[float]
|
|
8
|
+
was_online: NotRequired[float]
|
|
9
|
+
by_me: NotRequired[bool]
|
|
10
|
+
|
|
11
|
+
class DictUser(TypedDict):
|
|
12
|
+
id: int
|
|
13
|
+
is_self: bool | None
|
|
14
|
+
contact: bool | None
|
|
15
|
+
mutual_contact: bool | None
|
|
16
|
+
deleted: bool | None
|
|
17
|
+
bot: bool | None
|
|
18
|
+
bot_chat_history: bool | None
|
|
19
|
+
bot_nochats: bool | None
|
|
20
|
+
verified: bool | None
|
|
21
|
+
restricted: bool | None
|
|
22
|
+
min: bool | None
|
|
23
|
+
bot_inline_geo: bool | None
|
|
24
|
+
support: bool | None
|
|
25
|
+
scam: bool | None
|
|
26
|
+
apply_min_photo: bool | None
|
|
27
|
+
fake: bool | None
|
|
28
|
+
bot_attach_menu: bool | None
|
|
29
|
+
premium: bool | None
|
|
30
|
+
attach_menu_enabled: bool | None
|
|
31
|
+
bot_can_edit: bool | None
|
|
32
|
+
close_friend: bool | None
|
|
33
|
+
stories_hidden: bool | None
|
|
34
|
+
stories_unavailable: bool | None
|
|
35
|
+
contact_require_premium: bool | None
|
|
36
|
+
bot_business: bool | None
|
|
37
|
+
bot_has_main_app: bool | None
|
|
38
|
+
bot_forum_view: bool | None
|
|
39
|
+
bot_forum_can_manage_topics: bool | None
|
|
40
|
+
bot_can_manage_bots: bool | None
|
|
41
|
+
bot_guestchat: bool | None
|
|
42
|
+
bot_guard: bool | None
|
|
43
|
+
access_hash: int | None
|
|
44
|
+
first_name: str | None
|
|
45
|
+
last_name: str | None
|
|
46
|
+
username: str | None
|
|
47
|
+
phone: str | None
|
|
48
|
+
photo: int | None
|
|
49
|
+
status: _Status | None
|
|
50
|
+
bot_info_version: int | None
|
|
51
|
+
restriction_reason: list[str] | None
|
|
52
|
+
bot_inline_placeholder: str | None
|
|
53
|
+
lang_code: str | None
|
|
54
|
+
emoji_status: int | None
|
|
55
|
+
usernames: list[str] | None
|
|
56
|
+
stories_max_id: int | None
|
|
57
|
+
color: list[int] | None
|
|
58
|
+
profile_color: int | None
|
|
59
|
+
bot_active_users: int | None
|
|
60
|
+
bot_verification_icon: int | None
|
|
61
|
+
send_paid_messages_stars: int | None
|
|
62
|
+
linked_community_id: int | None
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import TypedDict
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DictUserAiogram(TypedDict):
|
|
6
|
+
id: int
|
|
7
|
+
is_bot: bool
|
|
8
|
+
first_name: str
|
|
9
|
+
last_name: str | None
|
|
10
|
+
username: str | None
|
|
11
|
+
language_code: str | None
|
|
12
|
+
is_premium: bool | None
|
|
13
|
+
added_to_attachment_menu: bool | None
|
|
14
|
+
can_join_groups: bool | None
|
|
15
|
+
can_read_all_group_messages: bool | None
|
|
16
|
+
supports_guest_queries: bool | None
|
|
17
|
+
supports_inline_queries: bool | None
|
|
18
|
+
can_connect_to_business: bool | None
|
|
19
|
+
has_main_web_app: bool | None
|
|
20
|
+
has_topics_enabled: bool | None
|
|
21
|
+
allows_users_to_create_topics: bool | None
|
|
22
|
+
can_manage_bots: bool | None
|
|
23
|
+
supports_join_request_queries: bool | None
|
libapitelethon/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: libapitelethon
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: Асинхронный клиент для https://codeberg.org/ourempirecommunity/api_telethon
|
|
5
|
+
Keywords: telegram,api,async,client
|
|
6
|
+
Author: ibrvtk
|
|
7
|
+
Author-email: ibrvtk <nicecock@disroot.org>
|
|
8
|
+
License: GPL-3.0-or-later
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Dist: aiohttp
|
|
17
|
+
Requires-Dist: aiogram>=3.0.0 ; extra == 'aiogram'
|
|
18
|
+
Requires-Dist: telethon>=1.30.0 ; extra == 'telethon'
|
|
19
|
+
Requires-Python: >=3.14
|
|
20
|
+
Project-URL: Homepage, https://codeberg.org/ourempirecommunity/libapitelethon
|
|
21
|
+
Project-URL: Repository, https://codeberg.org/ourempirecommunity/libapitelethon
|
|
22
|
+
Project-URL: Issues, https://codeberg.org/ourempirecommunity/libapitelethon/issues
|
|
23
|
+
Provides-Extra: aiogram
|
|
24
|
+
Provides-Extra: telethon
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# libapitelethon
|
|
28
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
libapitelethon/__init__.py,sha256=5TCykhShiYi3E0B8RYAMwpkZMcm403QiVMpAlLfol6I,91
|
|
2
|
+
libapitelethon/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
libapitelethon/client/api_telethon.py,sha256=eniXzjsfu_0Oq5tZMxIIkrJcpSo8xePrBp-JVOtQE4I,2335
|
|
4
|
+
libapitelethon/exceptions.py,sha256=uGbxZr9TogrogiUJ8AflZJy4xhgcwuFyfECuLWEQNTs,47
|
|
5
|
+
libapitelethon/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
libapitelethon/models/__init__.py,sha256=HL49Pin1bpnXpoV9ZQlaqpIQyAX_6BL2JzYEOJ8kN6s,145
|
|
7
|
+
libapitelethon/models/dict_user.py,sha256=6TgNIqjvXXga1tYjvRM_qpcp_SuF1prTznc9QvNgwQs,1769
|
|
8
|
+
libapitelethon/models/dict_user_aiogram.py,sha256=tVnilYnrdcwK7sir5l-89FYQh2IBT6wDCLQ6xMvGwkM,696
|
|
9
|
+
libapitelethon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
libapitelethon/types/__init__.py,sha256=9ReYsrPQ9XQfdKETtUW4nIEJR-ZxthPfj7rZUmXrqrE,203
|
|
11
|
+
libapitelethon/types/user_id.py,sha256=_6eB786DJAgfQMZzsWa2tsNU3zP09BQaXaxGX6TZ_Vs,89
|
|
12
|
+
libapitelethon/types/user_id_or_username.py,sha256=JqjZooejVwlX7paS8sWbS8Zx6W9L0unx_e_0Kop8mcw,186
|
|
13
|
+
libapitelethon/types/user_username.py,sha256=u-eHkGYwfI1S8aheVcP7OGL3XzYqPpzojdWbMtN1G0U,95
|
|
14
|
+
libapitelethon-1.0.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
|
|
15
|
+
libapitelethon-1.0.dist-info/METADATA,sha256=KIN123MsSjpWjFTlMUhdrmwYILGfFJd7MoCFq2AtAFQ,1108
|
|
16
|
+
libapitelethon-1.0.dist-info/RECORD,,
|