Restore Russian bot interface

This commit is contained in:
2026-07-20 08:58:10 +05:00
parent cea7da5d2b
commit 4adf9aa32e
7 changed files with 213 additions and 151 deletions
+27 -27
View File
@@ -36,14 +36,14 @@ async def _blocked(message: Message) -> bool:
register(message.from_user.id, message.from_user.username)
profile = get(message.from_user.id)
if profile.is_banned:
await message.answer(f"You are banned. Reason: {profile.ban_reason or '-'}")
await message.answer(f"❌ Вы заблокированы. Причина: {profile.ban_reason or ''}")
return True
cfg = load_config()
if not cfg.bot_enabled and message.from_user.id != ADMIN_ID:
await message.answer("The bot is temporarily disabled.")
await message.answer("🚫 Бот временно отключен.")
return True
if not cfg.shop_enabled and message.from_user.id != ADMIN_ID:
await message.answer("Cookie buying is temporarily disabled.")
await message.answer("🚫 Скупка cookie временно отключена.")
return True
return False
@@ -51,13 +51,13 @@ async def _blocked(message: Message) -> bool:
@router.message(StateFilter(None), F.document)
async def handle_document(message: Message):
if is_admin(message.from_user.id):
await message.answer("Admin accounts cannot sell cookies. Use /admin.")
await message.answer("👑 Администраторы не могут продавать cookie. Используйте /admin.")
return
if await _blocked(message):
return
filename = message.document.file_name or ""
if not filename.lower().endswith(".txt"):
await message.answer("Send a .txt file.")
await message.answer("❌ Отправьте файл формата .txt.")
return
path = COOKIE_FILES_DIR / f"{message.from_user.id}_{random.randint(100000, 999999)}.txt"
@@ -72,13 +72,13 @@ async def handle_document(message: Message):
@router.message(StateFilter(None), F.text & ~F.text.startswith("/"))
async def handle_text(message: Message):
if is_admin(message.from_user.id):
await message.answer("Admin accounts cannot sell cookies. Use /admin.")
await message.answer("👑 Администраторы не могут продавать cookie. Используйте /admin.")
return
if await _blocked(message):
return
text = message.text or ""
if "_|WARNING:-DO-NOT-SHARE-THIS." not in text:
await message.answer("Use the menu below or send cookie text.", reply_markup=main_menu_kb())
await message.answer("👋 Используйте меню ниже или отправьте текст с cookie.", reply_markup=main_menu_kb())
return
await process_cookies(message, text)
@@ -86,14 +86,14 @@ async def handle_text(message: Message):
async def process_cookies(message: Message, raw_text: str):
cookies, duplicates = parse_cookies_text(raw_text)
if not cookies:
await message.answer("No cookies were found in the submitted data.")
await message.answer("❌ В отправленных данных cookie не найдены.")
return
cfg = load_config()
proxies = load_proxies()
total = len(cookies)
progress = await message.answer(
f"<b>Processing cookies</b>\nTotal: {total}\nDuplicates removed: {duplicates}\nStage: validation...",
f"<b>Начинаю обработку cookie</b>\nВсего: {total}\nДубликатов удалено: {duplicates}\nЭтап: проверка...",
parse_mode="HTML",
)
@@ -110,17 +110,17 @@ async def process_cookies(message: Message, raw_text: str):
if index % 20 == 0 or index == total:
try:
await progress.edit_text(
f"<b>Validation</b>\nProgress: {index}/{total}\nValid: {len(valid)}",
f"<b>Проверка cookie</b>\nПрогресс: {index}/{total}\n✅ Валидных: {len(valid)}",
parse_mode="HTML",
)
except Exception:
pass
if not valid:
await progress.edit_text(f"No valid cookies found. Duplicates: {duplicates}")
await progress.edit_text(f"❌ Валидные cookie не найдены. Дубликатов: {duplicates}")
return
await progress.edit_text(f"<b>Checking donations</b>\nValid cookies: {len(valid)}", parse_mode="HTML")
await progress.edit_text(f"<b>Проверяю донаты</b>\nВалидных cookie: {len(valid)}", parse_mode="HTML")
donations = []
async with aiohttp.ClientSession() as session:
async def get_donation(result):
@@ -140,13 +140,13 @@ async def process_cookies(message: Message, raw_text: str):
priced, avg_used, avg_price = price_cookie_batch(donations, cfg)
if not priced:
await progress.edit_text(
f"No cookies matched the rates. Valid: {len(valid)}",
f"❌ Ни одна cookie не подошла под курсы. Валидных: {len(valid)}",
reply_markup=back_kb(),
)
return
await progress.edit_text(
f"<b>Refreshing cookies</b>\nPayable: {len(priced)}\nMethod: {'AVG' if avg_used else 'per-rate'}",
f"<b>Обновляю cookie</b>\nК оплате: {len(priced)}\nМетод: {'AVG' if avg_used else 'поштучный'}",
parse_mode="HTML",
)
fresh_ok = []
@@ -166,8 +166,8 @@ async def process_cookies(message: Message, raw_text: str):
fresh_failed += 1
try:
await progress.edit_text(
f"<b>Refreshing cookies</b>\nProgress: {min(offset + len(batch), len(priced))}/{len(priced)}\n"
f"Refreshed: {len(fresh_ok)}\nFailed: {fresh_failed}",
f"<b>Обновление cookie</b>\nПрогресс: {min(offset + len(batch), len(priced))}/{len(priced)}\n"
f"✅ Обновлено: {len(fresh_ok)}\n❌ Ошибок: {fresh_failed}",
parse_mode="HTML",
)
except Exception:
@@ -175,7 +175,7 @@ async def process_cookies(message: Message, raw_text: str):
if not fresh_ok:
await progress.edit_text(
f"No cookies could be refreshed. Valid: {len(valid)}, failed: {fresh_failed}",
f"❌ Не удалось обновить ни одной cookie. Валидных: {len(valid)}, ошибок: {fresh_failed}",
reply_markup=back_kb(),
)
return
@@ -204,30 +204,30 @@ async def process_cookies(message: Message, raw_text: str):
bot = get_bot() or message.bot
await apply_referral_payout(bot, profile.user_id, profile.username, payout, cfg.referral_percent)
method = "AVG" if avg_used else "per-rate"
method = "📊 AVG-система" if avg_used else "📋 Поштучный"
report = (
"<b>Processing complete</b>\n\n"
f"Total: {total}\nDuplicates: {duplicates}\nValid: {len(valid)}\n"
f"Payable: {len(priced)}\nRefreshed: {len(fresh_ok)}\nFailed refresh: {fresh_failed}\n"
f"Method: {method}\n"
"<b>Обработка завершена</b>\n\n"
f"Всего cookie: {total}\nДубликатов: {duplicates}\nВалидных: {len(valid)}\n"
f"Подошло под курс: {len(priced)}\nОбновлено: {len(fresh_ok)}\nОшибок обновления: {fresh_failed}\n"
f"Метод оплаты: {method}\n"
)
if avg_used:
report += f"AVG price: {avg_price:.2f} RUB\n"
report += f"\nPayout: <b>{payout:.2f} RUB</b>\nBalance: <b>{profile.balance:.2f} RUB</b>"
report += f"AVG цена за cookie: {avg_price:.2f} \n"
report += f"\n💰 Начислено: <b>{payout:.2f} </b>\n💳 Баланс: <b>{profile.balance:.2f} </b>"
await progress.edit_text(report, parse_mode="HTML", reply_markup=main_menu_kb())
await log_admin(
bot,
ADMIN_ID,
f"<b>Cookie purchase</b>\n@{profile.username or '-'} (<code>{profile.user_id}</code>)\n"
f"Total: {total}, valid: {len(valid)}, refreshed: {len(fresh_ok)}\nPayout: {payout:.2f} RUB",
f"🍪 <b>Новая покупка cookie</b>\n@{profile.username or ''} (<code>{profile.user_id}</code>)\n"
f"Всего: {total}, валидных: {len(valid)}, обновлено: {len(fresh_ok)}\nВыплачено: {payout:.2f} ",
get_log_bot(),
)
await log_admin_document(
bot,
ADMIN_ID,
str(user_file),
caption=f"robsec from <code>{profile.user_id}</code>",
caption=f"robsec от <code>{profile.user_id}</code>",
log_bot=get_log_bot(),
)
user_file.unlink(missing_ok=True)