telegram-bot-types 0.4.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +11 -1
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +22 -0
  5. data/Gemfile +2 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +1 -0
  8. data/bin/install_git_hooks +2 -1
  9. data/lib/telegram/bot/types.rb +19 -70
  10. data/lib/telegram/bot/types/animation.rb +6 -0
  11. data/lib/telegram/bot/types/audio.rb +5 -0
  12. data/lib/telegram/bot/types/base.rb +6 -0
  13. data/lib/telegram/bot/types/callback_game.rb +2 -0
  14. data/lib/telegram/bot/types/callback_query.rb +2 -0
  15. data/lib/telegram/bot/types/chat.rb +10 -0
  16. data/lib/telegram/bot/types/chat_invite_link.rb +16 -0
  17. data/lib/telegram/bot/types/chat_location.rb +12 -0
  18. data/lib/telegram/bot/types/chat_member.rb +22 -0
  19. data/lib/telegram/bot/types/chat_member_updated.rb +16 -0
  20. data/lib/telegram/bot/types/chat_permissions.rb +18 -0
  21. data/lib/telegram/bot/types/chat_photo.rb +14 -0
  22. data/lib/telegram/bot/types/chosen_inline_result.rb +2 -0
  23. data/lib/telegram/bot/types/contact.rb +3 -0
  24. data/lib/telegram/bot/types/dice.rb +12 -0
  25. data/lib/telegram/bot/types/document.rb +3 -0
  26. data/lib/telegram/bot/types/encrypted_credentials.rb +13 -0
  27. data/lib/telegram/bot/types/encrypted_passport_element.rb +20 -0
  28. data/lib/telegram/bot/types/file.rb +3 -0
  29. data/lib/telegram/bot/types/force_reply.rb +2 -0
  30. data/lib/telegram/bot/types/game.rb +2 -0
  31. data/lib/telegram/bot/types/game_high_score.rb +2 -0
  32. data/lib/telegram/bot/types/inline_keyboard_button.rb +3 -0
  33. data/lib/telegram/bot/types/inline_keyboard_markup.rb +2 -0
  34. data/lib/telegram/bot/types/inline_query.rb +2 -0
  35. data/lib/telegram/bot/types/inline_query_result_article.rb +2 -0
  36. data/lib/telegram/bot/types/inline_query_result_audio.rb +3 -0
  37. data/lib/telegram/bot/types/inline_query_result_cached_audio.rb +3 -0
  38. data/lib/telegram/bot/types/inline_query_result_cached_document.rb +3 -0
  39. data/lib/telegram/bot/types/inline_query_result_cached_gif.rb +3 -0
  40. data/lib/telegram/bot/types/inline_query_result_cached_mpeg4_gif.rb +3 -0
  41. data/lib/telegram/bot/types/inline_query_result_cached_photo.rb +3 -0
  42. data/lib/telegram/bot/types/inline_query_result_cached_sticker.rb +2 -0
  43. data/lib/telegram/bot/types/inline_query_result_cached_video.rb +3 -0
  44. data/lib/telegram/bot/types/inline_query_result_cached_voice.rb +3 -0
  45. data/lib/telegram/bot/types/inline_query_result_contact.rb +3 -0
  46. data/lib/telegram/bot/types/inline_query_result_document.rb +3 -0
  47. data/lib/telegram/bot/types/inline_query_result_game.rb +2 -0
  48. data/lib/telegram/bot/types/inline_query_result_gif.rb +3 -0
  49. data/lib/telegram/bot/types/inline_query_result_location.rb +6 -0
  50. data/lib/telegram/bot/types/inline_query_result_mpeg4_gif.rb +4 -0
  51. data/lib/telegram/bot/types/inline_query_result_photo.rb +3 -0
  52. data/lib/telegram/bot/types/inline_query_result_venue.rb +5 -0
  53. data/lib/telegram/bot/types/inline_query_result_video.rb +3 -0
  54. data/lib/telegram/bot/types/inline_query_result_voice.rb +3 -0
  55. data/lib/telegram/bot/types/input_contact_message_content.rb +3 -0
  56. data/lib/telegram/bot/types/input_location_message_content.rb +6 -0
  57. data/lib/telegram/bot/types/input_media_animation.rb +18 -0
  58. data/lib/telegram/bot/types/input_media_audio.rb +18 -0
  59. data/lib/telegram/bot/types/input_media_document.rb +17 -0
  60. data/lib/telegram/bot/types/input_media_photo.rb +14 -0
  61. data/lib/telegram/bot/types/input_media_video.rb +18 -0
  62. data/lib/telegram/bot/types/input_message_content.rb +2 -0
  63. data/lib/telegram/bot/types/input_text_message_content.rb +2 -0
  64. data/lib/telegram/bot/types/input_venue_message_content.rb +5 -0
  65. data/lib/telegram/bot/types/invoice.rb +2 -0
  66. data/lib/telegram/bot/types/keyboard_button.rb +3 -0
  67. data/lib/telegram/bot/types/keyboard_button_poll_type.rb +11 -0
  68. data/lib/telegram/bot/types/labeled_price.rb +2 -0
  69. data/lib/telegram/bot/types/location.rb +6 -0
  70. data/lib/telegram/bot/types/login_url.rb +14 -0
  71. data/lib/telegram/bot/types/mask_position.rb +14 -0
  72. data/lib/telegram/bot/types/message.rb +20 -0
  73. data/lib/telegram/bot/types/message_auto_delete_timer_changed.rb +11 -0
  74. data/lib/telegram/bot/types/message_entity.rb +3 -0
  75. data/lib/telegram/bot/types/order_info.rb +2 -0
  76. data/lib/telegram/bot/types/passport_data.rb +12 -0
  77. data/lib/telegram/bot/types/passport_element_error_data_field.rb +15 -0
  78. data/lib/telegram/bot/types/passport_element_error_file.rb +14 -0
  79. data/lib/telegram/bot/types/passport_element_error_files.rb +14 -0
  80. data/lib/telegram/bot/types/passport_element_error_front_side.rb +14 -0
  81. data/lib/telegram/bot/types/passport_element_error_reverse_side.rb +14 -0
  82. data/lib/telegram/bot/types/passport_element_error_selfie.rb +14 -0
  83. data/lib/telegram/bot/types/passport_element_error_translation_file.rb +14 -0
  84. data/lib/telegram/bot/types/passport_element_error_translation_files.rb +14 -0
  85. data/lib/telegram/bot/types/passport_element_error_unspecified.rb +14 -0
  86. data/lib/telegram/bot/types/passport_file.rb +14 -0
  87. data/lib/telegram/bot/types/photo_size.rb +3 -0
  88. data/lib/telegram/bot/types/poll.rb +23 -0
  89. data/lib/telegram/bot/types/poll_answer.rb +13 -0
  90. data/lib/telegram/bot/types/poll_option.rb +12 -0
  91. data/lib/telegram/bot/types/pre_checkout_query.rb +2 -0
  92. data/lib/telegram/bot/types/proximity_alert_triggered.rb +13 -0
  93. data/lib/telegram/bot/types/reply_keyboard_markup.rb +2 -0
  94. data/lib/telegram/bot/types/reply_keyboard_remove.rb +2 -0
  95. data/lib/telegram/bot/types/response.rb +94 -0
  96. data/lib/telegram/bot/types/shipping_address.rb +2 -0
  97. data/lib/telegram/bot/types/shipping_option.rb +2 -0
  98. data/lib/telegram/bot/types/shipping_query.rb +2 -0
  99. data/lib/telegram/bot/types/sticker.rb +6 -0
  100. data/lib/telegram/bot/types/sticker_set.rb +16 -0
  101. data/lib/telegram/bot/types/successful_payment.rb +2 -0
  102. data/lib/telegram/bot/types/update.rb +6 -0
  103. data/lib/telegram/bot/types/user.rb +6 -0
  104. data/lib/telegram/bot/types/user_profile_photos.rb +2 -0
  105. data/lib/telegram/bot/types/venue.rb +5 -0
  106. data/lib/telegram/bot/types/version.rb +3 -1
  107. data/lib/telegram/bot/types/video.rb +4 -0
  108. data/lib/telegram/bot/types/video_note.rb +3 -0
  109. data/lib/telegram/bot/types/voice.rb +3 -0
  110. data/lib/telegram/bot/types/voice_chat_ended.rb +11 -0
  111. data/lib/telegram/bot/types/voice_chat_participants_invited.rb +11 -0
  112. data/lib/telegram/bot/types/voice_chat_started.rb +10 -0
  113. data/lib/telegram/bot/types/webhook_info.rb +19 -0
  114. data/telegram-bot-types.gemspec +5 -4
  115. metadata +50 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 85255981f3fa947c7001592ffa42a38cd96e9916
