Module: Telegram::Bot::UpdatesController::ReplyHelpers
- Included in:
- Telegram::Bot::UpdatesController
- Defined in:
- lib/telegram/bot/updates_controller/reply_helpers.rb
Instance Method Summary collapse
-
#answer_callback_query(text, params = {}) ⇒ Object
Same as reply_with, but for callback queries.
-
#answer_inline_query(results, params = {}) ⇒ Object
Same as reply_with, but for inline queries.
-
#reply_with(type, params) ⇒ Object
Same as respond_with but also sets ‘reply_to_message_id`.
-
#respond_with(type, params) ⇒ Object
Helper to call bot’s ‘send_#type` method with already set `chat_id`:.
Instance Method Details
#answer_callback_query(text, params = {}) ⇒ Object
Same as reply_with, but for callback queries.
34 35 36 37 38 39 40 |
# File 'lib/telegram/bot/updates_controller/reply_helpers.rb', line 34 def answer_callback_query(text, params = {}) params = params.merge( callback_query_id: payload['id'], text: text, ) bot.answer_callback_query(params) end |
#answer_inline_query(results, params = {}) ⇒ Object
Same as reply_with, but for inline queries.
25 26 27 28 29 30 31 |
# File 'lib/telegram/bot/updates_controller/reply_helpers.rb', line 25 def answer_inline_query(results, params = {}) params = params.merge( inline_query_id: payload['id'], results: results, ) bot.answer_inline_query(params) end |
#reply_with(type, params) ⇒ Object
Same as respond_with but also sets ‘reply_to_message_id`.
17 18 19 20 21 22 |
# File 'lib/telegram/bot/updates_controller/reply_helpers.rb', line 17 def reply_with(type, params) payload = self.payload = payload && payload['message_id'] params = params.merge(reply_to_message_id: ) if respond_with(type, params) end |
#respond_with(type, params) ⇒ Object
Helper to call bot’s ‘send_#type` method with already set `chat_id`:
respond_with :message, text: 'Hello!'
respond_with :message, text: '__Hello!__', parse_mode: :Markdown
respond_with :photo, photo: File.open(photo_to_send), caption: "It's incredible!"
10 11 12 13 14 |
# File 'lib/telegram/bot/updates_controller/reply_helpers.rb', line 10 def respond_with(type, params) chat = self.chat chat_id = chat && chat['id'] or raise 'Can not respond_with when chat is not present' bot.public_send("send_#{type}", params.merge(chat_id: chat_id)) end |