Refactor synchronization messaging for clarity and simplicity
- Updated synchronization messages to provide simpler, more concise feedback to admins during the sync process. - Replaced detailed sync status messages with straightforward notifications for success, failure, and errors. - Enhanced localization for new message formats to improve user experience across languages.
This commit is contained in:
@@ -265,7 +265,7 @@ async def sync_command_handler(
|
||||
return
|
||||
|
||||
if isinstance(message_event, types.Message):
|
||||
await message_event.answer(_("sync_started"))
|
||||
await message_event.answer(_("sync_started_simple"))
|
||||
|
||||
logging.info(f"Admin ({message_event.from_user.id}) triggered panel sync.")
|
||||
|
||||
@@ -277,27 +277,13 @@ async def sync_command_handler(
|
||||
details = sync_result.get("details", "No details available")
|
||||
errors = sync_result.get("errors", [])
|
||||
|
||||
# Simple confirmation message to admin
|
||||
if status == "failed":
|
||||
await bot.send_message(target_chat_id, _("sync_failed", details=details))
|
||||
await bot.send_message(target_chat_id, _("sync_failed_simple"))
|
||||
elif status == "completed_with_errors":
|
||||
error_preview = "; ".join(errors[:3]) # Show first 3 errors
|
||||
final_message = _(
|
||||
"sync_completed_with_errors_details",
|
||||
total_checked=sync_result.get("users_processed", 0),
|
||||
users_synced=sync_result.get("users_synced", 0),
|
||||
subs_synced=sync_result.get("subs_synced", 0),
|
||||
errors_count=len(errors),
|
||||
error_details_preview=error_preview
|
||||
)
|
||||
await bot.send_message(target_chat_id, final_message)
|
||||
await bot.send_message(target_chat_id, _("sync_errors_simple", errors_count=len(errors)))
|
||||
else:
|
||||
final_message = _(
|
||||
"sync_completed_details",
|
||||
total_checked=sync_result.get("users_processed", 0),
|
||||
users_synced=sync_result.get("users_synced", 0),
|
||||
subs_synced=sync_result.get("subs_synced", 0)
|
||||
)
|
||||
await bot.send_message(target_chat_id, _("sync_completed", status="Success", details=final_message))
|
||||
await bot.send_message(target_chat_id, _("sync_success_simple"))
|
||||
|
||||
# Send notification to log channel with proper thread handling
|
||||
try:
|
||||
@@ -311,7 +297,7 @@ async def sync_command_handler(
|
||||
|
||||
except Exception as e_sync_global:
|
||||
logging.error(f"Global error during /sync command: {e_sync_global}", exc_info=True)
|
||||
await bot.send_message(target_chat_id, _("sync_failed", details=str(e_sync_global)))
|
||||
await bot.send_message(target_chat_id, _("sync_critical_error"))
|
||||
|
||||
# Send notification to log channel about failure
|
||||
try:
|
||||
|
||||
+5
-5
@@ -228,11 +228,11 @@
|
||||
"admin_log_user_not_found": "User \"{input}\" not found in bot database.",
|
||||
"admin_user_logs_title": "Logs for {user_display} (page {current_page}/{total_pages}):",
|
||||
|
||||
"sync_started": "🔄 Starting data sync with panel...",
|
||||
"sync_failed": "❌ Sync with panel failed. Details: {details}",
|
||||
"sync_completed": "✅ Sync with panel completed. Status: {status}. Details: {details}",
|
||||
"sync_completed_details": "Checked: {total_checked} entries.\nUsers synced/updated: {users_synced}.\nSubscriptions synced/updated: {subs_synced}.",
|
||||
"sync_completed_with_errors_details": "Checked: {total_checked} entries.\nUsers synced/updated: {users_synced}.\nSubscriptions synced/updated: {subs_synced}.\nErrors: {errors_count}.\n\nFirst errors:\n{error_details_preview}",
|
||||
"sync_started_simple": "🔄 Starting synchronization...",
|
||||
"sync_success_simple": "✅ Synchronization completed successfully",
|
||||
"sync_failed_simple": "❌ Synchronization failed",
|
||||
"sync_errors_simple": "⚠️ Synchronization completed with errors ({errors_count} errors)",
|
||||
"sync_critical_error": "❌ Critical synchronization error",
|
||||
"no_errors_placeholder": "none",
|
||||
"admin_sync_initiated_from_panel": "Sync initiated...",
|
||||
"admin_panel_user_creation_failed": "❌ Failed to create panel user for TG ID {user_id}. Panel unreachable?",
|
||||
|
||||
+5
-5
@@ -238,11 +238,11 @@
|
||||
"admin_log_user_not_found": "Пользователь по запросу \"{input}\" не найден в базе данных бота.",
|
||||
"admin_user_logs_title": "Логи пользователя {user_display} (стр. {current_page}/{total_pages}):",
|
||||
|
||||
"sync_started": "🔄 Начинаю синхронизацию данных с панелью...",
|
||||
"sync_failed": "❌ Ошибка синхронизации с панелью. Детали: {details}",
|
||||
"sync_completed": "✅ Синхронизация с панелью завершена. Статус: {status}. Детали: {details}",
|
||||
"sync_completed_details": "Проверено: {total_checked} записей.\nПользователей синхронизировано/обновлено: {users_synced}.\nПодписок синхронизировано/обновлено: {subs_synced}.",
|
||||
"sync_completed_with_errors_details": "Проверено: {total_checked} записей.\nПользователей синхронизировано/обновлено: {users_synced}.\nПодписок синхронизировано/обновлено: {subs_synced}.\nОшибок: {errors_count}.\n\nПервые ошибки:\n{error_details_preview}",
|
||||
"sync_started_simple": "🔄 Начинаю синхронизацию...",
|
||||
"sync_success_simple": "✅ Синхронизация успешно завершена",
|
||||
"sync_failed_simple": "❌ Синхронизация завершилась с ошибкой",
|
||||
"sync_errors_simple": "⚠️ Синхронизация завершена с ошибками ({errors_count} ошибок)",
|
||||
"sync_critical_error": "❌ Критическая ошибка синхронизации",
|
||||
"no_errors_placeholder": "нет",
|
||||
"admin_sync_initiated_from_panel": "Синхронизация запущена...",
|
||||
"admin_panel_user_creation_failed": "❌ Не удалось создать пользователя на панели для TG ID {user_id}. Панель недоступна?",
|
||||
|
||||
Reference in New Issue
Block a user