4
- data.tar.gz: bd72458c724896c5ea7a58c0b3d22b552861cc27
2
+ SHA256:
3
+ metadata.gz: 0606fc748fb8602745774a0445227cfd5ead1b8d5669bd08bd9ee1bb0ce3b53b
4
+ data.tar.gz: b8c309b5149ac1b850dcd7de3e4fda9150091d1b91dff03376b5e8b93c15d44e
5
5
  SHA512:
6
- metadata.gz: 4c49b3b44ab2731764e7d7b4d5f6ad3a9f261d512a87089e5a2822bb7721308398295617fcf458fa35bbb5eaa9e0d08c011074771ddf084da633e9e7728248d9
7
- data.tar.gz: 79e3ef124f2e3ab0fe3cfe8e5aee74a2f4d94597f3f60a1bb5f4a5d409a988bc8ae7dca28d03415155ce6e508984c0bfb8695a5c6e004bc45ffb66e968788ced
6
+ metadata.gz: 2c5928397f4828c224ca987c5487655ccf5e9603329859fa13c64b6e12dc792ec53d62d0cc3b3b201be552982e7e1e12dba72eabb986c0dbc42c8bde28639d2d
7
+ data.tar.gz: 26927705f798cc3da58bc6371f10d8b1c1104342a913f29e8a9298b38ee16ea0bb20900fd4e016f7a493742edf6740645efa3743e09f0ee55d631ee959096a90
data/.rubocop.yml CHANGED
@@ -1,4 +1,14 @@
1
+ Layout/EmptyLineAfterGuardClause: {Enabled: false}
2
+ Layout/SpaceInsideHashLiteralBraces: {EnforcedStyle: no_space}
1
3
  Metrics/LineLength: {Max: 100}
