telegram-bot-ruby 0.23.0 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.env.sample +2 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -1
  5. data/README.md +25 -13
  6. data/Rakefile +43 -0
  7. data/lib/telegram/bot/types/animation.rb +9 -9
  8. data/lib/telegram/bot/types/audio.rb +9 -9
  9. data/lib/telegram/bot/types/base.rb +3 -2
  10. data/lib/telegram/bot/types/bot_command.rb +2 -2
  11. data/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb +1 -1
  12. data/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb +1 -1
  13. data/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb +1 -1
  14. data/lib/telegram/bot/types/bot_command_scope_chat.rb +2 -2
  15. data/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +2 -2
  16. data/lib/telegram/bot/types/bot_command_scope_chat_member.rb +3 -3
  17. data/lib/telegram/bot/types/bot_command_scope_default.rb +1 -1
  18. data/lib/telegram/bot/types/callback_query.rb +6 -6
  19. data/lib/telegram/bot/types/chat.rb +27 -28
  20. data/lib/telegram/bot/types/chat_administrator_rights.rb +13 -12
  21. data/lib/telegram/bot/types/chat_invite_link.rb +8 -8
  22. data/lib/telegram/bot/types/chat_join_request.rb +3 -3
  23. data/lib/telegram/bot/types/chat_location.rb +1 -1
  24. data/lib/telegram/bot/types/chat_member.rb +0 -22
  25. data/lib/telegram/bot/types/chat_member_administrator.rb +26 -0
  26. data/lib/telegram/bot/types/chat_member_banned.rb +13 -0
  27. data/lib/telegram/bot/types/chat_member_left.rb +12 -0
  28. data/lib/telegram/bot/types/chat_member_member.rb +12 -0
  29. data/lib/telegram/bot/types/chat_member_owner.rb +14 -0
  30. data/lib/telegram/bot/types/chat_member_restricted.rb +23 -0
  31. data/lib/telegram/bot/types/chat_member_updated.rb +2 -2
  32. data/lib/telegram/bot/types/chat_permissions.rb +9 -8
  33. data/lib/telegram/bot/types/chat_photo.rb +4 -4
  34. data/lib/telegram/bot/types/chosen_inline_result.rb +4 -4
  35. data/lib/telegram/bot/types/contact.rb +5 -5
  36. data/lib/telegram/bot/types/dice.rb +2 -2
  37. data/lib/telegram/bot/types/document.rb +6 -6
  38. data/lib/telegram/bot/types/encrypted_credentials.rb +3 -3
  39. data/lib/telegram/bot/types/encrypted_passport_element.rb +10 -10
  40. data/lib/telegram/bot/types/file.rb +4 -4
  41. data/lib/telegram/bot/types/force_reply.rb +3 -3
  42. data/lib/telegram/bot/types/forum_topic.rb +14 -0
  43. data/lib/telegram/bot/types/forum_topic_closed.rb +10 -0
  44. data/lib/telegram/bot/types/forum_topic_created.rb +13 -0
  45. data/lib/telegram/bot/types/forum_topic_reopened.rb +10 -0
  46. data/lib/telegram/bot/types/game.rb +6 -6
  47. data/lib/telegram/bot/types/game_high_score.rb +2 -2
  48. data/lib/telegram/bot/types/inline_keyboard_button.rb +9 -9
  49. data/lib/telegram/bot/types/inline_keyboard_markup.rb +1 -1
  50. data/lib/telegram/bot/types/inline_query.rb +5 -5
  51. data/lib/telegram/bot/types/inline_query_result_article.rb +10 -10
  52. data/lib/telegram/bot/types/inline_query_result_audio.rb +11 -10
  53. data/lib/telegram/bot/types/inline_query_result_cached_audio.rb +8 -7
  54. data/lib/telegram/bot/types/inline_query_result_cached_document.rb +10 -9
  55. data/lib/telegram/bot/types/inline_query_result_cached_gif.rb +9 -8
  56. data/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb +9 -8
  57. data/lib/telegram/bot/types/inline_query_result_cached_photo.rb +10 -9
  58. data/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +5 -5
  59. data/lib/telegram/bot/types/inline_query_result_cached_video.rb +10 -9
  60. data/lib/telegram/bot/types/inline_query_result_cached_voice.rb +9 -8
  61. data/lib/telegram/bot/types/inline_query_result_contact.rb +11 -11
  62. data/lib/telegram/bot/types/inline_query_result_document.rb +14 -13
  63. data/lib/telegram/bot/types/inline_query_result_game.rb +4 -4
  64. data/lib/telegram/bot/types/inline_query_result_gif.rb +14 -12
  65. data/lib/telegram/bot/types/inline_query_result_location.rb +14 -14
  66. data/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +14 -13
  67. data/lib/telegram/bot/types/inline_query_result_photo.rb +13 -12
  68. data/lib/telegram/bot/types/inline_query_result_venue.rb +15 -15
  69. data/lib/telegram/bot/types/inline_query_result_video.rb +15 -14
  70. data/lib/telegram/bot/types/inline_query_result_voice.rb +10 -9
  71. data/lib/telegram/bot/types/input_contact_message_content.rb +4 -4
  72. data/lib/telegram/bot/types/input_invoice_message_content.rb +20 -20
  73. data/lib/telegram/bot/types/input_location_message_content.rb +6 -6
  74. data/lib/telegram/bot/types/input_media_animation.rb +9 -8
  75. data/lib/telegram/bot/types/input_media_audio.rb +9 -8
  76. data/lib/telegram/bot/types/input_media_document.rb +7 -7
  77. data/lib/telegram/bot/types/input_media_photo.rb +5 -4
  78. data/lib/telegram/bot/types/input_media_video.rb +10 -8
  79. data/lib/telegram/bot/types/input_text_message_content.rb +4 -3
  80. data/lib/telegram/bot/types/input_venue_message_content.rb +8 -8
  81. data/lib/telegram/bot/types/invoice.rb +5 -5
  82. data/lib/telegram/bot/types/keyboard_button.rb +5 -5
  83. data/lib/telegram/bot/types/keyboard_button_poll_type.rb +1 -1
  84. data/lib/telegram/bot/types/labeled_price.rb +2 -2
  85. data/lib/telegram/bot/types/location.rb +6 -6
  86. data/lib/telegram/bot/types/login_url.rb +4 -4
  87. data/lib/telegram/bot/types/mask_position.rb +4 -4
  88. data/lib/telegram/bot/types/menu_button_commands.rb +1 -1
  89. data/lib/telegram/bot/types/menu_button_default.rb +1 -1
  90. data/lib/telegram/bot/types/menu_button_web_app.rb +2 -2
  91. data/lib/telegram/bot/types/message.rb +63 -58
  92. data/lib/telegram/bot/types/message_auto_delete_timer_changed.rb +1 -1
  93. data/lib/telegram/bot/types/message_entity.rb +7 -7
  94. data/lib/telegram/bot/types/order_info.rb +4 -4
  95. data/lib/telegram/bot/types/passport_data.rb +1 -1
  96. data/lib/telegram/bot/types/passport_element_error_data_field.rb +5 -5
  97. data/lib/telegram/bot/types/passport_element_error_file.rb +4 -4
  98. data/lib/telegram/bot/types/passport_element_error_files.rb +4 -4
  99. data/lib/telegram/bot/types/passport_element_error_front_side.rb +4 -4
  100. data/lib/telegram/bot/types/passport_element_error_reverse_side.rb +4 -4
  101. data/lib/telegram/bot/types/passport_element_error_selfie.rb +4 -4
  102. data/lib/telegram/bot/types/passport_element_error_translation_file.rb +4 -4
  103. data/lib/telegram/bot/types/passport_element_error_translation_files.rb +4 -4
  104. data/lib/telegram/bot/types/passport_element_error_unspecified.rb +4 -4
  105. data/lib/telegram/bot/types/passport_file.rb +4 -4
  106. data/lib/telegram/bot/types/photo_size.rb +5 -5
  107. data/lib/telegram/bot/types/poll.rb +13 -13
  108. data/lib/telegram/bot/types/poll_answer.rb +2 -2
  109. data/lib/telegram/bot/types/poll_option.rb +2 -2
  110. data/lib/telegram/bot/types/pre_checkout_query.rb +6 -6
  111. data/lib/telegram/bot/types/proximity_alert_triggered.rb +1 -1
  112. data/lib/telegram/bot/types/reply_keyboard_markup.rb +5 -5
  113. data/lib/telegram/bot/types/reply_keyboard_remove.rb +2 -2
  114. data/lib/telegram/bot/types/sent_web_app_message.rb +1 -1
  115. data/lib/telegram/bot/types/shipping_address.rb +6 -6
  116. data/lib/telegram/bot/types/shipping_option.rb +3 -3
  117. data/lib/telegram/bot/types/shipping_query.rb +2 -2
  118. data/lib/telegram/bot/types/sticker.rb +14 -14
  119. data/lib/telegram/bot/types/sticker_set.rb +7 -8
  120. data/lib/telegram/bot/types/successful_payment.rb +7 -7
  121. data/lib/telegram/bot/types/update.rb +15 -15
  122. data/lib/telegram/bot/types/user.rb +11 -11
  123. data/lib/telegram/bot/types/user_profile_photos.rb +2 -2
  124. data/lib/telegram/bot/types/venue.rb +6 -6
  125. data/lib/telegram/bot/types/video.rb +9 -9
  126. data/lib/telegram/bot/types/video_chat_ended.rb +1 -1
  127. data/lib/telegram/bot/types/video_chat_participants_invited.rb +1 -1
  128. data/lib/telegram/bot/types/video_chat_scheduled.rb +1 -1
  129. data/lib/telegram/bot/types/video_note.rb +6 -6
  130. data/lib/telegram/bot/types/voice.rb +5 -5
  131. data/lib/telegram/bot/types/web_app_data.rb +2 -2
  132. data/lib/telegram/bot/types/web_app_info.rb +1 -1
  133. data/lib/telegram/bot/types/webhook_info.rb +9 -9
  134. data/lib/telegram/bot/types.rb +7 -124
  135. data/lib/telegram/bot/version.rb +1 -1
  136. data/lib/telegram/bot.rb +7 -9
  137. data/telegram-bot-ruby.gemspec +4 -2
  138. metadata +51 -13
  139. data/lib/telegram/bot/exceptions.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bca107deda1051398ddcbc2e07373d9391b1bd28ca076d7610d164bd80ff24b
