Merge branch 'master' into new-api
This commit is contained in:
commit
e3c70c84ba
@ -892,15 +892,20 @@ class Client:
|
||||
)
|
||||
|
||||
def get_dialogs_chunk(self, offset_date):
|
||||
r = self.send(
|
||||
functions.messages.GetDialogs(
|
||||
offset_date, 0, types.InputPeerEmpty(),
|
||||
self.DIALOGS_AT_ONCE, True
|
||||
)
|
||||
)
|
||||
log.info("Total peers: {}".format(len(self.peers_by_id)))
|
||||
|
||||
return r
|
||||
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):
|
||||
self.send(functions.messages.GetPinnedDialogs())
|
||||
@ -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
|
||||
|
||||
dialogs = self.get_dialogs_chunk(offset_date)
|
||||
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