Class: BotTelegram::Custom::Message
- Inherits:
-
Object
- Object
- BotTelegram::Custom::Message
- Defined in:
- lib/tramway/bots/telegram/message.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #build_options(button) ⇒ Object
-
#initialize(text: nil, file: nil, reply_markup: nil, inline_keyboard: nil) ⇒ Message
constructor
A new instance of Message.
- #options ⇒ Object
Constructor Details
#initialize(text: nil, file: nil, reply_markup: nil, inline_keyboard: nil) ⇒ Message
Returns a new instance of Message.
8 9 10 11 12 13 14 15 |
# File 'lib/tramway/bots/telegram/message.rb', line 8 def initialize(text: nil, file: nil, reply_markup: nil, inline_keyboard: nil) raise 'You set text: argument for message' unless text.present? @text = text @file = file @reply_markup = reply_markup @inline_keyboard = inline_keyboard end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/tramway/bots/telegram/message.rb', line 6 def file @file end |
Instance Method Details
#build_options(button) ⇒ Object
17 18 19 20 21 |
# File 'lib/tramway/bots/telegram/message.rb', line 17 def () = { text: [0] } .merge! callback_data: [1][:data].to_json if [1][:data].present? Telegram::Bot::Types::InlineKeyboardButton.new(**) end |
#options ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tramway/bots/telegram/message.rb', line 23 def arguments = {} arguments.merge!(text: @text) if @text.present? if @reply_markup.present? arguments.merge!(reply_markup: Telegram::Bot::Types::ReplyKeyboardMarkup.new(**@reply_markup)) elsif @inline_keyboard.present? keyboard = @inline_keyboard.map do || if [0].is_a? Array .map do |b| b end else end end arguments.merge!(reply_markup: Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: keyboard)) end arguments end |