A
A
Anonymous Coder2020-11-24 03:57:42
Python
Anonymous Coder, 2020-11-24 03:57:42

How to implement adding buttons from the telebot admin panel?

I'm trying to make a "menu" bot, where through the admin panel you can edit the same bot, that is, edit inline buttons or content. Well, I collected the name of the button and callback (or url) from the user. Well, I put this stuff in the database .. and then what? How to implement adding a keyboard if there is info about it in the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2020-11-24
@Geza420

We get buttons from the database in the form of an array or a multidimensional array, if with callback data:
buttons = db.get_main_buttons()
Next, we add buttons (Example without calldata):

k = types.ReplyKeyboardMarkup()
for b in buttons:
      k.add(types.KeyboardButton(b))
bot.send_message(message.chat.id, "TEXT", reply_markup=k)

With a date, a similar scheme, only from the database can be collected into a multidimensional array:

Then just repeat the steps above, but changing the button type and adding the date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question