Spaces:
Building
Building
import telebot | |
import socks | |
import socket | |
# Proxy configuration | |
PROXY_HOST = '64.29.87.81' | |
PROXY_PORT = 48558 | |
PROXY_USERNAME = 'KNaDX4iRd2t6El0' | |
PROXY_PASSWORD = 'NleyoQHQJwHbqSH' | |
# Configure SOCKS proxy | |
socks.set_default_proxy(socks.SOCKS5, PROXY_HOST, PROXY_PORT, username=PROXY_USERNAME, password=PROXY_PASSWORD) | |
socket.socket = socks.socksocket | |
# Initialize the bot with your API token | |
API_TOKEN = '7484321656:AAExhpS7sOGMu2BCuPQrDjuXpY3sEQmBgfY' | |
bot = telebot.TeleBot(API_TOKEN) | |
def handle_start(message): | |
# Extract username from message | |
username = message.from_user.username or "Guest" | |
# Construct URL with username | |
encoded_url = f"https://measmonysuon-webapp.hf.space/?username={username}" | |
# Send a message with the inline button to open the web app | |
markup = telebot.types.InlineKeyboardMarkup() | |
button = telebot.types.InlineKeyboardButton( | |
text="Open Web App", | |
web_app=telebot.types.WebAppInfo(url=encoded_url) | |
) | |
markup.add(button) | |
bot.send_message( | |
message.chat.id, | |
f"Welcome, {username}! Click the button below to open the web app:", | |
reply_markup=markup | |
) | |
bot.polling() |