Class: MTProto::TL::Users
- Inherits:
-
Object
- Object
- MTProto::TL::Users
- Defined in:
- lib/mtproto/tl/objects/users.rb
Defined Under Namespace
Classes: User
Class Method Summary collapse
Class Method Details
.deserialize(data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/mtproto/tl/objects/users.rb', line 9 def self.deserialize(data) constructor = data[0, 4].unpack1('L<') raise "Expected Vector constructor, got 0x#{constructor.to_s(16)}" unless constructor == Constructors::VECTOR offset = 4 count = data[offset, 4].unpack1('L<') offset += 4 users = [] count.times do user_constructor = data[offset, 4].unpack1('L<') offset += 4 next unless user_constructor == Constructors::USER flags = data[offset, 4].unpack1('L<') offset += 4 flags2 = data[offset, 4].unpack1('L<') offset += 4 id = data[offset, 8].unpack1('Q<') offset += 8 access_hash = nil if flags.anybits?(1 << 0) access_hash = data[offset, 8].unpack1('Q<') offset += 8 end first_name = nil first_name, offset = read_tl_string(data, offset) if flags.anybits?(1 << 1) last_name = nil last_name, offset = read_tl_string(data, offset) if flags.anybits?(1 << 2) username = nil username, offset = read_tl_string(data, offset) if flags.anybits?(1 << 3) phone = nil phone, offset = read_tl_string(data, offset) if flags.anybits?(1 << 4) users << User.new( id: id, access_hash: access_hash, first_name: first_name, last_name: last_name, username: username, phone: phone, flags: flags, flags2: flags2 ) break end users end |