From 96cbd243d92d543a851480d1fa6e2ab8b785654d Mon Sep 17 00:00:00 2001 From: anten-ka Date: Wed, 8 Apr 2026 23:08:04 +0300 Subject: [PATCH] v2.3.1: promo only on gotelegram launch (once/day), not after proxy setup; bot promo with 2 hosters --- gotelegram-bot/bot.py | 71 ++++++++++++++++++++++++++++++++++--------- install.sh | 6 ---- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/gotelegram-bot/bot.py b/gotelegram-bot/bot.py index 5d0f57d..f1e24fe 100644 --- a/gotelegram-bot/bot.py +++ b/gotelegram-bot/bot.py @@ -58,8 +58,10 @@ WEBSITE_ROOT = "/var/www/gotelegram-site" BACKUP_DIR = "/opt/gotelegram/backups" TEMPLATES_CATALOG = "/opt/gotelegram/templates_catalog.json" -PROMO_LINK = "https://vk.cc/ct29NQ" +PROMO_LINK_1 = "https://vk.cc/ct29NQ" +PROMO_LINK_2 = "https://vk.cc/cUxAhj" TIP_LINK = "https://pay.cloudtips.ru/p/7410814f" +PROMO_STAMP_FILE = "/opt/gotelegram/.promo_bot_last_shown" BOT_TOKEN = os.getenv("BOT_TOKEN") ALLOWED_IDS_STR = os.getenv("ALLOWED_IDS", "") @@ -277,7 +279,7 @@ def get_main_menu() -> InlineKeyboardMarkup: ], [ InlineKeyboardButton("🌐 Website/SSL", callback_data="menu_website"), - InlineKeyboardButton("🎁 Promo", callback_data="menu_promo"), + InlineKeyboardButton("🎁 Промо", callback_data="menu_promo"), ], [ InlineKeyboardButton("📊 Traffic Stats", callback_data="menu_stats"), @@ -297,7 +299,7 @@ def get_main_menu() -> InlineKeyboardMarkup: async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: - """Start command - show main menu.""" + """Start command - show main menu, promo once per day.""" if not await require_auth(update, context): return @@ -311,6 +313,13 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: welcome, reply_markup=get_main_menu(), parse_mode="HTML" ) + # Промо раз в сутки + if should_show_promo_bot(): + mark_promo_shown_bot() + await update.message.reply_text( + get_promo_text(), parse_mode="HTML" + ) + async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: """Help command - show available commands.""" @@ -1310,23 +1319,57 @@ async def cb_ssl_status(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N # ============================================================================ +def get_promo_text() -> str: + """Return promo text with 2 hosters + donate.""" + return ( + "💰 Хостинг #1 — скидка до 60%\n" + f"{PROMO_LINK_1}\n\n" + "Промокоды:\n" + " OFF60 — 60% на первый месяц\n" + " antenka20 — 20% + 3% за 3 мес\n" + " antenka6 — 15% + 5% за 6 мес\n\n" + "━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" + "💰 Хостинг #2 — скидка до 60%\n" + f"{PROMO_LINK_2}\n\n" + "Промокод:\n" + " OFF60 — 60% на первый месяц\n\n" + "━━━━━━━━━━━━━━━━━━━━━━━━━\n\n" + "☕ Донат / Чаевые\n" + f"{TIP_LINK}" + ) + + +def should_show_promo_bot() -> bool: + """Check if promo should be shown (once per 24h).""" + try: + if not os.path.exists(PROMO_STAMP_FILE): + return True + with open(PROMO_STAMP_FILE, "r") as f: + last_ts = int(f.read().strip()) + return (int(time.time()) - last_ts) >= 86400 + except (ValueError, OSError): + return True + + +def mark_promo_shown_bot() -> None: + """Mark promo as shown.""" + try: + os.makedirs(os.path.dirname(PROMO_STAMP_FILE), exist_ok=True) + with open(PROMO_STAMP_FILE, "w") as f: + f.write(str(int(time.time()))) + except OSError: + pass + + async def cb_menu_promo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: - """Promo information.""" + """Promo information — always shown from menu.""" query = update.callback_query await query.answer() - text = ( - f"🎁 GoTelegram Promo\n\n" - f"Share the love! Invite friends to use GoTelegram.\n\n" - f"Promo Link\n\n" - f"Support development:\n" - f"Send a Tip" - ) - keyboard = InlineKeyboardMarkup( - [[InlineKeyboardButton("« Back", callback_data="menu_main")]] + [[InlineKeyboardButton("« Назад", callback_data="menu_main")]] ) - await safe_edit_message(query,text, reply_markup=keyboard, parse_mode="HTML") + await safe_edit_message(query, get_promo_text(), reply_markup=keyboard, parse_mode="HTML") async def cb_menu_credits(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: diff --git a/install.sh b/install.sh index a5f29a6..f743cfb 100755 --- a/install.sh +++ b/install.sh @@ -333,9 +333,6 @@ install_lite_mode() { # Результат show_proxy_info log_success "GoTelegram v${GOTELEGRAM_VERSION} установлен! (Lite-режим)" - - # Промо при установке - show_promo_with_qr } # ── Pro-режим ──────────────────────────────────────────────────────────────── @@ -431,9 +428,6 @@ install_pro_mode() { show_proxy_info_pro "$user_domain" "$faketls_secret" echo -e " ${WHITE}Сайт:${NC} ${GREEN}https://${user_domain}${NC}" log_success "GoTelegram v${GOTELEGRAM_VERSION} установлен! (Pro-режим)" - - # Промо при установке - show_promo_with_qr } # ── Статус ───────────────────────────────────────────────────────────────────