diff --git a/bot/handlers/admin/promo/manage.py b/bot/handlers/admin/promo/manage.py
index cefd1a2..c90b432 100644
--- a/bot/handlers/admin/promo/manage.py
+++ b/bot/handlers/admin/promo/manage.py
@@ -445,10 +445,7 @@ async def promo_edit_field_handler(callback: types.CallbackQuery, state: FSMCont
}
prompt_key = prompts.get(field, "error_occurred_try_again")
- if field == "discount_percentage":
- prompt_text = "Enter the new discount percentage (1-100):"
- else:
- prompt_text = _(prompt_key)
+ prompt_text = _(prompt_key)
await state.set_state(AdminStates.waiting_for_promo_edit_details)
await callback.message.edit_text(prompt_text)
diff --git a/bot/handlers/user/promo_user.py b/bot/handlers/user/promo_user.py
index d68c35f..2da7d16 100644
--- a/bot/handlers/user/promo_user.py
+++ b/bot/handlers/user/promo_user.py
@@ -165,6 +165,21 @@ async def process_promo_code_input(message: types.Message, state: FSMContext,
f"Discount promo code '{code_input}' successfully applied for user {user.id}."
)
discount_pct = result_discount # Returns percentage
+
+ # Send notification about discount promo activation
+ if settings.LOG_PROMO_ACTIVATIONS:
+ try:
+ from bot.services.notification_service import NotificationService
+ notification_service = NotificationService(bot, settings, i18n)
+ await notification_service.notify_discount_promo_activation(
+ user_id=user.id,
+ promo_code=code_input.upper(),
+ discount_percentage=discount_pct,
+ username=user.username
+ )
+ except Exception as e:
+ logging.error(f"Failed to send discount promo activation notification: {e}")
+
response_to_user_text = _(
"discount_promo_code_applied_success",
code=hcode(code_input.upper()),
diff --git a/bot/services/notification_service.py b/bot/services/notification_service.py
index 8c79903..5143bc8 100644
--- a/bot/services/notification_service.py
+++ b/bot/services/notification_service.py
@@ -271,15 +271,15 @@ class NotificationService:
"""Send notification about promo code activation"""
if not self.settings.LOG_PROMO_ACTIVATIONS:
return
-
+
admin_lang = self.settings.DEFAULT_LANGUAGE
_ = lambda k, **kw: self.i18n.gettext(admin_lang, k, **kw) if self.i18n else k
-
+
user_display = self._format_user_display(
user_id=user_id,
username=username,
)
-
+
message = _(
"log_promo_activation",
user_display=user_display,
@@ -287,7 +287,33 @@ class NotificationService:
bonus_days=bonus_days,
timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
)
-
+
+ # Send to log channel
+ profile_keyboard = self._build_profile_keyboard(_, user_id)
+ await self._send_to_log_channel(message, reply_markup=profile_keyboard)
+
+ async def notify_discount_promo_activation(self, user_id: int, promo_code: str, discount_percentage: int,
+ username: Optional[str] = None):
+ """Send notification about discount promo code activation"""
+ if not self.settings.LOG_PROMO_ACTIVATIONS:
+ return
+
+ admin_lang = self.settings.DEFAULT_LANGUAGE
+ _ = lambda k, **kw: self.i18n.gettext(admin_lang, k, **kw) if self.i18n else k
+
+ user_display = self._format_user_display(
+ user_id=user_id,
+ username=username,
+ )
+
+ message = _(
+ "log_promo_discount_activation",
+ user_display=user_display,
+ promo_code=promo_code,
+ discount_percentage=discount_percentage,
+ timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ )
+
# Send to log channel
profile_keyboard = self._build_profile_keyboard(_, user_id)
await self._send_to_log_channel(message, reply_markup=profile_keyboard)
diff --git a/locales/en.json b/locales/en.json
index 04c8771..85a0095 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -208,6 +208,7 @@
"csv_no": "No",
"admin_promo_edit_select_field": "Select a field to edit:",
"admin_promo_prompt_bonus_days": "Enter the new number of bonus days:",
+ "admin_promo_prompt_discount_percentage": "Enter the new discount percentage (1-100):",
"admin_promo_prompt_max_activations": "Enter the new maximum number of activations:",
"admin_promo_prompt_validity_days": "Enter the new validity period in days (0 for indefinite):",
"admin_promo_edit_success": "Promo code updated successfully.",
@@ -313,6 +314,7 @@
"log_payment_received": "{provider_emoji} Payment Received\n\n👤 User: {user_display}\n💰 Amount: {amount} {currency}\n📅 Period: {months} mo.\n🏦 Provider: {payment_provider}\n🕐 Time: {timestamp}",
"log_payment_received_traffic": "{provider_emoji} Payment Received\n\n👤 User: {user_display}\n💰 Amount: {amount} {currency}\n🗂 Traffic: {traffic_gb} GB\n🏦 Provider: {payment_provider}\n🕐 Time: {timestamp}",
"log_promo_activation": "🎁 Promo Code Activated\n\n👤 User: {user_display}\n🏷 Code: {promo_code}\n🎯 Bonus: +{bonus_days}d\n🕐 Time: {timestamp}",
+ "log_promo_discount_activation": "💰 Discount Promo Code Activated\n\n👤 User: {user_display}\n🏷 Code: {promo_code}\n💵 Discount: {discount_percentage}%\n🕐 Time: {timestamp}",
"log_trial_activation": "🆓 Trial Activated\n\n👤 User: {user_display}\n⏰ Valid until: {end_date}\n🕐 Time: {timestamp}",
"log_panel_sync": "{status_emoji} Panel Synchronization\n\n📊 Status: {status}\n👥 Users processed: {users_processed}\n📋 Subscriptions synced: {subs_synced}\n🕐 Time: {timestamp}\n\n📝 Details:\n{details}",
"log_suspicious_promo": "⚠️ Suspicious Promo Code Attempt\n\n👤 User: {user_display}\n🆔 ID: {user_id}\n📝 Input:
{suspicious_input}\n🕐 Time: {timestamp}",
diff --git a/locales/ru.json b/locales/ru.json
index 2d826a9..fc5aac1 100644
--- a/locales/ru.json
+++ b/locales/ru.json
@@ -218,6 +218,7 @@
"csv_no": "Нет",
"admin_promo_edit_select_field": "Выберите поле для редактирования:",
"admin_promo_prompt_bonus_days": "Введите новое количество бонусных дней:",
+ "admin_promo_prompt_discount_percentage": "Введите новый процент скидки (от 1 до 100):",
"admin_promo_prompt_max_activations": "Введите новое максимальное количество активаций:",
"admin_promo_prompt_validity_days": "Введите новый срок действия в днях (0 для бессрочного):",
"admin_promo_edit_success": "Промокод успешно обновлен.",
@@ -314,6 +315,7 @@
"log_payment_received": "{provider_emoji} Получен платеж\n\n👤 Пользователь: {user_display}\n💰 Сумма: {amount} {currency}\n📅 Период: {months} мес.\n🏦 Провайдер: {payment_provider}\n🕐 Время: {timestamp}",
"log_payment_received_traffic": "{provider_emoji} Получен платеж\n\n👤 Пользователь: {user_display}\n💰 Сумма: {amount} {currency}\n🗂 Трафик: {traffic_gb} ГБ\n🏦 Провайдер: {payment_provider}\n🕐 Время: {timestamp}",
"log_promo_activation": "🎁 Активирован промокод\n\n👤 Пользователь: {user_display}\n🏷 Код: {promo_code}\n🎯 Бонус: +{bonus_days} дн.\n🕐 Время: {timestamp}",
+ "log_promo_discount_activation": "💰 Активирован промокод на скидку\n\n👤 Пользователь: {user_display}\n🏷 Код: {promo_code}\n💵 Скидка: {discount_percentage}%\n🕐 Время: {timestamp}",
"log_trial_activation": "🆓 Активирован триал\n\n👤 Пользователь: {user_display}\n⏰ Действует до: {end_date}\n🕐 Время: {timestamp}",
"log_panel_sync": "{status_emoji} Синхронизация с панелью\n\n📊 Статус: {status}\n👥 Обработано пользователей: {users_processed}\n📋 Синхронизировано подписок: {subs_synced}\n🕐 Время: {timestamp}\n\n📝 Детали:\n{details}",
"log_suspicious_promo": "⚠️ Подозрительная попытка ввода промокода\n\n👤 Пользователь: {user_display}\n🆔 ID: {user_id}\n📝 Ввод: {suspicious_input}\n🕐 Время: {timestamp}",