Class: MTProto::TL::ForwardMessages

Inherits:
Object
  • Object
show all
Includes:
Binary
Defined in:
lib/mtproto/tl/objects/forward_messages.rb

Constant Summary collapse

CONSTRUCTOR =
0x978928ca

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(from_peer:, to_peer:, ids:, random_ids: nil, drop_author: false, drop_media_captions: false) ⇒ ForwardMessages

Returns a new instance of ForwardMessages.



12
13
14
15
16
17
18
19
# File 'lib/mtproto/tl/objects/forward_messages.rb', line 12

def initialize(from_peer:, to_peer:, ids:, random_ids: nil, drop_author: false, drop_media_captions: false)
  @from_peer = from_peer
  @to_peer = to_peer
  @ids = ids
  @random_ids = random_ids || Array.new(ids.length) { SecureRandom.random_number(2**63) }
  @drop_author = drop_author
  @drop_media_captions = drop_media_captions
end

Instance Method Details

#serializeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mtproto/tl/objects/forward_messages.rb', line 21

def serialize
  flags = 0
  flags |= (1 << 11) if @drop_author
  flags |= (1 << 12) if @drop_media_captions

  result = u32_b(CONSTRUCTOR)
  result += u32_b(flags)
  result += serialize_input_peer(@from_peer)
  result += u32_b(Constructors::VECTOR) + u32_b(@ids.length)
  @ids.each { |id| result += u32_b(id) }
  result += u32_b(Constructors::VECTOR) + u32_b(@random_ids.length)
  @random_ids.each { |rid| result += u64_b(rid) }
  result += serialize_input_peer(@to_peer)
  result
end