Class: MTProto::TL::Messages
- Inherits:
-
Object
- Object
- MTProto::TL::Messages
- Defined in:
- lib/mtproto/tl/objects/messages.rb
Overview
A messages.messages / messagesSlice / channelMessages container (e.g. the messages.getHistory reply). Its messages are TL::Message instances.
Constant Summary collapse
- MESSAGES_MESSAGES =
0x1d73e7ea- MESSAGES_SLICE =
0x5f206716- MESSAGES_CHANNEL =
0xc776ba4e- 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.
19 20 21 22 |
# File 'lib/mtproto/tl/objects/messages.rb', line 19 def initialize(messages:, count: nil) @messages = @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
17 18 19 |
# File 'lib/mtproto/tl/objects/messages.rb', line 17 def count @count end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
17 18 19 |
# File 'lib/mtproto/tl/objects/messages.rb', line 17 def @messages end |
Class Method Details
.deserialize(data) ⇒ Object
34 35 36 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 |
# File 'lib/mtproto/tl/objects/messages.rb', line 34 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
24 25 26 |
# File 'lib/mtproto/tl/objects/messages.rb', line 24 def slice? !@count.nil? end |