This commit is contained in:
2025-09-14 17:15:48 +00:00
commit 4dee2bb54c
40 changed files with 739 additions and 0 deletions

32
bot.py Normal file
View File

@@ -0,0 +1,32 @@
import os
import asyncio
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, WebAppInfo
from telegram.ext import Application, CommandHandler, ContextTypes
TELEGRAM_TOKEN = os.getenv("TELEGRAM_TOKEN")
WEBAPP_URL = os.getenv("WEBAPP_URL", "https://yourdomain.com/webapp") # из .env или дефолт
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
"""Обработка команды /start"""
keyboard = [
[InlineKeyboardButton("🚀 Открыть чат", web_app=WebAppInfo(url=WEBAPP_URL))]
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(
"Привет! Нажми кнопку ниже, чтобы открыть WebApp 👇",
reply_markup=reply_markup
)
def main():
# Создаём приложение
app = Application.builder().token(TELEGRAM_TOKEN).build()
# Добавляем обработчик команды /start
app.add_handler(CommandHandler("start", start))
# Запускаем (асинхронно работает внутри run_polling)
print("🚀 Бот запущен. Нажми /start в чате с ним.")
app.run_polling()
if __name__ == "__main__":
main()