B
B
Bogdan2018-05-21 16:07:44
Ruby on Rails
Bogdan, 2018-05-21 16:07:44

Did you send a command when you clicked the KeyboardButton?

Hello. Can you please tell me how to send a command when pressing the KeyboardButton button, for example, when pressing the Settings button, the /settings command is sent.
Of course, you can make the command the name of the "/settings" button, but this is somehow ugly. I write in ruby, but the example is suitable from any language, I think I can figure it out.

markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: [%w(Settings), %w(Help)], resize_keyboard: true, one_time_keyboard: true)
    respond_with :message, text: I18n.t(:settings), reply_markup: markup.to_hash

Now like this:
5b02c49b54de1922386636.png
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-05-21
@Sanasol

no way to do "normal".
It is necessary to map the words to the necessary commands in the code.
I use a lazy option on buttons text in the form "/r Command"
Where /r is a command that runs other commands by "keyword".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question