Class: MTProto::TL::Messages
- Inherits:
-
Object
- Object
- MTProto::TL::Messages
- Defined in:
- lib/mtproto/tl/objects/messages.rb
Defined Under Namespace
Classes: Message
Constant Summary collapse
- MESSAGES_MESSAGES =
0x8c718e87- MESSAGES_SLICE =
0x762b263d- MESSAGES_CHANNEL =
0xc776ba4e- MESSAGE =
Constructors::MESSAGE
- MESSAGE_SERVICE =
0x7a800e0a- MESSAGE_EMPTY =
0x90a6ca84- VALID_CONSTRUCTORS =
[MESSAGES_MESSAGES, MESSAGES_SLICE, MESSAGES_CHANNEL].freeze
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(messages:, count: nil) ⇒ Messages
constructor
A new instance of Messages.
- #slice? ⇒ Boolean
Constructor Details
#initialize(messages:, count: nil) ⇒ Messages
Returns a new instance of Messages.
22 23 24 25 |
# File 'lib/mtproto/tl/objects/messages.rb', line 22 def initialize(messages:, count: nil) @messages = @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
20 21 22 |
# File 'lib/mtproto/tl/objects/messages.rb', line 20 def count @count end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
20 21 22 |
# File 'lib/mtproto/tl/objects/messages.rb', line 20 def @messages end |
Class Method Details
.deserialize(data) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mtproto/tl/objects/messages.rb', line 37 def self.deserialize(data) constructor = data[0, 4].unpack1('L<') raise UnexpectedConstructorError, constructor unless VALID_CONSTRUCTORS.include?(constructor) offset = 4 count = nil case constructor when MESSAGES_MESSAGES # messages:Vector<Message> chats:Vector<Chat> users:Vector<User> when MESSAGES_SLICE # flags:# count:int next_rate:flags.0?int offset_id_offset:flags.2?int # search_flood:flags.3?SearchPostsFlood messages:Vector<Message> ... flags = data[offset, 4].unpack1('L<') offset += 4 count = data[offset, 4].unpack1('L<') offset += 4 offset += 4 if flags.anybits?(1 << 0) # next_rate offset += 4 if flags.anybits?(1 << 2) # offset_id_offset offset = schema.skip(data, offset) if flags.anybits?(1 << 3) # search_flood when MESSAGES_CHANNEL # flags:# pts:int count:int offset_id_offset:flags.2?int # messages:Vector<Message> topics:Vector<ForumTopic> ... flags = data[offset, 4].unpack1('L<') offset += 4 offset += 4 # pts count = data[offset, 4].unpack1('L<') offset += 4 offset += 4 if flags.anybits?(1 << 2) # offset_id_offset end , offset = (data, offset) # skip topics vector for channelMessages schema.skip_vector(data, offset) { |d, o| schema.skip(d, o) } if constructor == MESSAGES_CHANNEL # skip chats and users (we don't need them here) new(messages: , count: count) end |
Instance Method Details
#slice? ⇒ Boolean
27 28 29 |
# File 'lib/mtproto/tl/objects/messages.rb', line 27 def slice? !@count.nil? end |