4
- data.tar.gz: 70d72be64d6706cedc45c125d439c15502c8b7f9d75821646455b0a30466fbc6
3
+ metadata.gz: 6149f85b75abd46b546aac32fbe88da43e4a414bcaabb6ea05d213681d136460
4
+ data.tar.gz: 88ae56d90f1e50883034d5433d3636f2feddc2ec31826466de31e23d61e2edfa
5
5
  SHA512:
6
- metadata.gz: a436f947e37fdf9642e48208d0dadae058499c9b9b99994819459be7b2a6819139c4c8f1651eb50fc52e8bcbe601417e0f8f7d1929d5420c36d50a6f39879024
7
- data.tar.gz: 2bee228283223aa1c6bdeb29ffe54e72c2c7fe39b43a3e60f158d20e1fdeace5e68a53a02cafde29b91fee3e622b7ca6a9d8587599f657925cf25912c26676a9
6
+ metadata.gz: c44671c55c2dcc30b15aef63d02351775a69ae2e73ed738e74ea97c469217b17f4e0581e5300dc4280b1dda36ce1ed4d2191ee9d824491935aaa09f1e1fcefbf
7
+ data.tar.gz: e7c37c40f7f2dc9d86618a18b8e17e91a75f03632c60a8e075b78ce890d7c093501f3a4366b583b9cd3b85715bd06468cedc1472f5a153565ca132e5c97fe8d1
data/.env.sample ADDED
@@ -0,0 +1,2 @@
1
+ BOT_API_ENV=test
2
+ BOT_API_TOKEN=
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  Gemfile.lock
2
2
 
