Class: MTProto::TL::SendMedia

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

Constant Summary collapse

INPUT_REPLY_TO_MESSAGE =
0x3bd4b7c2
INPUT_MEDIA_PHOTO =
0xe3af4434
INPUT_MEDIA_DOCUMENT =
0xa8763ab5
INPUT_PHOTO =
0x3bb3b94a
INPUT_DOCUMENT =
0x1abfb575

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(peer:, media:, message: '', random_id: nil, reply_to: nil, silent: false, reply_markup: nil) ⇒ SendMedia

Returns a new instance of SendMedia.



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

def initialize(peer:, media:, message: '', random_id: nil, reply_to: nil, silent: false, reply_markup: nil)
  @peer = peer
  @media = media
  @message = message
  @random_id = random_id || SecureRandom.random_number(2**63)
  @reply_to = reply_to
  @silent = silent
  @reply_markup = reply_markup
end

Instance Method Details

#serializeObject



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

def serialize
  flags = 0
  flags |= (1 << 0) if @reply_to
  flags |= (1 << 2) if @reply_markup
  flags |= (1 << 5) if @silent

  result = u32_b(Constructors::MESSAGES_SEND_MEDIA)
  result += u32_b(flags)
  result += serialize_input_peer
  result += serialize_reply_to if @reply_to
  result += serialize_input_media
  result += serialize_tl_string(@message)
  result += u64_b(@random_id)
  result += @reply_markup.serialize if @reply_markup
  result
end