mtproto 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d821c481442840e9ff4efd6484f531d5d51be2523ebf23c4e12f6ae1a7d397d
4
- data.tar.gz: 7c1131dfcfcafcef6e0310859d6af1f0d85ae829126288ff3084992ceafa95bf
3
+ metadata.gz: 588068f442e55e82abc279cf1ecef97f1e3f56f0581fc8517406ce81099cfcd2
4
+ data.tar.gz: a466aecbfee4bc2a65c446239efe714415f550b5e5ece284a745c51f02ec8c71
5
5
  SHA512:
6
- metadata.gz: f8fe999e48d98c6bbb5dc6335c4bc075a9a883b130cea978c81a660145f95aa3a70d6e9a4dbe9cf546a99d1cf8306e24dcf242d633a32f9d21667cd1d14f4dbd
7
- data.tar.gz: a81fee5603238bfb9d0ff7798ffcc11f45f527b4043b32737678c58336c5637e02fe53ab3e07004b5d5e1a8054d1e406196fe7bf24d59d849401b127edca63ba
6
+ metadata.gz: ab22ca4cc54eb0ee73bcdbb9a44ce0327e5464729def798644436058b1aaf63051c6c78474848c38e09dc9aab06bd7a5b2c91e460bf3a615e980b052d414e62d
7
+ data.tar.gz: 5ad6d73a68a47b04482e5c56731f47a5eadbb265a90065a9720f04370967fcb20187885867108e8f2dc6009a3d9acb83f0942017942f8b73129497a3f5152d6b
@@ -354,6 +354,11 @@ module MTProto
354
354
  constructor = response_body[0, 4].unpack1('L<')
355
355
 
356
356
  case constructor
357
+ when TL::Constructors::GZIP_PACKED
358
+ # The server gzips larger payloads (notably busy channels' update
359
+ # containers) at the top level too, not only inside rpc_result. Inflate
360
+ # and re-route the inner message, or these updates are silently dropped.
361
+ process_message(TL::GzipPacked.unpack(response_body), server_msg_id)
357
362
  when TL::Constructors::MSG_CONTAINER
358
363
  handle_container(response_body)
359
364
  when TL::Constructors::RPC_RESULT
@@ -443,7 +443,8 @@ module MTProto
443
443
  offset += 8 if flags2.anybits?(1 << 14) # bot_verification_icon
444
444
  offset += 8 if flags2.anybits?(1 << 15) # send_paid_messages_stars
445
445
 
446
- [{ id: id, first_name: first_name, last_name: last_name, username: username, access_hash: access_hash }, offset]
446
+ [{ id: id, first_name: first_name, last_name: last_name, username: username,
447
+ is_bot: flags.anybits?(1 << 14), access_hash: access_hash }, offset]
447
448
  end
448
449
 
449
450
  # --- TL string ---
@@ -2,11 +2,13 @@
2
2
 
3
3
  require_relative '../schema'
4
4
  require_relative 'message'
5
+ require_relative 'dialogs'
5
6
 
6
7
  module MTProto
7
8
  module TL
8
9
  # A messages.messages / messagesSlice / channelMessages container (e.g. the
9
- # messages.getHistory reply). Its messages are TL::Message instances.
10
+ # messages.getHistory / messages.getMessages reply). Its messages are
11
+ # TL::Message instances.
10
12
  class Messages
11
13
  MESSAGES_MESSAGES = 0x1d73e7ea
12
14
  MESSAGES_SLICE = 0x5f206716
@@ -14,11 +16,13 @@ module MTProto
14
16
 
15
17
  VALID_CONSTRUCTORS = [MESSAGES_MESSAGES, MESSAGES_SLICE, MESSAGES_CHANNEL].freeze
16
18
 
17
- attr_reader :messages, :count
19
+ attr_reader :messages, :count, :users, :chats
18
20
 
19
- def initialize(messages:, count: nil)
21
+ def initialize(messages:, count: nil, users: [], chats: [])
20
22
  @messages = messages
21
23
  @count = count
24
+ @users = users
25
+ @chats = chats
22
26
  end
23
27
 
24
28
  def slice?
@@ -64,12 +68,13 @@ module MTProto
64
68
 
65
69
  messages, offset = parse_messages_vector(data, offset)
66
70
 
67
- # skip topics vector for channelMessages
68
- schema.skip_vector(data, offset) { |d, o| schema.skip(d, o) } if constructor == MESSAGES_CHANNEL
71
+ # topics:Vector<ForumTopic> precedes chats/users in all three constructors
72
+ offset = schema.skip_vector(data, offset) { |d, o| schema.skip(d, o) }
69
73
 
70
- # skip chats and users (we don't need them here)
74
+ chats, offset = Dialogs.chats_at(data, offset)
75
+ users, = Dialogs.users_at(data, offset)
71
76
 
72
- new(messages: messages, count: count)
77
+ new(messages: messages, count: count, users: users, chats: chats)
73
78
  end
74
79
 
75
80
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MTProto
4
- VERSION = '0.0.22'
4
+ VERSION = '0.0.23'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtproto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Levenkov