pyrogram-client 0.0.3__tar.gz → 0.0.5__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.
- {pyrogram_client-0.0.3/pyrogram_client.egg-info → pyrogram_client-0.0.5}/PKG-INFO +1 -1
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/base.py +3 -1
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/user.py +2 -2
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/storage.py +16 -16
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5/pyrogram_client.egg-info}/PKG-INFO +1 -1
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/.env.sample +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/.gitignore +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/.pre-commit-config.yaml +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/makefile +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyproject.toml +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/bot.py +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/dc.json +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/file.py +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/client/single.py +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyro_client/loader.py +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyrogram_client.egg-info/SOURCES.txt +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyrogram_client.egg-info/dependency_links.txt +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyrogram_client.egg-info/requires.txt +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyrogram_client.egg-info/top_level.txt +0 -0
- {pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/setup.cfg +0 -0
|
@@ -25,7 +25,9 @@ class BaseClient(Client, metaclass=SingleMeta):
|
|
|
25
25
|
storage: PgStorage
|
|
26
26
|
|
|
27
27
|
def __init__(self, name: str, api_id, api_hash, *args, **kwargs):
|
|
28
|
-
super().__init__(
|
|
28
|
+
super().__init__(
|
|
29
|
+
name, api_id=api_id, api_hash=api_hash, *args, storage_engine=PgStorage(name), workers=1, **kwargs
|
|
30
|
+
)
|
|
29
31
|
|
|
30
32
|
async def send(
|
|
31
33
|
self,
|
|
@@ -12,7 +12,7 @@ from x_auth.models import Session, Username, Proxy
|
|
|
12
12
|
|
|
13
13
|
from pyro_client.client.base import BaseClient, AuthTopic
|
|
14
14
|
from pyro_client.client.bot import BotClient
|
|
15
|
-
from pyro_client.loader import WSToken
|
|
15
|
+
from pyro_client.loader import WSToken, TOKEN
|
|
16
16
|
|
|
17
17
|
vers: dict[ClientPlatform, str] = {
|
|
18
18
|
ClientPlatform.IOS: "18.5",
|
|
@@ -181,7 +181,7 @@ async def main():
|
|
|
181
181
|
|
|
182
182
|
await models.Proxy.load_list(WSToken)
|
|
183
183
|
# session = await models.Session.filter(is_bot__isnull=True).order_by("-date").prefetch_related("proxy").first()
|
|
184
|
-
bc: BotClient = await BotClient(
|
|
184
|
+
bc: BotClient = await BotClient(TOKEN)
|
|
185
185
|
uc: UserClient = await UserClient(5547330178, bc)
|
|
186
186
|
# try:
|
|
187
187
|
await uc.start()
|
|
@@ -23,6 +23,7 @@ class PgStorage(Storage):
|
|
|
23
23
|
VERSION = 1
|
|
24
24
|
USERNAME_TTL = 8 * 60 * 60
|
|
25
25
|
session: Session
|
|
26
|
+
|
|
26
27
|
# me_id: int
|
|
27
28
|
|
|
28
29
|
async def open(self):
|
|
@@ -39,10 +40,10 @@ class PgStorage(Storage):
|
|
|
39
40
|
|
|
40
41
|
async def update_peers(self, peers: list[tuple[int, int, str, str]]):
|
|
41
42
|
for peer in peers:
|
|
42
|
-
uid, ac_hsh, typ,
|
|
43
|
-
un, _ = await Username.
|
|
43
|
+
uid, ac_hsh, typ, phone = peer
|
|
44
|
+
un, _ = await Username.update_or_create(phone and {"phone": phone}, id=uid)
|
|
44
45
|
await Peer.update_or_create(
|
|
45
|
-
{"username": un, "type": typ, "phone_number":
|
|
46
|
+
{"username": un, "type": typ, "phone_number": phone}, session_id=self.name, id=ac_hsh
|
|
46
47
|
)
|
|
47
48
|
|
|
48
49
|
async def update_usernames(self, usernames: list[tuple[int, list[str]]]):
|
|
@@ -50,17 +51,17 @@ class PgStorage(Storage):
|
|
|
50
51
|
for username in user_list:
|
|
51
52
|
await Username.update_or_create({"username": username}, id=telegram_id)
|
|
52
53
|
|
|
53
|
-
async def get_peer_by_id(self,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
async def get_peer_by_id(self, uin: int | str):
|
|
55
|
+
peer = await (
|
|
56
|
+
Peer.get(session_id=self.name, username_id=uin) if isinstance(uin, int) else self.get_peer_by_username(uin)
|
|
57
|
+
)
|
|
57
58
|
if peer.last_update_on:
|
|
58
59
|
if abs(time.time() - peer.last_update_on.timestamp()) > self.USERNAME_TTL:
|
|
59
|
-
raise KeyError(f"Username expired: {
|
|
60
|
+
raise KeyError(f"Username expired: {uin}")
|
|
60
61
|
return get_input_peer(peer.username_id, peer.id, peer.type)
|
|
61
62
|
|
|
62
63
|
async def get_peer_by_username(self, username: str):
|
|
63
|
-
return await self.
|
|
64
|
+
return await Peer.get(session_id=self.name, username__username=username)
|
|
64
65
|
|
|
65
66
|
async def update_state(self, value: tuple[int, int, int, int, int] = object):
|
|
66
67
|
if value is None:
|
|
@@ -74,12 +75,9 @@ class PgStorage(Storage):
|
|
|
74
75
|
)
|
|
75
76
|
|
|
76
77
|
async def get_peer_by_phone_number(self, phone_number: str):
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
):
|
|
82
|
-
raise KeyError(f"Phone number not found: {phone_number}")
|
|
78
|
+
attrs = "id", "access_hash", "type"
|
|
79
|
+
if not (peer := await Peer.get_or_none(session_id=self.name, phone_number=phone_number).values_list(*attrs)):
|
|
80
|
+
peer = await Peer.get(session_id=self.name, username__phone=phone_number).values_list(*attrs)
|
|
83
81
|
return get_input_peer(*peer)
|
|
84
82
|
|
|
85
83
|
async def _get(self, attr: str):
|
|
@@ -119,7 +117,9 @@ class PgStorage(Storage):
|
|
|
119
117
|
return await self._accessor("user_id", value)
|
|
120
118
|
|
|
121
119
|
async def is_bot(self, value: bool = object):
|
|
122
|
-
|
|
120
|
+
if value is not object:
|
|
121
|
+
value = self.session.is_bot if value else None # dirty
|
|
122
|
+
return bool(await self._accessor("is_bot", value))
|
|
123
123
|
|
|
124
124
|
@staticmethod
|
|
125
125
|
async def version(value: int = object):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyrogram_client-0.0.3 → pyrogram_client-0.0.5}/pyrogram_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|