Merge branch 'master' into new-api
This commit is contained in:
commit
e3c70c84ba
@ -892,14 +892,19 @@ class Client:
|
||||
)
|
||||
|
||||
def get_dialogs_chunk(self, offset_date):
|
||||
while True:
|
||||
try:
|
||||
r = self.send(
|
||||
functions.messages.GetDialogs(
|
||||
offset_date, 0, types.InputPeerEmpty(),
|
||||
self.DIALOGS_AT_ONCE, 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(len(self.peers_by_id)))
|
||||
|
||||
return r
|
||||
|
||||
def get_dialogs(self):
|
||||
@ -909,13 +914,7 @@ class Client:
|
||||
offset_date = utils.get_offset_date(dialogs)
|
||||
|
||||
while len(dialogs.dialogs) == self.DIALOGS_AT_ONCE:
|
||||
try:
|
||||
dialogs = self.get_dialogs_chunk(offset_date)
|
||||
except FloodWait as e:
|
||||
log.warning("get_dialogs flood: waiting {} seconds".format(e.x))
|
||||
time.sleep(e.x)
|
||||
continue
|
||||
|
||||
offset_date = utils.get_offset_date(dialogs)
|
||||
|
||||
self.get_dialogs_chunk(0)
|
||||
|
@ -74,15 +74,15 @@ class Syncer:
|
||||
date=int(time.time()),
|
||||
peers_by_id={
|
||||
k: getattr(v, "access_hash", None)
|
||||
for k, v in client.peers_by_id.items()
|
||||
for k, v in client.peers_by_id.copy().items()
|
||||
},
|
||||
peers_by_username={
|
||||
k: utils.get_peer_id(v)
|
||||
for k, v in client.peers_by_username.items()
|
||||
for k, v in client.peers_by_username.copy().items()
|
||||
},
|
||||
peers_by_phone={
|
||||
k: utils.get_peer_id(v)
|
||||
for k, v in client.peers_by_phone.items()
|
||||
for k, v in client.peers_by_phone.copy().items()
|
||||
}
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user