Fix handling of early edits in Conversation

The incoming messages were never updated, so of course their
edit_date wasn't either. This would cause the library to be
stuck until it timed out, because the event had already
arrived before we waited for it. As an example:

    await conv.send_message('foo')
    await sleep(1)  # bot has plenty of time to respond+edit
    await conv.get_edit()
This commit is contained in:
Lonami Exo 2019-10-31 10:40:22 +01:00
parent 4a8b19b0be
commit 0a3d164806

View File

@ -333,6 +333,12 @@ class Conversation(ChatGetter):
if message.chat_id != self.chat_id or message.out:
return
# We have to update our incoming messages with the new edit date
for i, m in enumerate(self._incoming):
if m.id == message.id:
self._incoming[i] = message
break
for msg_id, future in list(self._pending_edits.items()):
if msg_id < message.id:
edit_ts = message.edit_date.timestamp()