2
4
  Style/Alias: {EnforcedStyle: prefer_alias_method}
3
5
  Style/Documentation: {Enabled: false}
4
- Style/TrailingCommaInLiteral: {EnforcedStyleForMultiline: comma}
6
+ Style/TrailingCommaInArrayLiteral: {EnforcedStyleForMultiline: comma}
7
+ Style/TrailingCommaInHashLiteral: {EnforcedStyleForMultiline: comma}
8
+
9
+ # New cops. Need to be explicitly enabled to prevent warning.
10
+ Lint/RaiseException: {Enabled: true}
11
+ Lint/StructNewOverride: {Enabled: true}
12
+ Style/HashEachMethods: {Enabled: true}
13
+ Style/HashTransformKeys: {Enabled: true}
14
+ Style/HashTransformValues: {Enabled: true}
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.2.3
4
+ - 2.6
5
5
  notifications:
6
6
  email: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Unreleased
2
+
3
+ # 0.6.3
4
+
5
+ - Bunch of new types from Bot API 5.3.
6
+
7
+ # 0.6.2
8
+
9
+ - Bunch of new types.
10
+
11
+ # 0.6.1
12
+
13
+ - Strip empty values from `#to_hash`.
14
+
15
+ # 0.6.0
16
+
17
+ - Add WebhookInfo
18
+ - Add Response module to cast results from api methods.
19
+
20
+ # Older
21
+
22
+ See `git log`. `¯\_(ツ)_/¯`
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'telegram/bot/types'
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- root = File.expand_path('../../', __FILE__)
4
+ root = File.expand_path('..', __dir__)
4
5
  hooks_dir = "#{root}/bin/git-hooks"
5
6
 
6
7
  `ls -1 #{hooks_dir}`.each_line.map(&:strip).each do |file|
@@ -1,78 +1,27 @@
1
- require 'active_support/core_ext/string/inflections'
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
2
4
 
3
5
  module Telegram
4
6
  module Bot
5
7
  module Types
