R
R
Roman2021-04-08 23:05:37
Python
Roman, 2021-04-08 23:05:37

How to add a message sent by a bot to the database?

Good day, how can I make sure that when I click on the inline button, the text of the message is added to the database? Or how to make it so that in '' if call.data == 'pizza': '' for each message sent by the bot, there would be different inline buttons? I will be grateful for any answer.

@bot.callback_query_handler(func=lambda call: True )
def callback_inline_button(call):
    try:
        if call.message:            
            if call.data == 'pizza':
                markup = types.InlineKeyboardMarkup(row_width=1)
                item1 = types.InlineKeyboardButton("В корзину 30см", callback_data='in_shopping cart_30')
                item2 = types.InlineKeyboardButton("В корзину 50см", callback_data='in_shopping cart_50')

                markup.add(item1, item2)
                s_s = open('photo\\shunka_syr.jfif', 'rb')
                s4 = open('photo\\syry_4.jfif', 'rb')
                dia = <b></b>open('photo\\diabola.jfif', 'rb')

                bot.send_photo(call.message.chat.id, s_s, menu.shunka_syr,
                                                        parse_mode='html', reply_markup=markup)
                bot.send_photo(call.message.chat.id, s4, menu.syry_4,
                                                        parse_mode='html', reply_markup=markup)
                bot.send_photo(call.message.chat.id, dia, menu.diabola,
                                                        parse_mode='html', reply_markup=markup)
                s_s.close()
                s4.close()
                dia.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexa2007, 2021-04-13
@no_name_2020

Here is a sample
and here is this line

if call.message:
nothing at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question