mtproto 0.0.30 → 0.0.31

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: 573ffb4ecced33cf4a62f7d2faab6ad88d9903246732dc521f3193c8bba3a0dd
4
- data.tar.gz: 68f6fb65b7121568e5a1ca7c46daf287430214de1204a7de718d4046d596d4de
3
+ metadata.gz: 7dc46e6630ceabe739c317ee739b3b23a62e60fec9164fcce46549570c2ae440
4
+ data.tar.gz: 99cfdf36c0bb6101dd1d5389ec28c81616c02ec5303ba3200cfa6caa960fe77d
5
5
  SHA512:
6
- metadata.gz: a9e3cd7660f5d50be09e4ec3e68f5d1d84c96e8cfb8a056036b1d41eb1dd4e23fdcc6fb7399d7ea922987f6a18de2be8496c8cabc94bfcd1f1ff020daa5578da
7
- data.tar.gz: e1fb03e7f7b214788fbc12fdfa859873b809f1483e5e2e008bc07d68e4d751c78b7b4c8a441489f178a809d109efc9ba8273b231ce4450eed2fde6daac85a531
6
+ metadata.gz: 8bbbf72972ce201874a7980453d776d7de4b99aa34918eb6ddee300c35cdbacda900b9a2ecf4a34faf916666fc8c98e0194e8830c58300804d98be5e5eedef27
7
+ data.tar.gz: 314835babb0a97abc5e3f75bf0f7b231d08b91c8b32d5862985f70e33edf89e39663c48bf84c74c9931e5675989f00e7b1cb2edb3a48878690afe4e790dbd4d3
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../tl/objects/export_bot_token'
4
+ require_relative '../../tl/objects/exported_bot_token'
5
+
6
+ module MTProto
7
+ class Client
8
+ class API
9
+ def export_bot_token(bot:, revoke: false)
10
+ rpc_call(TL::ExportBotToken.new(bot: bot, revoke: revoke), TL::ExportedBotToken).body.token
11
+ end
12
+ end
13
+ end
14
+ end
@@ -17,12 +17,13 @@ module MTProto
17
17
  # A `reply_to` (with optional `quote_text`/`quote_offset`) replies to a message,
18
18
  # optionally pinning the quoted fragment.
19
19
  def send_message(peer:, message: '', random_id: nil, reply_to: nil, entities: nil,
20
- parse_mode: nil, rich_markdown: nil, quote_text: nil, quote_offset: nil, no_webpage: false)
20
+ parse_mode: nil, rich_markdown: nil, quote_text: nil, quote_offset: nil, no_webpage: false,
21
+ reply_markup: nil)
21
22
  message, entities = Markdown.parse(message) if parse_mode && entities.nil? && rich_markdown.nil?
22
23
  rpc_call(
23
24
  TL::SendMessage.new(peer: peer, message: message, random_id: random_id, reply_to: reply_to,
24
25
  entities: entities, rich_markdown: rich_markdown, quote_text: quote_text, quote_offset: quote_offset,
25
- no_webpage: no_webpage),
26
+ no_webpage: no_webpage, reply_markup: reply_markup),
26
27
  TL::UpdateShortSentMessage
27
28
  ).body
28
29
  end
@@ -18,6 +18,7 @@ require_relative 'api/get_bot_callback_answer'
18
18
  require_relative 'api/send_message'
19
19
  require_relative 'api/set_typing'
20
20
  require_relative 'api/get_contacts'
21
+ require_relative 'api/export_bot_token'
21
22
  require_relative 'api/pin_message'
22
23
  require_relative 'api/unpin_all_messages'
23
24
  require_relative 'api/get_pinned_messages'
@@ -8,12 +8,12 @@ require_relative 'updates'
8
8
  module MTProto
9
9
  module TL
10
10
  class UpdatesDifference
11
- attr_reader :type, :date, :seq, :new_messages, :pts, :state, :chats, :users, :guest_queries
11
+ attr_reader :type, :date, :seq, :new_messages, :pts, :state, :chats, :users, :guest_queries, :managed_bots
12
12
 
