telegram-bot-ruby 1.0.0.rc1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +10 -0
  3. data/.github/workflows/ci.yml +2 -5
  4. data/.github/workflows/stale.yml +19 -0
  5. data/.gitignore +1 -0
  6. data/.rspec +1 -0
  7. data/.rubocop.yml +12 -7
  8. data/CHANGELOG.md +17 -0
  9. data/Gemfile +13 -0
  10. data/LICENSE +0 -1
  11. data/README.md +78 -19
  12. data/Rakefile +10 -8
  13. data/bin/console +4 -1
  14. data/lib/telegram/bot/api/endpoints.rb +114 -0
  15. data/lib/telegram/bot/api.rb +20 -44
  16. data/lib/telegram/bot/client.rb +8 -9
  17. data/lib/telegram/bot/exceptions/response_error.rb +2 -8
  18. data/lib/telegram/bot/types/animation.rb +1 -1
  19. data/lib/telegram/bot/types/audio.rb +1 -1
  20. data/lib/telegram/bot/types/bot_command_scope_all_chat_administrators.rb +1 -1
  21. data/lib/telegram/bot/types/bot_command_scope_all_group_chats.rb +1 -1
  22. data/lib/telegram/bot/types/bot_command_scope_all_private_chats.rb +1 -1
  23. data/lib/telegram/bot/types/bot_command_scope_chat.rb +2 -2
  24. data/lib/telegram/bot/types/bot_command_scope_chat_administrators.rb +2 -2
  25. data/lib/telegram/bot/types/bot_command_scope_chat_member.rb +2 -2
  26. data/lib/telegram/bot/types/bot_command_scope_default.rb +1 -1
  27. data/lib/telegram/bot/types/bot_description.rb +11 -0
  28. data/lib/telegram/bot/types/bot_name.rb +11 -0
  29. data/lib/telegram/bot/types/bot_short_description.rb +11 -0
  30. data/lib/telegram/bot/types/callback_query.rb +1 -1
  31. data/lib/telegram/bot/types/chat.rb +16 -9
  32. data/lib/telegram/bot/types/chat_administrator_rights.rb +3 -0
  33. data/lib/telegram/bot/types/chat_boost.rb +14 -0
  34. data/lib/telegram/bot/types/chat_boost_removed.rb +14 -0
  35. data/lib/telegram/bot/types/chat_boost_source.rb +13 -0
  36. data/lib/telegram/bot/types/chat_boost_source_gift_code.rb +12 -0
  37. data/lib/telegram/bot/types/chat_boost_source_giveaway.rb +14 -0
  38. data/lib/telegram/bot/types/chat_boost_source_premium.rb +12 -0
  39. data/lib/telegram/bot/types/chat_boost_updated.rb +12 -0
  40. data/lib/telegram/bot/types/chat_join_request.rb +1 -0
  41. data/lib/telegram/bot/types/chat_member.rb +11 -2
  42. data/lib/telegram/bot/types/chat_member_administrator.rb +8 -5
  43. data/lib/telegram/bot/types/chat_member_banned.rb +2 -2
  44. data/lib/telegram/bot/types/chat_member_left.rb +2 -2
  45. data/lib/telegram/bot/types/chat_member_member.rb +2 -2
  46. data/lib/telegram/bot/types/chat_member_owner.rb +2 -2
  47. data/lib/telegram/bot/types/chat_member_restricted.rb +12 -7
  48. data/lib/telegram/bot/types/chat_member_updated.rb +1 -0
  49. data/lib/telegram/bot/types/chat_permissions.rb +6 -1
  50. data/lib/telegram/bot/types/chat_shared.rb +12 -0
  51. data/lib/telegram/bot/types/compactable.rb +2 -7
  52. data/lib/telegram/bot/types/document.rb +1 -1
  53. data/lib/telegram/bot/types/external_reply_info.rb +33 -0
  54. data/lib/telegram/bot/types/force_reply.rb +1 -1
  55. data/lib/telegram/bot/types/giveaway.rb +18 -0
  56. data/lib/telegram/bot/types/giveaway_completed.rb +13 -0
  57. data/lib/telegram/bot/types/giveaway_created.rb +10 -0
  58. data/lib/telegram/bot/types/giveaway_winners.rb +21 -0
  59. data/lib/telegram/bot/types/inaccessible_message.rb +13 -0
  60. data/lib/telegram/bot/types/inline_keyboard_button.rb +1 -0
  61. data/lib/telegram/bot/types/inline_query_result_article.rb +4 -4
  62. data/lib/telegram/bot/types/inline_query_result_audio.rb +1 -1
  63. data/lib/telegram/bot/types/inline_query_result_cached_audio.rb +1 -1
  64. data/lib/telegram/bot/types/inline_query_result_cached_document.rb +1 -1
  65. data/lib/telegram/bot/types/inline_query_result_cached_gif.rb +1 -1
  66. data/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb +1 -1
  67. data/lib/telegram/bot/types/inline_query_result_cached_photo.rb +1 -1
  68. data/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +1 -1
  69. data/lib/telegram/bot/types/inline_query_result_cached_video.rb +1 -1
  70. data/lib/telegram/bot/types/inline_query_result_cached_voice.rb +1 -1
  71. data/lib/telegram/bot/types/inline_query_result_contact.rb +4 -4
  72. data/lib/telegram/bot/types/inline_query_result_document.rb +4 -4
  73. data/lib/telegram/bot/types/inline_query_result_game.rb +1 -1
  74. data/lib/telegram/bot/types/inline_query_result_gif.rb +3 -3
  75. data/lib/telegram/bot/types/inline_query_result_location.rb +4 -4
  76. data/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +3 -3
  77. data/lib/telegram/bot/types/inline_query_result_photo.rb +2 -2
  78. data/lib/telegram/bot/types/inline_query_result_venue.rb +4 -4
  79. data/lib/telegram/bot/types/inline_query_result_video.rb +2 -2
  80. data/lib/telegram/bot/types/inline_query_result_voice.rb +1 -1
  81. data/lib/telegram/bot/types/input_media_animation.rb +2 -2
  82. data/lib/telegram/bot/types/input_media_audio.rb +2 -2
  83. data/lib/telegram/bot/types/input_media_document.rb +2 -2
  84. data/lib/telegram/bot/types/input_media_photo.rb +1 -1
  85. data/lib/telegram/bot/types/input_media_video.rb +2 -2
  86. data/lib/telegram/bot/types/input_text_message_content.rb +1 -1
  87. data/lib/telegram/bot/types/keyboard_button.rb +2 -0
  88. data/lib/telegram/bot/types/keyboard_button_request_chat.rb +18 -0
  89. data/lib/telegram/bot/types/keyboard_button_request_users.rb +14 -0
  90. data/lib/telegram/bot/types/link_preview_options.rb +15 -0
  91. data/lib/telegram/bot/types/maybe_inaccessible_message.rb +12 -0
  92. data/lib/telegram/bot/types/menu_button_commands.rb +1 -1
  93. data/lib/telegram/bot/types/menu_button_default.rb +1 -1
  94. data/lib/telegram/bot/types/menu_button_web_app.rb +1 -1
  95. data/lib/telegram/bot/types/message.rb +20 -15
  96. data/lib/telegram/bot/types/message_id.rb +11 -0
  97. data/lib/telegram/bot/types/message_origin.rb +14 -0
  98. data/lib/telegram/bot/types/message_origin_channel.rb +15 -0
  99. data/lib/telegram/bot/types/message_origin_chat.rb +14 -0
  100. data/lib/telegram/bot/types/message_origin_hidden_user.rb +13 -0
  101. data/lib/telegram/bot/types/message_origin_user.rb +13 -0
  102. data/lib/telegram/bot/types/message_reaction_count_updated.rb +14 -0
  103. data/lib/telegram/bot/types/message_reaction_updated.rb +17 -0
  104. data/lib/telegram/bot/types/passport_element_error_data_field.rb +1 -1
  105. data/lib/telegram/bot/types/passport_element_error_file.rb +1 -1
  106. data/lib/telegram/bot/types/passport_element_error_files.rb +2 -2
  107. data/lib/telegram/bot/types/passport_element_error_front_side.rb +1 -1
  108. data/lib/telegram/bot/types/passport_element_error_reverse_side.rb +1 -1
  109. data/lib/telegram/bot/types/passport_element_error_selfie.rb +1 -1
  110. data/lib/telegram/bot/types/passport_element_error_translation_file.rb +1 -1
  111. data/lib/telegram/bot/types/passport_element_error_translation_files.rb +2 -2
  112. data/lib/telegram/bot/types/passport_element_error_unspecified.rb +1 -1
  113. data/lib/telegram/bot/types/poll_answer.rb +2 -1
  114. data/lib/telegram/bot/types/reaction_count.rb +12 -0
  115. data/lib/telegram/bot/types/reaction_type.rb +12 -0
  116. data/lib/telegram/bot/types/reaction_type_custom_emoji.rb +12 -0
  117. data/lib/telegram/bot/types/reaction_type_emoji.rb +12 -0
  118. data/lib/telegram/bot/types/reply_keyboard_remove.rb +1 -1
  119. data/lib/telegram/bot/types/reply_parameters.rb +17 -0
  120. data/lib/telegram/bot/types/sticker.rb +2 -1
  121. data/lib/telegram/bot/types/sticker_set.rb +1 -1
  122. data/lib/telegram/bot/types/story.rb +9 -0
  123. data/lib/telegram/bot/types/switch_inline_query_chosen_chat.rb +15 -0
  124. data/lib/telegram/bot/types/text_quote.rb +14 -0
  125. data/lib/telegram/bot/types/update.rb +4 -0
  126. data/lib/telegram/bot/types/user.rb +2 -2
  127. data/lib/telegram/bot/types/user_chat_boosts.rb +11 -0
  128. data/lib/telegram/bot/types/users_shared.rb +12 -0
  129. data/lib/telegram/bot/types/video.rb +1 -1
  130. data/lib/telegram/bot/types/video_note.rb +1 -1
  131. data/lib/telegram/bot/types/webhook_info.rb +1 -1
  132. data/lib/telegram/bot/types/write_access_allowed.rb +3 -0
  133. data/lib/telegram/bot/version.rb +1 -1
  134. data/lib/telegram/bot.rb +1 -0
  135. data/telegram-bot-ruby.gemspec +1 -13
  136. metadata +47 -117
