Y
Y
Yung_Cod3r2020-02-23 03:14:15
Python
Yung_Cod3r, 2020-02-23 03:14:15

How to implement the display of the desired product?

The code:

import telebot


bot = telebot.TeleBot("")
link = "t.me/..."
text = """
"""
balances_btc = [0.002, 0.004]
balances_rub = [2000, 4000]
Prices = [800, 1600]
IDs = [0, 1]
keyboard1 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard1.row("Аккаунты Hydra")
keyboard1.row("Информация")
keyboard1.row("Отзывы")
keyboard1.row("Заметки HYDRA")
keyboard2 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard2.row("Купить заметку")
keyboard3 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard3.row("BTC", "QIWI")
keyboard4 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard4.row("ID товара: {ID}, Баланс: {balance1}btc - {balance2}руб, цена - {price}".format(ID=IDs[0], balance1=balances_btc[0], balance2=balances_rub[0], price=Prices[0]))
keyboard4.row("ID товара: {ID}, Баланс: {balance1}btc - {balance2}руб, цена - {price}".format(ID=IDs[1], balance1=balances_btc[1], balance2=balances_rub[1], price=Prices[1]))
btc = "bvjbftbv1c561fn1vb1ftg5n1f5"
qiwi = "+78005553535"
tg = "@Fucking_Coder"


@bot.message_handler(commands=['start'])
def hello(message):
    bot.send_message(message.chat.id, "<тут приветственное сообщение>", reply_markup=keyboard1)

@bot.message_handler(func=lambda message: message.text.lower() == "аккаунты hydra")
def cart(message):
    bot.send_message(message.chat.id, "Все доступные товары: ", reply_markup=keyboard4)

@bot.message_handler(func=lambda message: message.text.lower() == "информация")
def info(message):
    bot.send_message(message.chat.id, "<тут вся нужная информация>")

@bot.message_handler(func=lambda message: message.text.lower() == "отзывы")
def callbacks(message):
    bot.send_message(message.chat.id, "Отзывы вы можете посмотреть в нашем канале: {link}!".format(link=link))

@bot.message_handler(func=lambda message: message.text.lower() == "заметки hydra")
def notes(message):
    bot.send_message(message.chat.id, text, reply_markup=keyboard2)
    img = open("1.jpg", 'rb')
    bot.send_photo(message.chat.id, img)
    img = open("2.jpg", 'rb')
    bot.send_photo(message.chat.id, img)
    img = open("3.jpg", 'rb')
    bot.send_photo(message.chat.id, img)
    img = open("4.jpg", 'rb')
    bot.send_photo(message.chat.id, img)
    img = open("5.jpg", 'rb')
    bot.send_photo(message.chat.id, img)
    img = open("6.jpg", 'rb')
    bot.send_photo(message.chat.id, img)

@bot.message_handler(func=lambda message: message.text.lower() == "купить заметку")
def buy_note(message):
    bot.send_message(message.chat.id, "Выберите способ оплаты", reply_markup=keyboard3)

@bot.message_handler(func=lambda message: message.text.upper() == "BTC")
def pay_note1(message):
    markup = telebot.types.InlineKeyboardMarkup(row_width=1)
    button = telebot.types.InlineKeyboardButton(text='Проверить оплату', callback_data='check')
    markup.add(button)
    bot.send_message(message.chat.id, "оплатите 150р на BTC адрес: {btc}!".format(btc=btc), reply_markup=markup)

@bot.message_handler(func=lambda message: message.text.upper() == "QIWI")
def pay_note2(message):
    markup = telebot.types.InlineKeyboardMarkup(row_width=1)
    button = telebot.types.InlineKeyboardButton(text='Проверить оплату', callback_data='check')
    markup.add(button)
    bot.send_message(message.chat.id, "оплатите 150р на QIWI кошелёк: {qiwi}".format(qiwi=qiwi), reply_markup=markup)

@bot.callback_query_handler(func=lambda call: True)
def sendToPeople(call):
    if call.data == "check":
        bot.send_message(call.message.chat.id, "Успешная оплата! Для получения товара напишите {tg}".format(tg=tg))

bot.polling(none_stop=True)


Now the question itself. How to make it so that when you click on a button on the keyboard, exactly the item on which it is clicked is displayed? Since the work is simple, I would like to do without using the database. Is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2020-02-23
@Yung_Cod3r

Add callbacks to the buttons on the keyboard
And then a string of if's, which will determine what to return when pressed :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question