3
3
  .bundle/
4
+ .env
4
5
  pkg/
5
6
  vendor/bundle/
data/.rubocop.yml CHANGED
@@ -15,9 +15,10 @@ Style/FrozenStringLiteralComment:
15
15
  - bin/console
16
16
 
17
17
  Metrics/BlockLength:
18
- IgnoredMethods:
18
+ AllowedMethods:
19
19
  - context
20
20
  - describe
21
+ - task
21
22
 
22
23
  Layout/LineLength:
23
24
  Max: 120
data/README.md CHANGED
@@ -18,13 +18,13 @@ gem 'telegram-bot-ruby'
18
18
  And then execute:
19
19
 
20
20
  ```shell
21
- $ bundle
21
+ bundle
22
22
  ```
23
23
 
24
24
  Or install it system-wide:
25
25
 
26
26
  ```shell
27
- $ gem install telegram-bot-ruby
27
+ gem install telegram-bot-ruby
28
28
  ```
29
29
 
30
30
  ## Usage
@@ -50,8 +50,13 @@ end
50
50
 
51
51
  Note that `bot.api` object implements [Telegram Bot API methods](https://core.telegram.org/bots/api#available-methods) as is. So you can invoke any method inside the block without any problems. All methods are available in both *snake_case* and *camelCase* notations.
52
52
 
53
- If you need to start a bot on development mode you have to pass `enviroment: :test` <br>
54
- example: `Telegram::Bot::Client.run(token, enviroment: :test)`
53
+ If you need to start a bot in development mode you have to pass `environment: :test`:
54
+
55
+ ```ruby
56
+ Telegram::Bot::Client.run(token, environment: :test) do |bot|
57
+ # ...
58
+ end
59
+ ```
55
60
 
56
61
  Same thing about `message` object - it implements [Message](https://core.telegram.org/bots/api#message) spec, so you always know what to expect from it.
57
62
 
@@ -80,8 +85,13 @@ bot.listen do |message|
80
85
  question = 'London is a capital of which country?'
81
86
  # See more: https://core.telegram.org/bots/api#replykeyboardmarkup
82
87
  answers =
83
- Telegram::Bot::Types::ReplyKeyboardMarkup
84
- .new(keyboard: [%w(A B), %w(C D)], one_time_keyboard: true)
88
+ Telegram::Bot::Types::ReplyKeyboardMarkup.new(
89
+ keyboard: [
90
+ [{ text: 'A' }, { text: 'B' }],
91
+ [{ text: 'C' }, { text: 'D' }]
92
+ ],
93
+ one_time_keyboard: true
94
+ )
85
95
  bot.api.send_message(chat_id: message.chat.id, text: question, reply_markup: answers)
86
96
  when '/stop'
87
97
  # See more: https://core.telegram.org/bots/api#replykeyboardremove
@@ -95,10 +105,10 @@ Furthermore, you can ask user to share location or phone number using `KeyboardB
95
105
 
96
106
  ```ruby
97
107
  bot.listen do |message|
98
- kb = [
108
+ kb = [[
99
109
  Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true),
100
110
  Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true)
101
- ]
111
+ ]]
102
112
  markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb)
