Download app.py from zjsjdjsj/nicker: direct link, hf CLI and curl.
- Browser
- Download file 4.68 kB
-
https://huggingface.co/spaces/zjsjdjsj/nicker/resolve/main/app.py
- Command line
-
hf download hf://spaces/zjsjdjsj/nicker/app.py
-
curl -L -o app.py https://huggingface.co/spaces/zjsjdjsj/nicker/resolve/main/app.py
4.68 kB
| import telebot | |
| from telebot import types | |
| import time | |
| import threading | |
| import gradio as gr | |
| # --- НАСТРОЙКИ --- | |
| TOKEN = '8317707454:AAHRAInErEdeLVO5d_NDWkYZtCMxU1wXBdw' | |
| ADMIN_ID = 0 | |
| BOT_START_TIME = int(time.time()) | |
| # Создаем бота напрямую БЕЗ apihelper.proxy (если DNS на HF заработает) | |
| bot = telebot.TeleBot(TOKEN) | |
| user_data = {} | |
| def get_stats(): | |
| now = int(time.time()) | |
| diff = now - BOT_START_TIME | |
| gifts = (diff if diff > 0 else 0) + 5243 | |
| hours_passed = diff // 3600 | |
| saved_money = (hours_passed * 5000) + 8125 | |
| return gifts, saved_money | |
| def main_menu(): | |
| gifts, saved = get_stats() | |
| kb = types.InlineKeyboardMarkup(row_width=1) | |
| kb.add( | |
| types.InlineKeyboardButton("🎁 Подарки", callback_data="nft_list"), | |
| types.InlineKeyboardButton("📱 Написать комментарий в TikTok - + 100⭐", callback_data="tiktok_task"), | |
| types.InlineKeyboardButton("👤 Профиль", callback_data="profile") | |
| ) | |
| text = (f"📍 Главное меню\n\n" | |
| f"🎁 Подарено подарков: **{gifts}**⠀\n" | |
| f"💸 Сэкономили для вас: **{saved}** ⭐\n\n" | |
| "Выбери категорию 👇") | |
| return text, kb | |
| def nft_menu(): | |
| kb = types.InlineKeyboardMarkup(row_width=1) | |
| items = ["🎭 Маска", "💼 Рюкзак", "📅 Календарь", "🍭 Лолипоп", "🦩 Фламинго", | |
| "🥥 Кокос", "🥚 Яйцо", "🍦 Мороженое", "💩 Какашка", "🧁 Кекс"] | |
| for item in items: | |
| kb.add(types.InlineKeyboardButton(f"{item} — 35 ⭐", callback_data=f"buy_{item}")) | |
| kb.add(types.InlineKeyboardButton("Назад 🔙", callback_data="to_main")) | |
| return kb | |
| def start_cmd(message): | |
| user_data[message.chat.id] = {'photos': 0, 'is_uploading': False} | |
| text, kb = main_menu() | |
| bot.send_message(message.chat.id, text, reply_markup=kb, parse_mode="Markdown") | |
| def handle_calls(call): | |
| chat_id = call.message.chat.id | |
| if call.data == "to_main": | |
| text, kb = main_menu() | |
| bot.edit_message_text(text, chat_id, call.message.message_id, reply_markup=kb, parse_mode="Markdown") | |
| elif call.data == "nft_list": | |
| bot.edit_message_text("✨ НФТ подарки:", chat_id, call.message.message_id, reply_markup=nft_menu()) | |
| elif call.data == "profile": | |
| profile_text = (f"📊 Ваш профиль!\n\n💡 ID: `{call.from_user.id}`\n" | |
| f"👤 Имя: {call.from_user.first_name}\n" | |
| f"💰 Баланс: 50\n⭐ Потрачено: 0") | |
| kb = types.InlineKeyboardMarkup().add(types.InlineKeyboardButton("Назад 🔙", callback_data="to_main")) | |
| bot.edit_message_text(profile_text, chat_id, call.message.message_id, reply_markup=kb, parse_mode="Markdown") | |
| elif call.data == "tiktok_task": | |
| kb = types.InlineKeyboardMarkup().add(types.InlineKeyboardButton("✅ Отправить скриншот", callback_data="send_screens"), | |
| types.InlineKeyboardButton("Назад 🔙", callback_data="to_main")) | |
| bot.edit_message_text("📱 Задание: 10 комментов в TikTok за 100⭐", chat_id, call.message.message_id, reply_markup=kb) | |
| elif call.data == "send_screens": | |
| user_data[chat_id] = {'photos': 0, 'is_uploading': True} | |
| bot.send_message(chat_id, "📸 Кидай 10 скринов подряд.") | |
| def handle_photo(message): | |
| chat_id = message.chat.id | |
| if chat_id in user_data and user_data[chat_id].get('is_uploading'): | |
| user_data[chat_id]['photos'] += 1 | |
| if user_data[chat_id]['photos'] == 10: | |
| bot.send_message(chat_id, "✅ Получено! Жди проверки.") | |
| user_data[chat_id]['is_uploading'] = False | |
| else: | |
| bot.send_message(chat_id, f"Принято {user_data[chat_id]['photos']}/10") | |
| # --- ЗАПУСК БОТА С ПЕРЕЗАПУСКОМ ПРИ ОШИБКЕ --- | |
| def run_bot(): | |
| while True: | |
| try: | |
| bot.polling(none_stop=True, timeout=60) | |
| except Exception as e: | |
| print(f"Ошибка: {e}") | |
| time.sleep(10) | |
| threading.Thread(target=run_bot, daemon=True).start() | |
| # --- ОБЯЗАТЕЛЬНО ДЛЯ HUGGING FACE GRADIO --- | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# БОТ ВКЛЮЧЕН") | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |