remove waiting for deletion

This commit is contained in:
udf 2019-04-27 12:05:46 +02:00
parent b98bc8eb02
commit 0b64a64568
Signed by: kate
GPG Key ID: F17AECB58C3A3096
1 changed files with 4 additions and 12 deletions

View File

@ -41,8 +41,8 @@ async def wait_for_delete(deleted_fut, timeout):
return False return False
async def wait_and_revert(deleted_fut, timeout): async def wait_and_revert(timeout):
await wait_for_delete(deleted_fut, timeout) await asyncio.sleep(timeout)
await edit_title(DEFAULT_TITLE) await edit_title(DEFAULT_TITLE)
@ -60,16 +60,8 @@ async def on_name(event):
with (await rename_lock): with (await rename_lock):
await edit_title(new_title) await edit_title(new_title)
deleted_fut = borg.await_event(events.MessageDeleted(
chats=CHANNEL_ID,
func=lambda e: e.deleted_id == event.message.id
))
if await wait_for_delete(asyncio.shield(deleted_fut), MULTI_EDIT_TIMEOUT):
await edit_title(DEFAULT_TITLE)
await asyncio.sleep(MULTI_EDIT_TIMEOUT) await asyncio.sleep(MULTI_EDIT_TIMEOUT)
return
if revert_task and not revert_task.done(): if revert_task and not revert_task.done():
revert_task.cancel() revert_task.cancel()
revert_task = asyncio.create_task(wait_and_revert(REVERT_TIMEOUT))
revert_task = asyncio.create_task(wait_and_revert(deleted_fut, REVERT_TIMEOUT))