H
H
HeLDaN2022-01-20 21:38:33
Python
HeLDaN, 2022-01-20 21:38:33

How to create a button in FSM, so that later it can be displayed through the database?

Hi all. I would like to know how to create a button in FSM, and then display it from the sqlite3 database.
In short, they make an admin panel and I want it to be possible to create a post through it, so that the content includes (photo, text, inline button). I hope I explained clearly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-01-20
@SoreMix

If I understood correctly, then you want to send a button to the bot in the PM and then create a post from this button and text with a photo, which will then go to the group. You can’t send the button itself, so just create it in code, like everything else. Let's say the text and photo were sent, then the state is hung up, which will lead to the button creation function, there it's just a text link sent to the bot, and a button is created in the code. In general, no buttons need to be sent. You just make a normal handler that will accept your text as a link. Either is not specified, let it be aiogram then

@dp.message_handler(state=Form.button)
async def process_button(message: types.Message, state: FSMContext):

    # ну и тут дальше, либо новые шаги, либо сразу публикация 
    inline_kb = InlineKeyboardMarkup()
    inline_kb.add(InlineKeyboardButton('Ссылка на страницу', url=message.text))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question