13
13
  SCHEMA_PATH = File.expand_path('../../../../data/tl-schema.json', __dir__)
14
14
 
15
15
  def initialize(type:, date: nil, seq: nil, new_messages: [], pts: nil, state: nil, chats: [], users: [],
16
- guest_queries: [])
16
+ guest_queries: [], managed_bots: [])
17
17
  @type = type
18
18
  @date = date
19
19
  @seq = seq
@@ -23,6 +23,7 @@ module MTProto
23
23
  @chats = chats
24
24
  @users = users
25
25
  @guest_queries = guest_queries
26
+ @managed_bots = managed_bots
26
27
  end
27
28
 
28
29
  def self.schema
@@ -47,6 +48,7 @@ module MTProto
47
48
 
48
49
  UPDATE_NEW_MESSAGE = 0x1f2b0afd
49
50
  UPDATE_NEW_CHANNEL_MESSAGE = 0x62ba04d9
51
+ UPDATE_MANAGED_BOT = 0x4880ed9a
50
52
 
51
53
  class << self
52
54
  private
@@ -68,7 +70,7 @@ module MTProto
68
70
 
69
71
  messages, offset = parse_messages_vector(data, offset)
70
72
  offset = schema.skip_vector(data, offset) # new_encrypted_messages
71
- other_messages, guest_queries, offset = parse_other_updates(data, offset)
73
+ other_messages, guest_queries, managed_bots, offset = parse_other_updates(data, offset)
72
74
  chats, offset = Dialogs.chats_at(data, offset)
73
75
  users, offset = Dialogs.users_at(data, offset)
74
76
  state = UpdatesState.deserialize(data[offset..])
@@ -77,6 +79,7 @@ module MTProto
77
79
  type: constructor == Constructors::UPDATES_DIFFERENCE ? :difference : :slice,
78
80
  new_messages: messages + other_messages,
79
81
  guest_queries: guest_queries,
82
+ managed_bots: managed_bots,
80
83
  chats: chats, users: users, state: state
81
84
  )
82
85
  end
@@ -91,6 +94,7 @@ module MTProto
91
94
 
92
95
  messages = []
93
96
  guest_queries = []
97
+ managed_bots = []
94
98
  count.times do
95
99
  ctor = data[offset, 4].unpack1('L<')
96
100
  if [UPDATE_NEW_MESSAGE, UPDATE_NEW_CHANNEL_MESSAGE].include?(ctor)
@@ -99,10 +103,12 @@ module MTProto
99
103
  messages << msg.to_h if msg
100
104
  elsif ctor == Updates::UPDATE_BOT_GUEST_CHAT_QUERY
101
105
  guest_queries << Updates.extract_guest_query(data, offset)
106
+ elsif ctor == UPDATE_MANAGED_BOT
107
+ managed_bots << { user_id: data[offset + 4, 8].unpack1('Q<'), bot_id: data[offset + 12, 8].unpack1('Q<') }
102
108
  end
103
109
  offset = schema.skip(data, offset)
104
110
  end
105
- [messages, guest_queries, offset]
111
+ [messages, guest_queries, managed_bots, offset]
106
112
  end
107
113
 
108
114
  def parse_messages_vector(data, offset)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MTProto
4
- VERSION = '0.0.30'
4
+ VERSION = '0.0.31'
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.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Levenkov
@@ -65,6 +65,7 @@ files:
65
65
  - lib/mtproto/client/api.rb
66
66
  - lib/mtproto/client/api/check_password.rb
67
67
  - lib/mtproto/client/api/export_authorization.rb
68
+ - lib/mtproto/client/api/export_bot_token.rb
68
69
  - lib/mtproto/client/api/export_login_token.rb
69
70
  - lib/mtproto/client/api/get_bot_callback_answer.rb
70
71
  - lib/mtproto/client/api/get_channel_difference.rb