Module: MTProto::TL::MessageService

Defined in:
lib/mtproto/tl/objects/message_service.rb

Overview

The header of messageService#7a800e0a — the chat event (a join, a leave, a title change) that rides the same Vector as a plain message. The walk stops at the MessageAction, whose meaning belongs to the caller: it reads the action itself, from action_offset.

Defined Under Namespace

Classes: Header

Constant Summary collapse

MESSAGE_SERVICE =
0x7a800e0a

Class Method Summary collapse

Class Method Details

.deserialize(data, offset, constructor) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mtproto/tl/objects/message_service.rb', line 18

def deserialize(data, offset, constructor)
  return unless constructor == MESSAGE_SERVICE

  offset += 4 # constructor
  flags = data[offset, 4].unpack1('L<')
  offset += 4
  id = data[offset, 4].unpack1('l<')
  offset += 4

  from_id = nil
  _from_type, from_id, offset = Reader.parse_peer(data, offset) if flags.anybits?(1 << 8) # from_id (Peer)
  peer_type, peer_id, offset = Reader.parse_peer(data, offset)
  offset = Reader.schema.skip(data, offset) if flags.anybits?(1 << 28) # saved_peer_id
  offset = Reader.schema.skip(data, offset) if flags.anybits?(1 << 3) # reply_to

  date = data[offset, 4].unpack1('L<')

  Header.new(id: id, date: date, from_id: from_id,
    peer_type: peer_type, peer_id: peer_id, action_offset: offset + 4)
end