Small fix

This commit is contained in:
Profitroll 2023-06-28 08:56:21 +02:00
parent e06cb4b377
commit 51da210817
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2

View File

@ -264,19 +264,19 @@ async def cmd_remove(app: PyroClient, msg: Message):
app._("remove_request", "message", locale=msg.from_user.language_code) app._("remove_request", "message", locale=msg.from_user.language_code)
) )
answer = await listen_message(app, msg.chat.id, timeout=600) answer_id = await listen_message(app, msg.chat.id, timeout=600)
USERS_WITH_CONTEXT.remove(msg.from_user.id) USERS_WITH_CONTEXT.remove(msg.from_user.id)
if answer is None: if answer_id is None:
await msg.reply_text( await msg.reply_text(
app._("remove_ignored", "message", locale=msg.from_user.language_code), app._("remove_ignored", "message", locale=msg.from_user.language_code),
quote=True, quote=True,
) )
return return
if answer.text == "/cancel": if answer_id.text == "/cancel":
await answer.reply_text( await answer_id.reply_text(
app._("remove_abort", "message", locale=msg.from_user.language_code) app._("remove_abort", "message", locale=msg.from_user.language_code)
) )
return return
@ -301,11 +301,11 @@ async def cmd_remove(app: PyroClient, msg: Message):
USERS_WITH_CONTEXT.append(msg.from_user.id) USERS_WITH_CONTEXT.append(msg.from_user.id)
answer = await listen_message(app, msg.chat.id, timeout=600) answer_kind = await listen_message(app, msg.chat.id, timeout=600)
USERS_WITH_CONTEXT.remove(msg.from_user.id) USERS_WITH_CONTEXT.remove(msg.from_user.id)
if answer is None: if answer_kind is None:
await msg.reply_text( await msg.reply_text(
app._("remove_ignored", "message", locale=msg.from_user.language_code), app._("remove_ignored", "message", locale=msg.from_user.language_code),
quote=True, quote=True,
@ -313,19 +313,19 @@ async def cmd_remove(app: PyroClient, msg: Message):
) )
return return
if answer.text == "/cancel": if answer_kind.text == "/cancel":
await answer.reply_text( await answer_kind.reply_text(
app._("remove_abort", "message", locale=msg.from_user.language_code), app._("remove_abort", "message", locale=msg.from_user.language_code),
reply_markup=ReplyKeyboardRemove(), reply_markup=ReplyKeyboardRemove(),
) )
return return
if answer.text in app.in_all_locales("photo", "button"): if answer_kind.text in app.in_all_locales("photo", "button"):
func = photo_delete func = photo_delete
elif answer.text in app.in_all_locales("video", "button"): elif answer_kind.text in app.in_all_locales("video", "button"):
func = video_delete func = video_delete
else: else:
await answer.reply_text( await answer_kind.reply_text(
app._( app._(
"remove_unknown", "message", locale=msg.from_user.language_code "remove_unknown", "message", locale=msg.from_user.language_code
).format( ).format(
@ -336,27 +336,31 @@ async def cmd_remove(app: PyroClient, msg: Message):
) )
return return
response = await func(id=answer.text, client=client) response = await func(id=answer_id.text, client=client)
if response: if response:
logger.info( logger.info(
"Removed '%s' by request of user %s", answer.text, answer.from_user.id "Removed %s '%s' by request of user %s",
answer_kind.text,
answer_id.text,
answer_id.from_user.id,
) )
await answer.reply_text( await answer_kind.reply_text(
app._( app._(
"remove_success", "message", locale=msg.from_user.language_code "remove_success", "message", locale=msg.from_user.language_code
).format(answer.text) ).format(answer_id.text)
) )
else: else:
logger.warning( logger.warning(
"Could not remove '%s' by request of user %s", "Could not remove %s '%s' by request of user %s",
answer.text, answer_kind.text,
answer.from_user.id, answer_id.text,
answer_id.from_user.id,
) )
await answer.reply_text( await answer_kind.reply_text(
app._( app._(
"remove_failure", "message", locale=msg.from_user.language_code "remove_failure", "message", locale=msg.from_user.language_code
).format(answer.text) ).format(answer_id.text)
) )