@@ -6,22 +6,16 @@ module Telegram
6
6
  class ResponseError < Base
7
7
  attr_reader :response
8
8
 
9
- def initialize(response)
9
+ def initialize(response:)
10
10
  @response = response
11
- super
12
- end
13
11
 
14
- def to_s
15
- super +
16
- format(' (%s)', data.map { |k, v| %(#{k}: "#{v}") }.join(', '))
12
+ super "Telegram API has returned the error. (#{data.map { |k, v| %(#{k}: #{v.inspect}) }.join(', ')})"
17
13
  end
18
14
 
19
15
  def error_code
20
16
  data[:error_code] || data['error_code']
21
17
  end
22
18
 
23
- private
24
-
25
19
  def data
26
20
  @data ||= begin
27
21
  JSON.parse(response.body)
@@ -9,7 +9,7 @@ module Telegram
9
9
  attribute :width, Types::Integer
10
10
  attribute :height, Types::Integer
11
11
  attribute :duration, Types::Integer
12
- attribute? :thumb, PhotoSize
12
+ attribute? :thumbnail, PhotoSize
13
13
  attribute? :file_name, Types::String
14
14
  attribute? :mime_type, Types::String
15
15
  attribute? :file_size, Types::Integer
@@ -12,7 +12,7 @@ module Telegram
12
12
  attribute? :file_name, Types::String
13
13
  attribute? :mime_type, Types::String
14
14
  attribute? :file_size, Types::Integer
15
- attribute? :thumb, PhotoSize
15
+ attribute? :thumbnail, PhotoSize
16
16
  end
17
17
  end
18
18
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeAllChatAdministrators < Base
7
- attribute :type, Types::String.default('all_chat_administrators')
7
+ attribute :type, Types::String.constrained(eql: 'all_chat_administrators').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, Types::String.default('all_group_chats')
7
+ attribute :type, Types::String.constrained(eql: 'all_group_chats').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, Types::String.default('all_private_chats')
7
+ attribute :type, Types::String.constrained(eql: 'all_private_chats').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, Types::String.default('chat')
8
- attribute :chat_id, Types::String
7
+ attribute :type, Types::String.constrained(eql: 'chat').default('chat')
8
+ attribute :chat_id, Types::Integer | 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, Types::String.default('chat_administrators')
8
- attribute :chat_id, Types::String
7
+ attribute :type, Types::String.constrained(eql: 'chat_administrators').default('chat_administrators')
8
+ attribute :chat_id, Types::Integer | 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 BotCommandScopeChatMember < Base
7
- attribute :type, Types::String.default('chat_member')
8
- attribute :chat_id, Types::String
7
+ attribute :type, Types::String.constrained(eql: 'chat_member').default('chat_member')
8
+ attribute :chat_id, Types::Integer | Types::String
9
9
  attribute :user_id, Types::Integer
10
10
  end
11
11
  end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class BotCommandScopeDefault < Base
7
- attribute :type, Types::String.default('default')
7
+ attribute :type, Types::String.constrained(eql: 'default').default('default')
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class BotDescription < Base
7
+ attribute :description, Types::String
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class BotName < Base
7
+ attribute :name, Types::String
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class BotShortDescription < Base
7
+ attribute :short_description, Types::String
8
+ end
9
+ end
10
+ end
11
+ end
@@ -6,7 +6,7 @@ module Telegram
6
6
  class CallbackQuery < Base
7
7
  attribute :id, Types::String
8
8
  attribute :from, User
9
- attribute? :message, Message
9
+ attribute? :message, MaybeInaccessibleMessage
10
10
  attribute? :inline_message_id, Types::String
11
11
  attribute :chat_instance, Types::String
12
12
  attribute? :data, Types::String
@@ -10,26 +10,33 @@ module Telegram
10
10
  attribute? :username, Types::String
11
11
  attribute? :first_name, Types::String
12
12
  attribute? :last_name, Types::String
13
- attribute? :is_forum, Types::Bool
13
+ attribute? :is_forum, Types::True
14
14
  attribute? :photo, ChatPhoto
15
15
  attribute? :active_usernames, Types::Array.of(Types::String)
16
+ attribute? :available_reactions, Types::Array.of(ReactionType)
17
+ attribute? :accent_color_id, Types::Integer
18
+ attribute? :background_custom_emoji_id, Types::String
19
+ attribute? :profile_accent_color_id, Types::Integer
20
+ attribute? :profile_background_custom_emoji_id, Types::String
16
21
  attribute? :emoji_status_custom_emoji_id, Types::String
22
+ attribute? :emoji_status_expiration_date, Types::Integer
17
23
  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
24
+ attribute? :has_private_forwards, Types::True
25
+ attribute? :has_restricted_voice_and_video_messages, Types::True
26
+ attribute? :join_to_send_messages, Types::True
27
+ attribute? :join_by_request, Types::True
22
28
  attribute? :description, Types::String
23
29
  attribute? :invite_link, Types::String
24
30
  attribute? :pinned_message, Message
25
31
  attribute? :permissions, ChatPermissions
26
32
  attribute? :slow_mode_delay, Types::Integer
27
33
  attribute? :message_auto_delete_time, Types::Integer
28
- attribute? :has_aggressive_anti_spam_enabled, Types::Bool
29
- attribute? :has_hidden_members, Types::Bool
30
- attribute? :has_protected_content, Types::Bool
34
+ attribute? :has_aggressive_anti_spam_enabled, Types::True
35
+ attribute? :has_hidden_members, Types::True
36
+ attribute? :has_protected_content, Types::True
37
+ attribute? :has_visible_history, Types::True
31
38
  attribute? :sticker_set_name, Types::String
32
- attribute? :can_set_sticker_set, Types::Bool
39
+ attribute? :can_set_sticker_set, Types::True
33
40
  attribute? :linked_chat_id, Types::Integer
34
41
  attribute? :location, ChatLocation
35
42
  end
@@ -15,6 +15,9 @@ module Telegram
15
15
  attribute? :can_post_messages, Types::Bool
16
16
  attribute? :can_edit_messages, Types::Bool
17
17
  attribute? :can_pin_messages, Types::Bool
18
+ attribute? :can_post_stories, Types::Bool
19
+ attribute? :can_edit_stories, Types::Bool
20
+ attribute? :can_delete_stories, Types::Bool
18
21
  attribute? :can_manage_topics, Types::Bool
19
22
  end
20
23
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatBoost < Base
7
+ attribute :boost_id, Types::String
8
+ attribute :add_date, Types::Integer
9
+ attribute :expiration_date, Types::Integer
10
+ attribute :source, ChatBoostSource
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatBoostRemoved < Base
7
+ attribute :chat, Chat
8
+ attribute :boost_id, Types::String
9
+ attribute :remove_date, Types::Integer
10
+ attribute :source, ChatBoostSource
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ ChatBoostSource = ( # rubocop:disable Naming/ConstantName
7
+ ChatBoostSourcePremium |
8
+ ChatBoostSourceGiftCode |
9
+ ChatBoostSourceGiveaway
10
+ )
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 ChatBoostSourceGiftCode < Base
7
+ attribute :source, Types::String.constrained(eql: 'gift_code').default('gift_code')
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 ChatBoostSourceGiveaway < Base
7
+ attribute :source, Types::String.constrained(eql: 'giveaway').default('giveaway')
8
+ attribute :giveaway_message_id, Types::Integer
9
+ attribute? :user, User
10
+ attribute? :is_unclaimed, Types::True
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatBoostSourcePremium < Base
7
+ attribute :source, Types::String.constrained(eql: 'premium').default('premium')
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 ChatBoostUpdated < Base
7
+ attribute :chat, Chat
8
+ attribute :boost, ChatBoost
9
+ end
10
+ end
11
+ end
12
+ end
@@ -6,6 +6,7 @@ module Telegram
6
6
  class ChatJoinRequest < Base
7
7
  attribute :chat, Chat
8
8
  attribute :from, User
9
+ attribute :user_chat_id, Types::Integer
9
10
  attribute :date, Types::Integer
10
11
  attribute? :bio, Types::String
11
12
  attribute? :invite_link, ChatInviteLink
@@ -3,8 +3,17 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMember < Base
7
- end
6
+ ## Just for classes consistency
7
+ # rubocop:disable Naming/ConstantName
8
+ ChatMember = (
9
+ ChatMemberAdministrator |
10
+ ChatMemberBanned |
11
+ ChatMemberLeft |
12
+ ChatMemberMember |
13
+ ChatMemberOwner |
14
+ ChatMemberRestricted
15
+ )
16
+ # rubocop:enable Naming/ConstantName
8
17
  end
9
18
  end
10
19
  end
@@ -3,8 +3,8 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberAdministrator < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberAdministrator < Base
7
+ attribute :status, Types::String.constrained(eql: 'administrator').default('administrator')
8
8
  attribute :user, User
9
9
  attribute :can_be_edited, Types::Bool
10
10
  attribute :is_anonymous, Types::Bool
@@ -16,9 +16,12 @@ module Telegram
16
16
  attribute :can_change_info, Types::Bool
17
17
  attribute :can_invite_users, Types::Bool
18
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
19
+ attribute? :can_edit_messages, Types::Bool
20
+ attribute? :can_pin_messages, Types::Bool
21
+ attribute? :can_post_stories, Types::Bool
22
+ attribute? :can_edit_stories, Types::Bool
23
+ attribute? :can_delete_stories, Types::Bool
24
+ attribute? :can_manage_topics, Types::Bool
22
25
  attribute? :custom_title, Types::String
23
26
  end
24
27
  end
@@ -3,8 +3,8 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberBanned < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberBanned < Base
7
+ attribute :status, Types::String.constrained(eql: 'kicked').default('kicked')
8
8
  attribute :user, User
9
9
  attribute :until_date, Types::Integer
10
10
  end
@@ -3,8 +3,8 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberLeft < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberLeft < Base
7
+ attribute :status, Types::String.constrained(eql: 'left').default('left')
8
8
  attribute :user, User
9
9
  end
10
10
  end
@@ -3,8 +3,8 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberMember < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberMember < Base
7
+ attribute :status, Types::String.constrained(eql: 'member').default('member')
8
8
  attribute :user, User
9
9
  end
10
10
  end
@@ -3,8 +3,8 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberOwner < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberOwner < Base
7
+ attribute :status, Types::String.constrained(eql: 'creator').default('creator')
8
8
  attribute :user, User
9
9
  attribute :is_anonymous, Types::Bool
10
10
  attribute? :custom_title, Types::String
@@ -3,19 +3,24 @@
3
3
  module Telegram
4
4
  module Bot
5
5
  module Types
6
- class ChatMemberRestricted < ChatMember
7
- attribute :status, Types::String
6
+ class ChatMemberRestricted < Base
7
+ attribute :status, Types::String.constrained(eql: 'restricted').default('restricted')
8
8
  attribute :user, User
9
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
10
  attribute :can_send_messages, Types::Bool
15
- attribute :can_send_media_messages, Types::Bool
11
+ attribute :can_send_audios, Types::Bool
12
+ attribute :can_send_documents, Types::Bool
13
+ attribute :can_send_photos, Types::Bool
14
+ attribute :can_send_videos, Types::Bool
15
+ attribute :can_send_video_notes, Types::Bool
16
+ attribute :can_send_voice_notes, Types::Bool
16
17
  attribute :can_send_polls, Types::Bool
17
18
  attribute :can_send_other_messages, Types::Bool
18
19
  attribute :can_add_web_page_previews, Types::Bool
20
+ attribute :can_change_info, Types::Bool
21
+ attribute :can_invite_users, Types::Bool
22
+ attribute :can_pin_messages, Types::Bool
23
+ attribute :can_manage_topics, Types::Bool
19
24
  attribute :until_date, Types::Integer
20
25
  end
21
26
  end
@@ -10,6 +10,7 @@ module Telegram
10
10
  attribute :old_chat_member, ChatMember
11
11
  attribute :new_chat_member, ChatMember
12
12
  attribute? :invite_link, ChatInviteLink
13
+ attribute? :via_chat_folder_invite_link, Types::Bool
13
14
  end
14
15
  end
15
16
  end
@@ -5,7 +5,12 @@ module Telegram
5
5
  module Types
6
6
  class ChatPermissions < Base
7
7
  attribute? :can_send_messages, Types::Bool
8
- attribute? :can_send_media_messages, Types::Bool
8
+ attribute? :can_send_audios, Types::Bool
9
+ attribute? :can_send_documents, Types::Bool
10
+ attribute? :can_send_photos, Types::Bool
11
+ attribute? :can_send_videos, Types::Bool
12
+ attribute? :can_send_video_notes, Types::Bool
13
+ attribute? :can_send_voice_notes, Types::Bool
9
14
  attribute? :can_send_polls, Types::Bool
10
15
  attribute? :can_send_other_messages, Types::Bool
11
16
  attribute? :can_add_web_page_previews, Types::Bool
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatShared < Base
7
+ attribute :request_id, Types::Integer
8
+ attribute :chat_id, Types::Integer
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,13 +5,8 @@ module Telegram
5
5
  module Types
6
6
  module Compactable
7
7
  def to_compact_hash
8
- attributes.dup.delete_if { |_, v| v.nil? }.to_h do |key, value|
9
- value =
10
- if value.respond_to?(:to_compact_hash)
11
- value.to_compact_hash
12
- else
13
- value
14
- end
8
+ attributes.dup.compact.to_h do |key, value|
9
+ value = value.to_compact_hash if value.respond_to?(:to_compact_hash)
15
10
 
16
11
  [key, value]
17
12
  end
@@ -6,7 +6,7 @@ module Telegram
6
6
  class Document < Base
7
7
  attribute :file_id, Types::String
8
8
  attribute :file_unique_id, Types::String
9
- attribute? :thumb, PhotoSize
9
+ attribute? :thumbnail, PhotoSize
10
10
  attribute? :file_name, Types::String
11
11
  attribute? :mime_type, Types::String
12
12
  attribute? :file_size, Types::Integer
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ExternalReplyInfo < Base
7
+ attribute :origin, MessageOrigin
8
+ attribute? :chat, Chat
9
+ attribute? :message_id, Types::Integer
10
+ attribute? :link_preview_options, LinkPreviewOptions
11
+ attribute? :animation, Animation
12
+ attribute? :audio, Audio
13
+ attribute? :document, Document
14
+ attribute? :photo, Types::Array.of(PhotoSize)
15
+ attribute? :sticker, Sticker
16
+ attribute? :story, Story
17
+ attribute? :video, Video
18
+ attribute? :video_note, VideoNote
19
+ attribute? :voice, Voice
20
+ attribute? :has_media_spoiler, Types::True
21
+ attribute? :contact, Contact
22
+ attribute? :dice, Dice
23
+ attribute? :game, Game
24
+ attribute? :giveaway, Giveaway
25
+ attribute? :giveaway_winners, GiveawayWinners
26
+ attribute? :invoice, Invoice
27
+ attribute? :location, Location
28
+ attribute? :poll, Poll
29
+ attribute? :venue, Venue
30
+ end
31
+ end
32
+ end
33
+ end
@@ -4,7 +4,7 @@ module Telegram
4
4
  module Bot
5
5
  module Types
6
6
  class ForceReply < Base
7
- attribute :force_reply, Types::Bool
7
+ attribute :force_reply, Types::True
8
8
  attribute? :input_field_placeholder, Types::String
9
9
  attribute? :selective, Types::Bool.default(false)
10
10
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class Giveaway < Base
7
+ attribute :chats, Types::Array.of(Chat)
8
+ attribute :winners_selection_date, Types::Integer
9
+ attribute :winner_count, Types::Integer
10
+ attribute? :only_new_members, Types::True
11
+ attribute? :has_public_winners, Types::True
12
+ attribute? :prize_description, Types::String
13
+ attribute? :country_codes, Types::Array.of(Types::String)
14
+ attribute? :premium_subscription_month_count, Types::Integer
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class GiveawayCompleted < Base
7
+ attribute :winner_count, Types::Integer
8
+ attribute? :unclaimed_prize_count, Types::Integer
9
+ attribute? :giveaway_message, Message
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class GiveawayCreated < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class GiveawayWinners < Base
7
+ attribute :chat, Chat
8
+ attribute :giveaway_message_id, Types::Integer
9
+ attribute :winners_selection_date, Types::Integer
10
+ attribute :winner_count, Types::Integer
11
+ attribute :winners, Types::Array.of(User)
12
+ attribute? :additional_chat_count, Types::Integer
13
+ attribute? :premium_subscription_month_count, Types::Integer
14
+ attribute? :unclaimed_prize_count, Types::Integer
15
+ attribute? :only_new_members, Types::True
16
+ attribute? :was_refunded, Types::True
17
+ attribute? :prize_description, Types::String
18
+ end
19
+ end
20
+ end
21
+ end