From dd5bd800174d7a07315b1ce38fa1dda9d84bc321 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 6 Jun 2020 12:31:25 +0200 Subject: [PATCH] Remove unneeded code Closes #414 --- pyrogram/client/client.py | 47 ------------------- .../client/methods/contacts/get_contacts.py | 12 +---- 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 53bc3799..5f52bfc0 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -685,9 +685,6 @@ class Client(Methods, BaseClient): print(e.MESSAGE) self.phone_number = None self.bot_token = None - except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) else: break @@ -736,9 +733,6 @@ class Client(Methods, BaseClient): return self.recover_password(recovery_code) except BadRequest as e: print(e.MESSAGE) - except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) except Exception as e: log.error(e, exc_info=True) raise @@ -749,12 +743,6 @@ class Client(Methods, BaseClient): except BadRequest as e: print(e.MESSAGE) self.password = None - except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) - except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) else: break @@ -774,9 +762,6 @@ class Client(Methods, BaseClient): ) except BadRequest as e: print(e.MESSAGE) - except FloodWait as e: - print(e.MESSAGE.format(x=e.x)) - time.sleep(e.x) else: break @@ -1636,38 +1621,6 @@ class Client(Methods, BaseClient): log.warning('[{}] No plugin loaded from "{}"'.format( self.session_name, root)) - # def get_initial_dialogs_chunk(self, offset_date: int = 0): - # while True: - # try: - # r = self.send( - # functions.messages.GetDialogs( - # offset_date=offset_date, - # offset_id=0, - # offset_peer=types.InputPeerEmpty(), - # limit=self.DIALOGS_AT_ONCE, - # hash=0, - # exclude_pinned=True - # ) - # ) - # except FloodWait as e: - # log.warning("get_dialogs flood: waiting {} seconds".format(e.x)) - # time.sleep(e.x) - # else: - # log.info("Total peers: {}".format(self.storage.peers_count)) - # return r - # - # def get_initial_dialogs(self): - # self.send(functions.messages.GetPinnedDialogs(folder_id=0)) - # - # dialogs = self.get_initial_dialogs_chunk() - # offset_date = utils.get_offset_date(dialogs) - # - # while len(dialogs.dialogs) == self.DIALOGS_AT_ONCE: - # dialogs = self.get_initial_dialogs_chunk(offset_date) - # offset_date = utils.get_offset_date(dialogs) - # - # self.get_initial_dialogs_chunk() - def resolve_peer(self, peer_id: Union[int, str]): """Get the InputPeer of a known peer id. Useful whenever an InputPeer type is required. diff --git a/pyrogram/client/methods/contacts/get_contacts.py b/pyrogram/client/methods/contacts/get_contacts.py index 84d9c7d4..a0699e19 100644 --- a/pyrogram/client/methods/contacts/get_contacts.py +++ b/pyrogram/client/methods/contacts/get_contacts.py @@ -17,12 +17,10 @@ # along with Pyrogram. If not, see . import logging -import time from typing import List import pyrogram from pyrogram.api import functions -from pyrogram.errors import FloodWait from ...ext import BaseClient log = logging.getLogger(__name__) @@ -41,11 +39,5 @@ class GetContacts(BaseClient): contacts = app.get_contacts() print(contacts) """ - while True: - try: - contacts = self.send(functions.contacts.GetContacts(hash=0)) - except FloodWait as e: - log.warning("get_contacts flood: waiting {} seconds".format(e.x)) - time.sleep(e.x) - else: - return pyrogram.List(pyrogram.User._parse(self, user) for user in contacts.users) + contacts = self.send(functions.contacts.GetContacts(hash=0)) + return pyrogram.List(pyrogram.User._parse(self, user) for user in contacts.users)