Class: MTProto::TL::SendReaction

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

Constant Summary collapse

CONSTRUCTOR =
0xd30d78d4
REACTION_EMOJI =
0x1b2286b8

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(peer:, msg_id:, emoticons: []) ⇒ SendReaction

emoticons: array of emoji strings (a single-element array is the common case); an empty array clears the reaction.



13
14
15
16
17
# File 'lib/mtproto/tl/objects/send_reaction.rb', line 13

def initialize(peer:, msg_id:, emoticons: [])
  @peer = peer
  @msg_id = msg_id
  @emoticons = emoticons
end

Instance Method Details

#serializeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mtproto/tl/objects/send_reaction.rb', line 19

def serialize
  flags = 0
  flags |= (1 << 0) unless @emoticons.empty? # reaction field present

  result = u32_b(CONSTRUCTOR)
  result += u32_b(flags)
  result += serialize_input_peer
  result += u32_b(@msg_id)
  unless @emoticons.empty?
    result += u32_b(Constructors::VECTOR) + u32_b(@emoticons.length)
    @emoticons.each { |e| result += u32_b(REACTION_EMOJI) + serialize_tl_string(e) }
  end
  result
end