Class: MTProto::TL::SendMessageAction

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

Overview

A SendMessageAction — the payload of messages.setTyping. Every variant is just its own constructor id; the upload/import variants additionally carry a progress:int (0-100). One class covers them all.

Constant Summary collapse

CONSTRUCTORS =
{
  typing: 0x16bf744e,
  cancel: 0xfd5ec8f5,
  record_audio: 0xd52f73f7,
  upload_audio: 0xf351d7ab,
  record_video: 0xa187d66f,
  upload_video: 0xe9763aec,
  record_round: 0x88f27fbc,
  upload_round: 0x243e1c66,
  upload_photo: 0xd1d34a26,
  upload_document: 0xaa0cd9e4,
  geo_location: 0x176f8ba1,
  choose_contact: 0x628cbc6f,
  choose_sticker: 0xb05ac6b1,
  game_play: 0xdd6a8f48,
  history_import: 0xdbda9246
}.freeze
WITH_PROGRESS =
%i[upload_audio upload_video upload_round upload_photo upload_document history_import].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(type, progress: 0) ⇒ SendMessageAction

Returns a new instance of SendMessageAction.



35
36
37
38
# File 'lib/mtproto/tl/objects/send_message_action.rb', line 35

def initialize(type, progress: 0)
  @type = type
  @progress = progress
end

Class Method Details

.typesObject



31
32
33
# File 'lib/mtproto/tl/objects/send_message_action.rb', line 31

def self.types
  CONSTRUCTORS.keys
end

Instance Method Details

#serializeObject



40
41
42
43
44
45
# File 'lib/mtproto/tl/objects/send_message_action.rb', line 40

def serialize
  id = CONSTRUCTORS.fetch(@type) { raise ArgumentError, "unknown SendMessageAction: #{@type}" }
  result = u32_b(id)
  result += u32_b(@progress) if WITH_PROGRESS.include?(@type)
  result
end