pyrogram-client 0.0.8.dev1__tar.gz → 0.0.9__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 (20) hide show
  1. {pyrogram_client-0.0.8.dev1/pyrogram_client.egg-info → pyrogram_client-0.0.9}/PKG-INFO +1 -1
  2. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/base.py +14 -22
  3. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/user.py +4 -1
  4. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/storage.py +2 -0
  5. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9/pyrogram_client.egg-info}/PKG-INFO +1 -1
  6. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/.env.sample +0 -0
  7. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/.gitignore +0 -0
  8. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/.pre-commit-config.yaml +0 -0
  9. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/makefile +0 -0
  10. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyproject.toml +0 -0
  11. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/bot.py +0 -0
  12. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/dc.json +0 -0
  13. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/file.py +0 -0
  14. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/client/filler.py +0 -0
  15. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyro_client/loader.py +0 -0
  16. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyrogram_client.egg-info/SOURCES.txt +0 -0
  17. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyrogram_client.egg-info/dependency_links.txt +0 -0
  18. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyrogram_client.egg-info/requires.txt +0 -0
  19. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/pyrogram_client.egg-info/top_level.txt +0 -0
  20. {pyrogram_client-0.0.8.dev1 → pyrogram_client-0.0.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyrogram-client
3
- Version: 0.0.8.dev1
3
+ Version: 0.0.9
4
4
  Author-email: Mike Artemiev <mixartemev@gmail.com>
5
5
  Project-URL: Homepage, https://gitlab.com/XyncNet/pyro-client
6
6
  Project-URL: Repository, https://gitlab.com/XyncNet/pyro-client
@@ -1,11 +1,10 @@
1
1
  import asyncio
2
- from collections import OrderedDict
3
2
  from io import BytesIO
4
3
  from typing import Literal
5
4
 
6
5
  from pyrogram import Client
7
6
  from pyrogram.errors import AuthKeyUnregistered, Unauthorized
8
- from pyrogram.filters import chat, contact, AndFilter
7
+ from pyrogram.filters import chat, contact
9
8
  from pyrogram.handlers import MessageHandler
10
9
  from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, KeyboardButton
11
10
  from x_auth.models import Session, App, Username
@@ -78,33 +77,26 @@ class BaseClient(Client):
78
77
  else:
79
78
  return await self.send_message(uid, txt, reply_markup=ikm)
80
79
 
81
- async def wait_from(self, uid: int, topic: str, past: int = 0, timeout: int = 10) -> str | None:
80
+ def subscribe_for(self, uid: int, topic: str) -> tuple[MessageHandler, int]:
82
81
  fltr = chat(uid)
83
82
  if topic == "phone":
84
83
  fltr &= contact
85
- handler = MessageHandler(self.got_msg, fltr)
86
- # handler, g = self.add_handler(handler, 1)
87
- g = 0
88
- if g not in self.dispatcher.groups:
89
- self.dispatcher.groups[g] = []
90
- self.dispatcher.groups = OrderedDict(sorted(self.dispatcher.groups.items()))
91
- self.dispatcher.groups[g].append(handler)
92
84
  self.storage.session.state |= {uid: {"waiting_for": topic}}
93
- #
85
+ return self.add_handler(MessageHandler(self.got_msg, fltr))
86
+
87
+ async def wait_from(
88
+ self, uid: int, topic: str, hg: tuple[MessageHandler, int], past: int = 0, timeout: int = 10
89
+ ) -> str | None:
94
90
  while past < timeout:
95
91
  if txt := self.storage.session.state.get(uid, {}).pop(topic, None):
96
- # self.remove_handler(handler)
97
- self.dispatcher.groups[g].remove(handler)
98
- #
92
+ self.remove_handler(*hg)
99
93
  return txt
100
- await asyncio.sleep(1)
101
- past += 1
102
- return self.remove_handler(handler, g)
94
+ await asyncio.sleep(2)
95
+ past += 2
96
+ return self.remove_handler(*hg)
103
97
 
104
98
  async def got_msg(self, _, msg: Message):
105
99
  if tpc := self.storage.session.state.get(msg.from_user.id, {}).pop("waiting_for", None):
106
- self.storage.session.state[msg.from_user.id][tpc] = msg.contact.phone_number if tpc == "phone" else msg.text
107
-
108
- def rm_handler(self, uid: int):
109
- for gi, grp in self.dispatcher.groups.items():
110
- [self.remove_handler(h, gi) for h in grp if isinstance(h.filters, AndFilter) and uid in h.filters.base]
100
+ self.storage.session.state[msg.from_user.id] = {
101
+ tpc: msg.contact.phone_number if tpc == "phone" else msg.text
102
+ }
@@ -175,11 +175,14 @@ async def main():
175
175
  # await models.Proxy.load_list(WSToken)
176
176
  # session = await models.Session.filter(is_bot__isnull=True).order_by("-date").prefetch_related("proxy").first()
177
177
  bc: BotClient = BotClient(6806432376)
178
- uc: UserClient = UserClient(7314099964, bc)
178
+ uc: UserClient = UserClient(193017646, bc)
179
179
  # try:
180
180
  await uc.start()
181
181
  # b = await uc.resolve_peer('xyncnetbot')
182
182
  await uc.send("/start", bc.me.username)
183
+
184
+ hg = uc.subscribe_for(1038938370, "code")
185
+ await uc.wait_from(1038938370, "code", hg)
183
186
  # except Exception as e:
184
187
  # print(e.MESSAGE)
185
188
  # await uc.send(e.MESSAGE)
@@ -14,6 +14,8 @@ def get_input_peer(peer_id: int, access_hash: int, peer_type: PeerType):
14
14
  return raw.types.InputPeerChat(chat_id=-peer_id)
15
15
  if peer_type in [PeerType.channel, PeerType.supergroup]:
16
16
  return raw.types.InputPeerChannel(channel_id=utils.get_channel_id(peer_id), access_hash=access_hash)
17
+ if peer_type in [PeerType.forum]:
18
+ return raw.types.InputPeerChannel(channel_id=utils.get_channel_id(peer_id), access_hash=access_hash)
17
19
  raise ValueError(f"Invalid peer type: {peer_type.name}")
18
20
 
19
21
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyrogram-client
3
- Version: 0.0.8.dev1
3
+ Version: 0.0.9
4
4
  Author-email: Mike Artemiev <mixartemev@gmail.com>
5
5
  Project-URL: Homepage, https://gitlab.com/XyncNet/pyro-client
6
6
  Project-URL: Repository, https://gitlab.com/XyncNet/pyro-client