Answer the question
In order to leave comments, you need to log in
How to make buttons and vote count under a post on pytelegrambotapi?
I want to make that under the message there were buttons. You click on one: the value is added to it. On the other also. But what would you press it was possible only 1 time.
Can you please advise how to do this?
Answer the question
In order to leave comments, you need to log in
Welcome to the very nasty side of the Telegram API!
The topic touches on the most annoying, complex and forever idle side of the Telegram Bot!
We have to work with edit_message_text also with call, and of course with the database!
PS The following code assumes that you know very well how to work with sqlite3 in python
You should create a table in the database where you will record the user_id of all who pressed at least one button, and 2 more columns for each button with the total result of the number of all users who pressed her.
Add a message with a button
def deffers():
cursor.execute('SELECT obshee_1 FROM tablica')
knopach1 = cursor.fetchone()
cursor.execute('SELECT obshee_2 FROM tablica')
knopach2 = cursor.fetchone()
klava = types.InlineKeyboardMarkup()
button1=types.InlineKeyboardButton(text='Всего: '+knopach1[0], callback_data='knopka1')
button2=types.InlineKeyboardButton(text='Всего: '+knopach2[0], callback_data='knopka2')
bot.send_message(message.text, 'Ваше абсолютно любое сообщение. Абсолютно любое.', reply_markup=klava)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question