6
- %w(
7
- animation
8
- audio
9
- base
10
- callback_game
11
- callback_query
12
- chat
13
- chat_member
14
- chosen_inline_result
15
- contact
16
- document
17
- file
18
- force_reply
19
- game
20
- game_high_score
21
- inline_keyboard_button
22
- inline_keyboard_markup
23
- inline_query
24
- inline_query_result_article
25
- inline_query_result_audio
26
- inline_query_result_cached_audio
27
- inline_query_result_cached_document
28
- inline_query_result_cached_gif
29
- inline_query_result_cached_mpeg4_gif
30
- inline_query_result_cached_photo
31
- inline_query_result_cached_sticker
32
- inline_query_result_cached_video
33
- inline_query_result_cached_voice
34
- inline_query_result_contact
35
- inline_query_result_document
36
- inline_query_result_game
37
- inline_query_result_gif
38
- inline_query_result_location
39
- inline_query_result_mpeg4_gif
40
- inline_query_result_photo
41
- inline_query_result_venue
42
- inline_query_result_video
43
- inline_query_result_voice
44
- input_contact_message_content
45
- input_location_message_content
46
- input_message_content
47
- input_text_message_content
48
- input_venue_message_content
49
- invoice
50
- keyboard_button
51
- labeled_price
52
- location
53
- message
54
- message_entity
55
- order_info
56
- photo_size
57
- pre_checkout_query
58
- reply_keyboard_markup
59
- reply_keyboard_remove
60
- shipping_address
61
- shipping_option
62
- shipping_query
63
- sticker
64
- successful_payment
65
- update
66
- user
67
- user_profile_photos
68
- venue
69
- version
70
- video
71
- video_note
72
- voice
73
- ).each do |type|
74
- autoload type.camelize, "telegram/bot/types/#{type}"
8
+ module_function
9
+
10
+ # Simple implementation for internal use only.
11
+ # rubocop:disable all
12
+ def camelize(str)
13
+ str.gsub(/(?:_|(\/)|^)([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
14
+ end
15
+ # rubocop:enable all
16
+
17
+ files = Pathname(__FILE__).dirname.join('types').children.map { |x| x.basename.to_s }
18
+ types = files.select { |x| x.end_with?('.rb') }.map { |x| x.gsub(/\.rb$/, '') }
19
+ types -= ['version']
20
+ types.each do |type|
21
+ autoload camelize(type), "telegram/bot/types/#{type}"
75
22
  end
76
23
  end
77
24
  end
78
25
  end
26
+
27
+ require 'telegram/bot/types/version'
@@ -1,8 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
4
6
  class Animation < Base
5
7
  attribute :file_id, String
8
+ attribute :file_unique_id, String
9
+ attribute :width, Integer
10
+ attribute :height, Integer
11
+ attribute :duration, Integer
6
12
  attribute :thumb, PhotoSize
7
13
  attribute :file_name, String
8
14
  attribute :mime_type, String
@@ -1,13 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
4
6
  class Audio < Base
5
7
  attribute :file_id, String
8
+ attribute :file_unique_id, String
6
9
  attribute :duration, Integer
7
10
  attribute :performer, String
8
11
  attribute :title, String
12
+ attribute :file_name, String
9
13
  attribute :mime_type, String
10
14
  attribute :file_size, Integer
15
+ attribute :thumb, PhotoSize
11
16
  end
12
17
  end
13
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'virtus'
2
4
 
3
5
  module Telegram
@@ -5,6 +7,10 @@ module Telegram
5
7
  module Types
6
8
  class Base
7
9
  include Virtus.model
10
+
11
+ def to_hash(*)
12
+ super.reject { |_k, v| v.nil? }
13
+ end
8
14
  end
9
15
  end
10
16
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
@@ -9,6 +11,14 @@ module Telegram
9
11
  attribute :first_name, String
10
12
  attribute :last_name, String
11
13
  attribute :all_members_are_administrators, Boolean
14
+ attribute :photo, ChatPhoto
15
+ attribute :description, String
16
+ attribute :invite_link, String
17
+ attribute :pinned_message, Message
18
+ attribute :permissions, ChatPermissions
19
+ attribute :slow_mode_delay, Integer
20
+ attribute :sticker_set_name, String
21
+ attribute :can_set_sticker_set, Boolean
12
22
  end
13
23
  end
14
24
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatInviteLink < Base
7
+ attribute :invite_link, String
8
+ attribute :creator, User
9
+ attribute :is_primary, Boolean
10
+ attribute :is_revoked, Boolean
11
+ attribute :expire_date, Integer
12
+ attribute :member_limit, Integer
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatLocation < Base
7
+ attribute :location, Location
8
+ attribute :address, String
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,9 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
4
6
  class ChatMember < Base
5
7
  attribute :user, User
6
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_voice_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
7
29
  end
8
30
  end
9
31
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatMemberUpdated < Base
7
+ attribute :chat, Chat
8
+ attribute :from, User
9
+ attribute :date, Integer
10
+ attribute :old_chat_member, ChatMember
11
+ attribute :new_chat_member, ChatMember
12
+ attribute :invite_link, ChatInviteLink
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatPermissions < Base
7
+ attribute :can_send_messages, Boolean
8
+ attribute :can_send_media_messages, Boolean
9
+ attribute :can_send_polls, Boolean
10
+ attribute :can_send_other_messages, Boolean
11
+ attribute :can_add_web_page_previews, Boolean
12
+ attribute :can_change_info, Boolean
13
+ attribute :can_invite_users, Boolean
14
+ attribute :can_pin_messages, Boolean
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class ChatPhoto < Base
7
+ attribute :small_file_id, String
8
+ attribute :small_file_unique_id, String
9
+ attribute :big_file_id, String
10
+ attribute :big_file_unique_id, String
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
@@ -6,6 +8,7 @@ module Telegram
6
8
  attribute :first_name, String
7
9
  attribute :last_name, String
8
10
  attribute :user_id, Integer
11
+ attribute :vcard, String
9
12
  end
10
13
  end
11
14
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class Dice < Base
7
+ attribute :emoji, String
8
+ attribute :value, Integer
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telegram
2
4
  module Bot
3
5
  module Types
4
6
  class Document < Base
5
7
  attribute :file_id, String
8
+ attribute :file_unique_id, String
6
9
  attribute :thumb, PhotoSize
7
10
  attribute :file_name, String
8
11
  attribute :mime_type, String