From 056fc52353a1f833f158376abd3cfdb36b45b1b9 Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sun, 19 Feb 2023 20:54:58 +0100 Subject: [PATCH] This commit closes #4 and closes #6 --- locale/en.json | 6 +++++- locale/uk.json | 6 +++++- plugins/handlers/submission.py | 12 +++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/locale/en.json b/locale/en.json index 09e9d9a..56598a1 100644 --- a/locale/en.json +++ b/locale/en.json @@ -15,7 +15,9 @@ "shutdown": "Shutting down bot with pid `{0}`", "startup": "Starting with pid `{0}`", "sub_yes": "✅ Submission approved and accepted", + "sub_yes_auto": "✅ Submission automatically accepted", "sub_no": "❌ Submission reviewed and declined", + "sub_dup": "⚠️ Submission automatically declined because database already contains this photo", "sub_blocked": "You were blocked and you can't submit media anymore.", "sub_unblocked": "You were unblocked and you can now submit media.", "sub_by": "\n\nSubmitted by:", @@ -33,7 +35,9 @@ "post_low": "Low amount of content: `There are only {0} files left in the queue.`", "api_creds_invalid": "__TO_BE_ADDED__", "sub_wip": "Post submission is now WIP. It will be available again in a few days. Thank you for your patience.", - "sub_duplicates_found": "__TO_BE_ADDED__" + "sub_duplicates_found": "__TO_BE_ADDED__", + "sub_error": "⚠️ Could not upload this image due to bot error. Admins are advised.", + "sub_error_admin": "User {0} could not submit photo without additional confirmation due to:\n```\n{1}\n```" }, "button": { "sub_yes": "✅ Accept", diff --git a/locale/uk.json b/locale/uk.json index 8900bee..4fb202a 100644 --- a/locale/uk.json +++ b/locale/uk.json @@ -15,7 +15,9 @@ "shutdown": "Вимкнення бота з підом `{0}`", "startup": "Запуск бота з підом `{0}`", "sub_yes": "✅ Подання схвалено та прийнято", + "sub_yes_auto": "✅ Подання автоматично прийнято", "sub_no": "❌ Подання розглянуто та відхилено", + "sub_dup": "⚠️ Подання автоматично відхилено через наявність цього фото в базі даних", "sub_blocked": "Вас заблокували, ви більше не можете надсилати медіафайли.", "sub_unblocked": "Вас розблокували, тепер ви можете надсилати медіафайли.", "sub_by": "\n\nПредставлено:", @@ -33,7 +35,9 @@ "post_low": "Мала кількість контенту: `Залишилось всього {0} файлів в черзі.`", "api_creds_invalid": "__TO_BE_ADDED__", "sub_wip": "Подання постів зараз знаходиться у розробці. Він буде знову доступний через кілька днів. Дякуємо за ваше терпіння.", - "sub_duplicates_found": "__TO_BE_ADDED__" + "sub_duplicates_found": "__TO_BE_ADDED__", + "sub_error": "⚠️ Не вдалось завантажити фото через помилку бота. Адміністрацію повідомлено.", + "sub_error_admin": "Користувач {0} не зміг надіслати фото без додаткової перевірки через помилку:\n```\n{1}\n```" }, "button": { "sub_yes": "✅ Прийняти", diff --git a/plugins/handlers/submission.py b/plugins/handlers/submission.py index 4b6c51b..e3151d6 100644 --- a/plugins/handlers/submission.py +++ b/plugins/handlers/submission.py @@ -149,25 +149,27 @@ async def get_submission(app: PosterClient, msg: Message): if msg.from_user.id in app.admins and configGet("admins", "submission", "require_confirmation") is False: try: await app.submit_photo(str(inserted.inserted_id)) - await msg.copy(app.owner, caption=caption) + await msg.reply_text(locale("sub_yes_auto", "message", locale=user_locale), quote=True) + await msg.copy(app.owner, caption=caption, disable_notification=True) return except SubmissionDuplicatesError as exp: await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)), quote=True) return except Exception as exp: - await msg.reply_text(format_exc()) + await msg.reply_text(format_exc(), quote=True) return elif msg.from_user.id not in app.admins and configGet("users", "submission", "require_confirmation") is False: try: await app.submit_photo(str(inserted.inserted_id)) + await msg.reply_text(locale("sub_yes_auto", "message", locale=user_locale), quote=True) await msg.copy(app.owner, caption=caption) return except SubmissionDuplicatesError as exp: - await msg.reply_text(locale("sub_media_duplicates_list", "message", locale=user_locale).format("\n • ".join(exp.duplicates)), quote=True) + await msg.reply_text(locale("sub_dup", "message", locale=user_locale), quote=True) return except Exception as exp: - await app.send_message(app.owner, f"User {msg.from_user.id} could not submit photo without additional confirmation due to:\n```\n{format_exc()}\n```") - await msg.reply_text("Could not upload this image. Admins are advised.") + await app.send_message(app.owner, locale("sub_error_admin", "message").format(msg.from_user.id, format_exc())) + await msg.reply_text("sub_error", quote=True) return if msg.from_user.id not in app.admins: