Remove unneeded code

Closes #414
This commit is contained in:
Dan 2020-06-06 12:31:25 +02:00
parent d65f773ed9
commit dd5bd80017
2 changed files with 2 additions and 57 deletions

View File

@ -685,9 +685,6 @@ class Client(Methods, BaseClient):
print(e.MESSAGE) print(e.MESSAGE)
self.phone_number = None self.phone_number = None
self.bot_token = None self.bot_token = None
except FloodWait as e:
print(e.MESSAGE.format(x=e.x))
time.sleep(e.x)
else: else:
break break
@ -736,9 +733,6 @@ class Client(Methods, BaseClient):
return self.recover_password(recovery_code) return self.recover_password(recovery_code)
except BadRequest as e: except BadRequest as e:
print(e.MESSAGE) print(e.MESSAGE)
except FloodWait as e:
print(e.MESSAGE.format(x=e.x))
time.sleep(e.x)
except Exception as e: except Exception as e:
log.error(e, exc_info=True) log.error(e, exc_info=True)
raise raise
@ -749,12 +743,6 @@ class Client(Methods, BaseClient):
except BadRequest as e: except BadRequest as e:
print(e.MESSAGE) print(e.MESSAGE)
self.password = None 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: else:
break break
@ -774,9 +762,6 @@ class Client(Methods, BaseClient):
) )
except BadRequest as e: except BadRequest as e:
print(e.MESSAGE) print(e.MESSAGE)
except FloodWait as e:
print(e.MESSAGE.format(x=e.x))
time.sleep(e.x)
else: else:
break break
@ -1636,38 +1621,6 @@ class Client(Methods, BaseClient):
log.warning('[{}] No plugin loaded from "{}"'.format( log.warning('[{}] No plugin loaded from "{}"'.format(
self.session_name, root)) 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]): def resolve_peer(self, peer_id: Union[int, str]):
"""Get the InputPeer of a known peer id. """Get the InputPeer of a known peer id.
Useful whenever an InputPeer type is required. Useful whenever an InputPeer type is required.

View File

@ -17,12 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
import time
from typing import List from typing import List
import pyrogram import pyrogram
from pyrogram.api import functions from pyrogram.api import functions
from pyrogram.errors import FloodWait
from ...ext import BaseClient from ...ext import BaseClient
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -41,11 +39,5 @@ class GetContacts(BaseClient):
contacts = app.get_contacts() contacts = app.get_contacts()
print(contacts) print(contacts)
""" """
while True: contacts = self.send(functions.contacts.GetContacts(hash=0))
try: return pyrogram.List(pyrogram.User._parse(self, user) for user in contacts.users)
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)