-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answers ReplyKeyboardMarkup #26
Comments
Following code did the job perfectly: require 'bundler/setup'
require 'telegram/bot'
token = 'secret'
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
option = 'What you wanna do?'
answers = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: [%w(Add Remove), %w(Search)], one_time_keyboard: true)
bot.api.send_message(chat_id: message.chat.id, text: option, reply_markup: answers)
end
end Proof pic: Seems like something wrong with your code, not the gem. |
Yes, it works but i wanna do stg like:
...and depending the users' option, i will do an action. The problem is, how can i get the value i choose? |
Sorry, pressed the wrong button and reopened. lol |
I got you. You have to store somehow user's current state and decide what to do depending on this state. In your example, you need to change user's state to "adding_something" if he/she types "/help" and chooses "Add". All next incoming messages from that user should be processed according his state. So, if user with state "adding_something" types "/help" again, you have treat it as a string, not a command to show the help menu. I did something similar here: https://github.com/atipugin/telekrug. It uses sinatra + webhooks, but in general idea is the same. Take a look here: https://github.com/atipugin/telekrug/blob/master/app/workers/process_message.rb. This class (sidekiq worker) handles each incoming message from any user. |
Yeah, i understood but i' having problem to get the 'Add' string when you press the option, in this case my reply to the question. A simple message.text was not supposed to get it?
Sorry if it's a newbie question, i'm learning ruby with this project. |
It doesn't work this way. You can't handle answers inside |
How can I get the ReplyKeyboardMarkup answer to interact with the user?
I've tried something like
for the given code
but just returned an object.
Thanks
The text was updated successfully, but these errors were encountered: