fix: suppress empty reward alerts and clean up referral notifications

- Silence "link for new users only" message for no-reward ad campaigns
- Show commission % in referral notifications only when > 0
- Show fixed bonus in referral notifications only when > 0
- When both bonus and commission are 0, don't promise a reward

Cherry-picked logic from PR #2822 (without version bump artifacts)
This commit is contained in:
Fringg
2026-03-29 04:59:23 +03:00
parent 2c12a4773c
commit e3d8d21b66
2 changed files with 19 additions and 8 deletions
+1 -1
View File
@@ -792,7 +792,7 @@ async def cmd_start(message: types.Message, state: FSMContext, db: AsyncSession,
)
)
if campaign:
if campaign and not campaign.is_none_bonus:
try:
await message.answer(
texts.t(
+18 -7
View File
@@ -213,16 +213,23 @@ async def process_referral_registration(db: AsyncSession, new_user_id: int, refe
f'По вашей ссылке зарегистрировался пользователь <b>{html.escape(new_user.full_name)}</b>!\n\n'
f'💰 Когда он пополнит баланс от {settings.format_price(settings.REFERRAL_MINIMUM_TOPUP_KOPEKS)}, '
)
if settings.REFERRAL_INVITER_BONUS_KOPEKS > 0:
if settings.REFERRAL_INVITER_BONUS_KOPEKS > 0 and commission_percent > 0:
inviter_notification += (
f'вы получите {settings.format_price(settings.REFERRAL_INVITER_BONUS_KOPEKS)} + '
f'{commission_percent}% от суммы пополнения.\n\n'
)
else:
elif settings.REFERRAL_INVITER_BONUS_KOPEKS > 0:
inviter_notification += (
f'вы получите {settings.format_price(settings.REFERRAL_INVITER_BONUS_KOPEKS)}.\n\n'
)
elif commission_percent > 0:
inviter_notification += f'вы получите {commission_percent}% от суммы.\n\n'
inviter_notification += (
f'📈 С каждого последующего пополнения вы будете получать {commission_percent}% комиссии.'
)
else:
inviter_notification += 'вы получите уведомление.\n\n'
if commission_percent > 0:
inviter_notification += (
f'📈 С каждого последующего пополнения вы будете получать {commission_percent}% комиссии.'
)
await send_referral_notification(
bot, referrer.telegram_id, inviter_notification, user=referrer, referral_name=new_user.full_name
)
@@ -430,9 +437,13 @@ async def process_referral_topup(db: AsyncSession, user_id: int, topup_amount_ko
f'Ваш реферал <b>{html.escape(user.full_name)}</b> сделал первое пополнение '
f'на {settings.format_price(topup_amount_kopeks)}!\n\n'
f'🎁 Ваша награда: {settings.format_price(inviter_bonus)}'
f' ({bonus_breakdown})\n\n'
f'📈 Теперь с каждого его пополнения вы будете получать {commission_percent}% комиссии.'
f' ({bonus_breakdown})'
)
if commission_percent > 0:
inviter_bonus_notification += (
f'\n\n📈 Теперь с каждого его пополнения вы будете получать '
f'{commission_percent}% комиссии.'
)
await send_referral_notification(
bot,
referrer.telegram_id,