Fix .get_dialogs() failing on Windows

This commit is contained in:
Lonami Exo 2017-10-01 21:02:41 +02:00
parent 3805aa3772
commit 43f796caab

View File

@ -284,8 +284,10 @@ class TelegramClient(TelegramBareClient):
)
offset_id = r.messages[-1].id & 4294967296 # Telegram/danog magic
# Sort by message date
no_date = datetime.fromtimestamp(0)
# Sort by message date. Windows will raise if timestamp is 0,
# so we need to set at least one day ahead while still being
# the smallest date possible.
no_date = datetime.fromtimestamp(86400)
ds = sorted(
list(dialogs.values()),
key=lambda d: getattr(messages[d.top_message], 'date', no_date)