Class: CallbackQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/callback_query.rb

Overview

Monday, August 24 2020

This object represents an incoming callback query from a callback button in an inline keyboard.

If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ CallbackQuery

:nodoc:



16
17
18
# File 'lib/objects/callback_query.rb', line 16

def initialize(query) # :nodoc:
  @query = query
end

Instance Method Details

#chat_instanceObject

Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.



49
50
51
# File 'lib/objects/callback_query.rb', line 49

def chat_instance
  @query.chat_instance
end

#dataObject

Optional. Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.



55
56
57
# File 'lib/objects/callback_query.rb', line 55

def data
  @query.data
end

#fromObject

Sender. Returns User object



26
27
28
# File 'lib/objects/callback_query.rb', line 26

def from
  User.new(@query.from)
end

#game_short_nameObject

Optional. Short name of a Game to be returned, serves as the unique identifier for the game



61
62
63
# File 'lib/objects/callback_query.rb', line 61

def game_short_name
  @query.game_short_name
end

#idObject

Unique identifier for this query.



21
22
23
# File 'lib/objects/callback_query.rb', line 21

def id
  @query.id
end

#inline_message_idObject

Optional. Identifier of the message sent via the bot in inline mode, that originated the query.



42
43
44
# File 'lib/objects/callback_query.rb', line 42

def inline_message_id
  @query.inline_message_id
end

#messageObject

Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old.



33
34
35
36
37
38
# File 'lib/objects/callback_query.rb', line 33

def message
  data = @query.message
  return Message.new(data) if data

  false
end