File size: 1,224 Bytes
2d02379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)

@bot.message_handler(commands=['start'])
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()