Class: Update

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

Overview

This object represents an incoming update.

Instance Method Summary collapse

Constructor Details

#initialize(update) ⇒ Update

:nodoc:



15
16
17
# File 'lib/objects/update.rb', line 15

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

Instance Method Details

#callback_queryObject

Optional. New incoming callback query. Returns CallBackQuery object



88
89
90
91
92
93
# File 'lib/objects/update.rb', line 88

def callback_query
  query = @update.callback_query
  return CallBackQuery.new(qury) if query

  false
end

#callback_query?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/objects/update.rb', line 159

def callback_query?
  @update.callback_query ? true : false
end

#channel_postObject

New incoming channel post of any kind — text, photo, sticker, etc else false is returned.



52
53
54
55
56
57
# File 'lib/objects/update.rb', line 52

def channel_post
  c_post = @update.channel_post
  return Message.new(c_post) if c_post

  false
end

#channel_post?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/objects/update.rb', line 135

def channel_post?
  @update.channel_post ? true : false
end

#chosen_inline_resultObject

Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.



80
81
82
83
84
85
# File 'lib/objects/update.rb', line 80

def chosen_inline_result
  inline_result = @update.chosen_inline_result
  return ChoseInlineResult.new(inline_result) if inline_result

  false
end

#chosen_inline_result?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/objects/update.rb', line 155

def chosen_inline_result?
  @update.chosen_inline_result ? true : false
end

#edited_channel_postObject

New version of a channel post that is known to the bot and was edited. else false is returned.



61
62
63
64
65
66
# File 'lib/objects/update.rb', line 61

def edited_channel_post
  c_post = @update.edited_channel_post
  return Message.new(e_c_post) if c_post

  false
end

#edited_channel_post?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/objects/update.rb', line 143

def edited_channel_post?
  @update.edited_channel_post ? true : false
end

#edited_messageObject

New version of a message that is known to the bot and was edited else false is returned.



43
44
45
46
47
48
# File 'lib/objects/update.rb', line 43

def edited_message
  e_msg = @update.edited_message
  return Message.new(e_msg) if e_msg

  false
end

#edited_msg?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/objects/update.rb', line 139

def edited_msg?
  @update.edited_message ? true : false
end

#inline_queryObject

Optional. New incoming inline query.



69
70
71
72
73
74
# File 'lib/objects/update.rb', line 69

def inline_query
  i_query = @update.inline_query
  return InlineQuery.new(i_query) if i_query

  false
end

#inline_query?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/objects/update.rb', line 147

def inline_query?
  @update.inline_query ? true : false
end

#messageObject

New incoming message of any kind — text, photo, sticker, etc else false is returned. returns Message object



34
35
36
37
38
39
# File 'lib/objects/update.rb', line 34

def message
  msg = @update.message
  return Message.new(msg) if msg

  false
end

#msg?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/objects/update.rb', line 131

def msg?
  @update.message ? true : false
end

#new_state_poll?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/objects/update.rb', line 151

def new_state_poll?
  @update.poll ? true : false
end

#pollObject

Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.



115
116
117
118
119
120
# File 'lib/objects/update.rb', line 115

def poll
  pol = @udpate.poll
  return Poll.new(pol) if pol

  false
end

#poll_answerObject

New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.



124
125
126
127
128
129
# File 'lib/objects/update.rb', line 124

def poll_answer
  p_answer = @update.poll_answer
  return PollAnswer.new(p_answer) if p_answer

  false
end

#poll_answer?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/objects/update.rb', line 171

def poll_answer?
  @update.poll_answer ? true : false
end

#pre_checkout_queryObject

Optional. New incoming pre-checkout query. Contains full information about checkout



106
107
108
109
110
111
# File 'lib/objects/update.rb', line 106

def pre_checkout_query
  c_query = @update.pre_checkout_query
  return PreCheckoutQuery.new(p_c_query) if c_query

  false
end

#pre_checkout_query?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/objects/update.rb', line 167

def pre_checkout_query?
  @update.pre_checkout_query ? true : false
end

#shipping_queryObject

Optional. New incoming shipping query. Only for invoices with flexible price



97
98
99
100
101
102
# File 'lib/objects/update.rb', line 97

def shipping_query
  s_query = @udpate.shipping_query
  return ShippingQuery.new(s_query) if s_query

  false
end

#shipping_query?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/objects/update.rb', line 163

def shipping_query?
  @update.shipping_query ? true : false
end

#update_idObject

The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.



27
28
29
# File 'lib/objects/update.rb', line 27

def update_id
  @update.update_id
end