-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
47 lines (39 loc) · 1.51 KB
/
bot.py
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
42
43
44
45
46
47
from telebot import types, TeleBot
from config import TOKEN, URL
payment_bot = TeleBot(TOKEN)
@payment_bot.message_handler(commands=['start'])
def start(message):
# Создаем веб-приложение и кнопку к ней
payment_web_app = types.WebAppInfo(
title='Payment',
description='Payment by user for service',
url=URL+f'/pay/?user_id={message.from_user.id}',
method='get',
)
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.add(
types.KeyboardButton('Оплата', web_app=payment_web_app),
)
# Отправляем сообщение с кнопкой
payment_bot.send_message(
message.chat.id,
'Добро пожаловать, {}!'.format(message.from_user.first_name),
reply_markup=keyboard,
)
@payment_bot.message_handler(content_types=['text'])
def text(message):
payment_web_app = types.WebAppInfo(
title='Payment',
description='Payment by user for service',
url=URL+f'/pay/?user_id={message.from_user.id}',
method='get',
)
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.add(
types.KeyboardButton('Оплата', web_app=payment_web_app),
)
payment_bot.send_message(
message.chat.id,
'Оплата производится внутри бота, нажмите на кнопку "Оплата"',
reply_markup=keyboard,
)