Class: MTProto::TL::Update

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, text: nil) ⇒ Update

Returns a new instance of Update.



8
9
10
11
# File 'lib/mtproto/tl/objects/update.rb', line 8

def initialize(type, text: nil)
  @type = type
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/mtproto/tl/objects/update.rb', line 6

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/mtproto/tl/objects/update.rb', line 6

def type
  @type
end

Class Method Details

.deserialize(bytes) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mtproto/tl/objects/update.rb', line 13

def self.deserialize(bytes)
  constructor_id = bytes[0, 4].unpack1('L<')
  type = type_name(constructor_id)

  case constructor_id
  when Constructors::UPDATE_NEW_MESSAGE
    text = extract_new_message_text(bytes)
    new(type, text: text)
  else
    new(type)
  end
end

.login_token?(constructor, body) ⇒ Boolean

Whether a top-level pushed message (as delivered to Client#on_update with its outer constructor and body) carries an updateLoginToken — the signal that a QR login token was scanned and accepted. Arrives bare or, in practice, wrapped in updateShort.

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
39
# File 'lib/mtproto/tl/objects/update.rb', line 30

def self.(constructor, body)
  case constructor
  when Constructors::UPDATE_LOGIN_TOKEN
    true
  when Constructors::UPDATE_SHORT
    UpdateShort.deserialize(body).update.type == 'login_token'
  else
    false
  end
end