Class: MTProto::TL::UpdatesDifference

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

Constant Summary collapse

SCHEMA_PATH =
File.expand_path('../../../../data/tl-schema.json', __dir__)
MESSAGE_CONSTRUCTOR =
Constructors::MESSAGE
MESSAGE_SERVICE =
0x7a800e0a
MESSAGE_EMPTY =
0x90a6ca84
MESSAGE_REPLY_HEADER =
0x6917560b
MEDIA_PHOTO =
0x695150d7
MEDIA_DOCUMENT =
0x52d8ccd9
UPDATE_NEW_MESSAGE =
0x1f2b0afd
UPDATE_NEW_CHANNEL_MESSAGE =
0x62ba04d9

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, date: nil, seq: nil, new_messages: [], pts: nil, state: nil, chats: [], users: []) ⇒ UpdatesDifference

Returns a new instance of UpdatesDifference.



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

def initialize(type:, date: nil, seq: nil, new_messages: [], pts: nil, state: nil, chats: [], users: [])
  @type = type
  @date = date
  @seq = seq
  @new_messages = new_messages
  @pts = pts
  @state = state
  @chats = chats
  @users = users
end

Instance Attribute Details

#chatsObject (readonly)

Returns the value of attribute chats.



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

def chats
  @chats
end

#dateObject (readonly)

Returns the value of attribute date.



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

def date
  @date
end

#new_messagesObject (readonly)

Returns the value of attribute new_messages.



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

def new_messages
  @new_messages
end

#ptsObject (readonly)

Returns the value of attribute pts.



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

def pts
  @pts
end

#seqObject (readonly)

Returns the value of attribute seq.



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

def seq
  @seq
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#usersObject (readonly)

Returns the value of attribute users.



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

def users
  @users
end

Class Method Details

.deserialize(data) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mtproto/tl/objects/updates_difference.rb', line 28

def self.deserialize(data)
  constructor = data[0, 4].unpack1('L<')

  case constructor
  when Constructors::UPDATES_DIFFERENCE_EMPTY
    parse_empty(data)
  when Constructors::UPDATES_DIFFERENCE, Constructors::UPDATES_DIFFERENCE_SLICE
    parse_difference(data, constructor)
  when Constructors::UPDATES_DIFFERENCE_TOO_LONG
    new(type: :too_long, pts: data[4, 4].unpack1('L<'))
  else
    warn "Unknown Difference constructor: 0x#{constructor.to_s(16)}, treating as empty"
    new(type: :empty, date: Time.now.to_i, seq: 0)
  end
end

.schemaObject



24
25
26
# File 'lib/mtproto/tl/objects/updates_difference.rb', line 24

def self.schema
  @schema ||= Schema.new(SCHEMA_PATH)
end