-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathmini_app.py
More file actions
32 lines (24 loc) · 1.17 KB
/
mini_app.py
File metadata and controls
32 lines (24 loc) · 1.17 KB
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
# The source of the "https://pytelegrambotminiapp.vercel.app" can be found in https://github.com/eternnoir/pyTelegramBotAPI/tree/master/examples/mini_app_web
from telebot import TeleBot
from telebot.types import (
ReplyKeyboardMarkup,
KeyboardButton,
WebAppInfo,
InlineKeyboardMarkup,
InlineKeyboardButton
)
BOT_TOKEN = ""
WEB_URL = "https://pytelegrambotminiapp.vercel.app"
bot = TeleBot(BOT_TOKEN)
@bot.message_handler(commands=["start"])
def start(message):
reply_keyboard_markup = ReplyKeyboardMarkup(resize_keyboard=True)
reply_keyboard_markup.row(KeyboardButton("Start MiniApp", web_app=WebAppInfo(WEB_URL)))
inline_keyboard_markup = InlineKeyboardMarkup()
inline_keyboard_markup.row(InlineKeyboardButton('Start MiniApp', web_app=WebAppInfo(WEB_URL)))
bot.reply_to(message, "Click the bottom inline button to start MiniApp", reply_markup=inline_keyboard_markup)
bot.reply_to(message, "Click keyboard button to start MiniApp", reply_markup=reply_keyboard_markup)
@bot.message_handler(content_types=['web_app_data'])
def web_app(message):
bot.reply_to(message, f'Your message is "{message.web_app_data.data}"')
bot.infinity_polling()