103
113
  bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup)
104
114
  end
@@ -117,11 +127,11 @@ bot.listen do |message|
117
127
  bot.api.send_message(chat_id: message.from.id, text: "Don't touch me!")
118
128
  end
119
129
  when Telegram::Bot::Types::Message
120
- kb = [
130
+ kb = [[
121
131
  Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Go to Google', url: 'https://google.com'),
122
132
  Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Touch me', callback_data: 'touch'),
123
133
  Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Switch to inline', switch_inline_query: 'some text')
124
- ]
134
+ ]]
125
135
  markup = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: kb)
126
136
  bot.api.send_message(chat_id: message.chat.id, text: 'Make a choice', reply_markup: markup)
127
137
  end
@@ -137,8 +147,8 @@ bot.listen do |message|
137
147
  case message
138
148
  when Telegram::Bot::Types::InlineQuery
139
149
  results = [
140
- [1, 'First article', 'Very interesting text goes here.'],
141
- [2, 'Second article', 'Another interesting text here.']
150
+ ['1', 'First article', 'Very interesting text goes here.'],
151
+ ['2', 'Second article', 'Another interesting text here.']
142
152
  ].map do |arr|
143
153
  Telegram::Bot::Types::InlineQueryResultArticle.new(
144
154
  id: arr[0],
@@ -166,7 +176,8 @@ Your bot can even upload files ([photos](https://core.telegram.org/bots/api#send
166
176
  bot.listen do |message|
167
177
  case message.text
168
178
  when '/photo'
169
- bot.api.send_photo(chat_id: message.chat.id, photo: Faraday::UploadIO.new('~/Desktop/jennifer.jpg', 'image/jpeg'))
179
+ path_to_photo = File.expand_path('~/Desktop/jennifer.jpg')
180
+ bot.api.send_photo(chat_id: message.chat.id, photo: Faraday::UploadIO.new(path_to_photo, 'image/jpeg'))
170
181
  end
171
182
  end
172
183
  ```
@@ -199,6 +210,7 @@ end
199
210
  ## Boilerplates
200
211
 
201
212
  If you don't know how to setup database for your bot or how to use it with different languages here are some boilerplates which can help you to start faster:
213
+
202
214
  - [Ruby Telegram Bot boilerplate](https://github.com/telegram-bots/ruby-telegram-bot-boilerplate)
203
215
 
204
216
  ## Contributing
data/Rakefile CHANGED
@@ -15,3 +15,46 @@ end
15
15
  RSpec::Core::RakeTask.new(:spec)
16
16
 
17
17
  task default: :spec
18
+
19
+ desc 'Dump type definitions from docs to YAML'
20
+ task :dump_type_attributes do
21
+ require File.expand_path('lib/telegram/bot', __dir__)
22
+ require 'nokogiri'
23
+ require 'open-uri'
24
+ require 'yaml'
25
+
26
+ # Preload every type we have
27
+ Zeitwerk::Loader.eager_load_all
28
+ types = Telegram::Bot::Types::Base.descendants.map { |c| c.name.split('::').last }
29
+
30
+ # Fetch and parse docs
31
+ doc = Nokogiri::HTML(URI.open('https://core.telegram.org/bots/api').read)
32
+
33
+ result = types.to_h do |type|
34
+ # This is very hacky but working way to find table containing attributes for
35
+ # given type. Basic idea is to find heading with type and then iterate until
36
+ # we find table with attributes or next heading (because sometimes type
37
+ # doesn't have any attributes).
38
+ element = doc.at_xpath(%{//h4[text() = "#{type}"]})
39
+ loop do
40
+ element = element.next_element
41
+ break if %w[table h4].include?(element.name)
42
+ end
43
+
44
+ attributes = element.xpath('.//tbody//tr').map do |el|
45
+ cells = el.children.select { |c| c.name == 'td' }
46
+ {
47
+ 'name' => cells[0].text,
48
+ 'required' => !cells[2].text.start_with?('Optional.')
49
+ }
50
+ end
51
+
52
+ [type, attributes]
53
+ end
54
+
55
+ # Write everything to fixture file
56
+ File.write(
57
+ File.expand_path('spec/fixtures/type_attributes.yml', __dir__),
58
+ result.to_yaml
59
+ )
60
+ end
@@ -4,15 +4,15 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class Animation < Base
7
- attribute :file_id, String
8
- attribute :file_unique_id, String
9
- attribute :width, Integer
10
- attribute :height, Integer
11
- attribute :duration, Integer
12
- attribute :thumb, PhotoSize
13
- attribute :file_name, String
14
- attribute :mime_type, String
15
- attribute :file_size, Integer
7
+ attribute :file_id, Types::String
8
+ attribute :file_unique_id, Types::String
9
+ attribute :width, Types::Integer
10
+ attribute :height, Types::Integer
11
+ attribute :duration, Types::Integer
12
+ attribute? :thumb, PhotoSize
13
+ attribute? :file_name, Types::String
14
+ attribute? :mime_type, Types::String
15
+ attribute? :file_size, Types::Integer
16
16
  end
17
17
  end
18
18
  end
@@ -4,15 +4,15 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class Audio < Base
7
- attribute :file_id, String
8
- attribute :file_unique_id, String
9
- attribute :duration, Integer
10
- attribute :performer, String
11
- attribute :title, String
12
- attribute :file_name, String
13
- attribute :mime_type, String
14
- attribute :file_size, Integer
15
- attribute :thumb, PhotoSize
7
+ attribute :file_id, Types::String
8
+ attribute :file_unique_id, Types::String
9
+ attribute :duration, Types::Integer
10
+ attribute? :performer, Types::String
11
+ attribute? :title, Types::String
12
+ attribute? :file_name, Types::String
13
+ attribute? :mime_type, Types::String
14
+ attribute? :file_size, Types::Integer
15
+ attribute? :thumb, PhotoSize
16
16
  end
17
17
  end
18
18
  end
@@ -3,10 +3,11 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class Base
7
- include Virtus.model
6
+ class Base < Dry::Struct
8
7
  include Compactable
9
8
  include PatternMatching
9
+
10
+ transform_keys(&:to_sym)
10
11
  end
11
12
  end
12
13
  end
@@ -4,8 +4,8 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommand < Base
7
- attribute :command, String
8
- attribute :description, String
7
+ attribute :command, Types::String
8
+ attribute :description, Types::String
9
9
  end
10
10
  end
11
11
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeAllChatAdministrators < Base
7
- attribute :type, String, default: 'all_chat_administrators'
7
+ attribute :type, Types::String.default('all_chat_administrators')
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeAllGroupChats < Base
7
- attribute :type, String, default: 'all_group_chats'
7
+ attribute :type, Types::String.default('all_group_chats')
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeAllPrivateChats < Base
7
- attribute :type, String, default: 'all_private_chats'
7
+ attribute :type, Types::String.default('all_private_chats')
8
8
  end
9
9
  end
10
10
  end
@@ -4,8 +4,8 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeChat < Base
7
- attribute :type, String, default: 'chat'
8
- attribute :chat_id, String
7
+ attribute :type, Types::String.default('chat')
8
+ attribute :chat_id, Types::String
9
9
  end
10
10
  end
11
11
  end
@@ -4,8 +4,8 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeChatAdministrators < Base
7
- attribute :type, String, default: 'chat_administrators'
8
- attribute :chat_id, String
7
+ attribute :type, Types::String.default('chat_administrators')
8
+ attribute :chat_id, Types::String
9
9
  end
10
10
  end
11
11
  end
@@ -4,9 +4,9 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeChatMember < Base
7
- attribute :type, String, default: 'chat_member'
8
- attribute :chat_id, String
9
- attribute :user_id, Integer
7
+ attribute :type, Types::String.default('chat_member')
8
+ attribute :chat_id, Types::String
9
+ attribute :user_id, Types::Integer
10
10
  end
11
11
  end
12
12
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeDefault < Base
7
- attribute :type, String, default: 'default'
7
+ attribute :type, Types::String.default('default')
8
8
  end
9
9
  end
10
10
  end
@@ -4,13 +4,13 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class CallbackQuery < Base
7
- attribute :id, String
7
+ attribute :id, Types::String
8
8
  attribute :from, User
9
- attribute :message, Message
10
- attribute :inline_message_id, String
11
- attribute :chat_instance, String
12
- attribute :data, String
13
- attribute :game_short_name, String
9
+ attribute? :message, Message
10
+ attribute? :inline_message_id, Types::String
11
+ attribute :chat_instance, Types::String
12
+ attribute? :data, Types::String
13
+ attribute? :game_short_name, Types::String
14
14
  end
15
15
  end
16
16
  end
@@ -3,34 +3,33 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class Chat
7
- include Virtus.model(finalize: false)
8
- include Compactable
9
- include PatternMatching
10
-
11
- attribute :id, Integer
12
- attribute :type, String
13
- attribute :title, String
14
- attribute :username, String
15
- attribute :first_name, String
16
- attribute :last_name, String
17
- attribute :photo, ChatPhoto
18
- attribute :bio, String
19
- attribute :has_private_forwards, Boolean
20
- attribute :has_restricted_voice_and_video_messages, Boolean
21
- attribute :join_to_send_messages, Boolean
22
- attribute :join_by_request, Boolean
23
- attribute :description, String
24
- attribute :invite_link, String
25
- attribute :pinned_message, 'Telegram::Bot::Types::Message'
26
- attribute :permissions, ChatPermissions
27
- attribute :slow_mode_delay, Integer
28
- attribute :message_auto_delete_time, Integer
29
- attribute :has_protected_content, Boolean
30
- attribute :sticker_set_name, String
31
- attribute :can_set_sticker_set, Boolean
32
- attribute :linked_chat_id, Integer
33
- attribute :location, ChatLocation
6
+ class Chat < Base
7
+ attribute :id, Types::Integer
8
+ attribute :type, Types::String
9
+ attribute? :title, Types::String
10
+ attribute? :username, Types::String
11
+ attribute? :first_name, Types::String
12
+ attribute? :last_name, Types::String
13
+ attribute? :is_forum, Types::Bool
14
+ attribute? :photo, ChatPhoto
15
+ attribute? :active_usernames, Types::Array.of(Types::String)
16
+ attribute? :emoji_status_custom_emoji_id, Types::String
17
+ attribute? :bio, Types::String
18
+ attribute? :has_private_forwards, Types::Bool
19
+ attribute? :has_restricted_voice_and_video_messages, Types::Bool
20
+ attribute? :join_to_send_messages, Types::Bool
21
+ attribute? :join_by_request, Types::Bool
22
+ attribute? :description, Types::String
23
+ attribute? :invite_link, Types::String
24
+ attribute? :pinned_message, Message
25
+ attribute? :permissions, ChatPermissions
26
+ attribute? :slow_mode_delay, Types::Integer
27
+ attribute? :message_auto_delete_time, Types::Integer
28
+ attribute? :has_protected_content, Types::Bool
29
+ attribute? :sticker_set_name, Types::String
30
+ attribute? :can_set_sticker_set, Types::Bool
31
+ attribute? :linked_chat_id, Types::Integer
32
+ attribute? :location, ChatLocation
34
33
  end
35
34
  end
36
35
  end
@@ -3,18 +3,19 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatAdministratorRight < Base
7
- attribute :is_anonymous, Boolean
8
- attribute :can_manage_chat, Boolean
9
- attribute :can_delete_messages, Boolean
10
- attribute :can_manage_video_chats, Boolean
11
- attribute :can_restrict_members, Boolean
12
- attribute :can_promote_members, Boolean
13
- attribute :can_change_info, Boolean
14
- attribute :can_invite_users, Boolean
15
- attribute :can_post_messages, Boolean
16
- attribute :can_edit_messages, Boolean
17
- attribute :can_pin_messages, Boolean
6
+ class ChatAdministratorRights < Base
7
+ attribute :is_anonymous, Types::Bool
8
+ attribute :can_manage_chat, Types::Bool
9
+ attribute :can_delete_messages, Types::Bool
10
+ attribute :can_manage_video_chats, Types::Bool
11
+ attribute :can_restrict_members, Types::Bool
12
+ attribute :can_promote_members, Types::Bool
13
+ attribute :can_change_info, Types::Bool
14
+ attribute :can_invite_users, Types::Bool
15
+ attribute? :can_post_messages, Types::Bool
16
+ attribute? :can_edit_messages, Types::Bool
17
+ attribute? :can_pin_messages, Types::Bool
18
+ attribute? :can_manage_topics, Types::Bool
18
19
  end
19
20
  end
20
21
  end
@@ -4,15 +4,15 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class ChatInviteLink < Base
7
- attribute :invite_link, String
7
+ attribute :invite_link, Types::String
8
8
  attribute :creator, User
9
- attribute :creates_join_request, Boolean
10
- attribute :is_primary, Boolean
11
- attribute :is_revoked, Boolean
12
- attribute :name, String
13
- attribute :expire_date, Integer
14
- attribute :member_limit, Integer
15
- attribute :pending_join_request_count, Integer
9
+ attribute :creates_join_request, Types::Bool
10
+ attribute :is_primary, Types::Bool
11
+ attribute :is_revoked, Types::Bool
12
+ attribute? :name, Types::String
13
+ attribute? :expire_date, Types::Integer
14
+ attribute? :member_limit, Types::Integer
15
+ attribute? :pending_join_request_count, Types::Integer
16
16
  end
17
17
  end
18
18
  end
@@ -6,9 +6,9 @@ module Telegram
6
6
  class ChatJoinRequest < Base
7
7
  attribute :chat, Chat
8
8
  attribute :from, User
9
- attribute :date, Integer
10
- attribute :bio, String
11
- attribute :invite_link, ChatInviteLink
9
+ attribute :date, Types::Integer
10
+ attribute? :bio, Types::String
11
+ attribute? :invite_link, ChatInviteLink
12
12
  end
13
13
  end
14
14
  end
@@ -5,7 +5,7 @@ module Telegram
5
5
  module Types
6
6
  class ChatLocation < Base
7
7
  attribute :location, Location
8
- attribute :address, String
8
+ attribute :address, Types::String
9
9
  end
10
10
  end
11
11
  end
@@ -4,28 +4,6 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class ChatMember < Base
7
- attribute :user, User
8
- attribute :status, String
9
- attribute :custom_title, String
10
- attribute :is_anonymous, Boolean
11
- attribute :can_be_edited, Boolean
12
- attribute :can_manage_chat, Boolean
13
- attribute :can_post_messages, Boolean
14
- attribute :can_edit_messages, Boolean
15
- attribute :can_delete_messages, Boolean
16
- attribute :can_manage_video_chats, Boolean
17
- attribute :can_restrict_members, Boolean
18
- attribute :can_promote_members, Boolean
19
- attribute :can_change_info, Boolean
20
- attribute :can_invite_users, Boolean
21
- attribute :can_pin_messages, Boolean
22
- attribute :is_member, Boolean
23
- attribute :can_send_messages, Boolean
24
- attribute :can_send_media_messages, Boolean
25
- attribute :can_send_polls, Boolean
26
- attribute :can_send_other_messages, Boolean
27
- attribute :can_add_web_page_previews, Boolean
28
- attribute :until_date, Integer
29
7
  end
30
8
  end
31
9
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberAdministrator < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ attribute :can_be_edited, Types::Bool
10
+ attribute :is_anonymous, Types::Bool
11
+ attribute :can_manage_chat, Types::Bool
12
+ attribute :can_delete_messages, Types::Bool
13
+ attribute :can_manage_video_chats, Types::Bool
14
+ attribute :can_restrict_members, Types::Bool
15
+ attribute :can_promote_members, Types::Bool
16
+ attribute :can_change_info, Types::Bool
17
+ attribute :can_invite_users, Types::Bool
18
+ attribute? :can_post_messages, Types::Bool
19
+ attribute? :can_edit_messages, Types::Integer
20
+ attribute? :can_pin_messages, Types::Integer
21
+ attribute? :can_manage_topics, Types::Integer
22
+ attribute? :custom_title, Types::String
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberBanned < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ attribute :until_date, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberLeft < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberMember < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberOwner < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ attribute :is_anonymous, Types::Bool
10
+ attribute? :custom_title, Types::String
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberRestricted < ChatMember
7
+ attribute :status, Types::String
8
+ attribute :user, User
9
+ attribute :is_member, Types::Bool
10
+ attribute :can_change_info, Types::Bool
11
+ attribute :can_invite_users, Types::Bool
12
+ attribute :can_pin_messages, Types::Bool
13
+ attribute :can_manage_topics, Types::Bool
14
+ attribute :can_send_messages, Types::Bool
15
+ attribute :can_send_media_messages, Types::Bool
16
+ attribute :can_send_polls, Types::Bool
17
+ attribute :can_send_other_messages, Types::Bool
18
+ attribute :can_add_web_page_previews, Types::Bool
19
+ attribute :until_date, Types::Integer
20
+ end
21
+ end
22
+ end
23
+ end