Audio / bot.py
Winhaa's picture
Upload bot.py
b99b626 verified
Raw
History Blame Contribute Delete
1.24 kB
import logging
import os
from telegram import Update, WebAppInfo, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler
# Enable logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
# Replace with your bot token and web app URL
TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN", "YOUR_BOT_TOKEN")
WEB_APP_URL = os.getenv("WEB_APP_URL", "https://your-webapp-url.com") # This will be the URL where your React app is hosted
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
keyboard = [
[
InlineKeyboardButton(
text="Open HCY Audio System",
web_app=WebAppInfo(url=WEB_APP_URL)
)
]
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text(
"Welcome to HCY Audio System! Click the button below to open the Mini App.",
reply_markup=reply_markup
)
def main():
application = ApplicationBuilder().token(TELEGRAM_BOT_TOKEN).build()
application.add_handler(CommandHandler("start", start))
application.run_polling()
if __name__ == "__main__":
main()