mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-02 05:24:51 +00:00
Catch FloodWaits when calling GetContacts
This commit is contained in:
parent
314d19e09d
commit
2a9da07548
1 changed files with 11 additions and 4 deletions
|
|
@ -2351,7 +2351,14 @@ class Client:
|
|||
)
|
||||
|
||||
def get_contacts(self, _hash: int = 0):
|
||||
contacts = self.send(functions.contacts.GetContacts(_hash))
|
||||
self.fetch_peers(contacts.users)
|
||||
|
||||
return contacts
|
||||
while True:
|
||||
try:
|
||||
contacts = self.send(functions.contacts.GetContacts(_hash))
|
||||
except FloodWait as e:
|
||||
log.info("Get contacts flood wait: {}".format(e.x))
|
||||
time.sleep(e.x)
|
||||
continue
|
||||
else:
|
||||
log.info("Contacts count: {}".format(len(contacts.users)))
|
||||
self.fetch_peers(contacts.users)
|
||||
return contacts
|
||||
|
|
|
|||
Loading…
Reference in a new issue