teleruby 1.5.1 → 1.5.4

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +9 -0
  3. data/README.md +398 -0
  4. data/lib/api/all.rb +12 -0
  5. data/lib/api/delete_apis.rb +55 -0
  6. data/lib/api/get_apis.rb +162 -0
  7. data/lib/api/nstandard.rb +26 -0
  8. data/lib/api/other_apis.rb +225 -0
  9. data/lib/api/send_apis.rb +191 -0
  10. data/lib/api/set_apis.rb +130 -0
  11. data/lib/core_api.rb +41 -0
  12. data/lib/objects/all.rb +42 -0
  13. data/lib/objects/animation.rb +38 -0
  14. data/lib/objects/audio.rb +37 -0
  15. data/lib/objects/bot_command.rb +24 -0
  16. data/lib/objects/callback_query.rb +64 -0
  17. data/lib/objects/chat.rb +158 -0
  18. data/lib/objects/chat_member.rb +142 -0
  19. data/lib/objects/chat_permissions.rb +59 -0
  20. data/lib/objects/chat_photo.rb +37 -0
  21. data/lib/objects/chosen_inline_result.rb +43 -0
  22. data/lib/objects/contact.rb +37 -0
  23. data/lib/objects/dice.rb +21 -0
  24. data/lib/objects/document.rb +27 -0
  25. data/lib/objects/file.rb +32 -0
  26. data/lib/objects/game.rb +65 -0
  27. data/lib/objects/inline_query.rb +42 -0
  28. data/lib/objects/inlinekeyboardbutton.rb +59 -0
  29. data/lib/objects/inlinekeyboardmarkup.rb +30 -0
  30. data/lib/objects/location.rb +21 -0
  31. data/lib/objects/mask_position.rb +35 -0
  32. data/lib/objects/message.rb +378 -0
  33. data/lib/objects/message_entity.rb +93 -0
  34. data/lib/objects/order_info.rb +34 -0
  35. data/lib/objects/photo_size.rb +14 -0
  36. data/lib/objects/poll.rb +97 -0
  37. data/lib/objects/poll_answer.rb +29 -0
  38. data/lib/objects/poll_option.rb +22 -0
  39. data/lib/objects/pre_checkout_query.rb +48 -0
  40. data/lib/objects/same/common.rb +37 -0
  41. data/lib/objects/same/common_2.rb +38 -0
  42. data/lib/objects/shipping_address.rb +39 -0
  43. data/lib/objects/shipping_query.rb +32 -0
  44. data/lib/objects/sticker.rb +55 -0
  45. data/lib/objects/update.rb +174 -0
  46. data/lib/objects/user.rb +66 -0
  47. data/lib/objects/user_profile_photos.rb +35 -0
  48. data/lib/objects/venue.rb +40 -0
  49. data/lib/objects/video.rb +37 -0
  50. data/lib/objects/video_note.rb +48 -0
  51. data/lib/objects/voice.rb +20 -0
  52. data/lib/teleruby.rb +4 -40
  53. data/lib/teleruby/all_apis.rb +22 -0
  54. data/lib/teleruby/api/delete_apis.rb +58 -0
  55. data/lib/teleruby/api/get_apis.rb +172 -0
  56. data/lib/teleruby/api/nstandard.rb +27 -0
  57. data/lib/teleruby/api/other_apis.rb +241 -0
  58. data/lib/teleruby/api/send_apis.rb +206 -0
  59. data/lib/teleruby/api/set_apis.rb +137 -0
  60. data/lib/teleruby/core_api.rb +52 -0
  61. data/lib/teleruby/objects/all.rb +42 -0
  62. data/lib/teleruby/objects/animation.rb +40 -0
  63. data/lib/teleruby/objects/audio.rb +39 -0
  64. data/lib/teleruby/objects/bot_command.rb +24 -0
  65. data/lib/teleruby/objects/callback_query.rb +66 -0
  66. data/lib/teleruby/objects/chat.rb +164 -0
  67. data/lib/teleruby/objects/chat_member.rb +142 -0
  68. data/lib/teleruby/objects/chat_permissions.rb +59 -0
  69. data/lib/teleruby/objects/chat_photo.rb +37 -0
  70. data/lib/teleruby/objects/chosen_inline_result.rb +45 -0
  71. data/lib/teleruby/objects/contact.rb +37 -0
  72. data/lib/teleruby/objects/dice.rb +21 -0
  73. data/lib/teleruby/objects/document.rb +29 -0
  74. data/lib/teleruby/objects/file.rb +32 -0
  75. data/lib/teleruby/objects/game.rb +65 -0
  76. data/lib/teleruby/objects/inline_query.rb +44 -0
  77. data/lib/teleruby/objects/inlinekeyboardbutton.rb +59 -0
  78. data/lib/teleruby/objects/inlinekeyboardmarkup.rb +31 -0
  79. data/lib/teleruby/objects/location.rb +21 -0
  80. data/lib/teleruby/objects/mask_position.rb +35 -0
  81. data/lib/teleruby/objects/message.rb +400 -0
  82. data/lib/teleruby/objects/message_entity.rb +95 -0
  83. data/lib/teleruby/objects/order_info.rb +36 -0
  84. data/lib/teleruby/objects/photo_size.rb +14 -0
  85. data/lib/teleruby/objects/poll.rb +97 -0
  86. data/lib/teleruby/objects/poll_answer.rb +29 -0
  87. data/lib/teleruby/objects/poll_option.rb +22 -0
  88. data/lib/teleruby/objects/pre_checkout_query.rb +50 -0
  89. data/lib/teleruby/objects/same/common.rb +31 -0
  90. data/lib/teleruby/objects/same/common_2.rb +32 -0
  91. data/lib/teleruby/objects/shipping_address.rb +39 -0
  92. data/lib/teleruby/objects/shipping_query.rb +32 -0
  93. data/lib/teleruby/objects/sticker.rb +59 -0
  94. data/lib/teleruby/objects/update.rb +207 -0
  95. data/lib/teleruby/objects/user.rb +66 -0
  96. data/lib/teleruby/objects/user_profile_photos.rb +36 -0
  97. data/lib/teleruby/objects/venue.rb +40 -0
  98. data/lib/teleruby/objects/video.rb +39 -0
  99. data/lib/teleruby/objects/video_note.rb +50 -0
  100. data/lib/teleruby/objects/voice.rb +20 -0
  101. data/lib/teleruby/version.rb +3 -0
  102. data/msg.png +0 -0
  103. data/rdoc.png +0 -0
  104. data/teleruby.gemspec +9 -7
  105. metadata +109 -6
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'shipping_address'
5
+
6
+ # This object represents information about an order.
7
+ class OrderInfo
8
+ def initialize(info) # :nodoc:
9
+ @info = info
10
+ end
11
+
12
+ # Optional. User name
13
+ def name
14
+ @info.name
15
+ end
16
+
17
+ # Optional. User's phone number.
18
+ def phone_number
19
+ @info.phone_number
20
+ end
21
+
22
+ # Optional. User email
23
+ def email
24
+ @info.email
25
+ end
26
+
27
+ # Optional. User shipping address
28
+ def shipping_address
29
+ address = @info.shipping_address
30
+ unless address.nil?
31
+ return ShippingAddress.new(address)
32
+ end
33
+
34
+ false
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'same/common'
5
+
6
+ ##
7
+ # +Monday,+ +August+ +24+ +2020+
8
+ # ===This object represents one size of a photo or a file/sticker thumbnail.
9
+ # Extends Common class.
10
+ class PhotoSize < Common
11
+ def initialize(photo) # :nodoc:
12
+ super(photo)
13
+ end
14
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'poll_option'
5
+ require_relative 'message_entity'
6
+
7
+ # ===This object contains information about a poll.
8
+ class Poll
9
+ def initialize(poll) # :nodoc:
10
+ @poll = poll
11
+ freeze
12
+ end
13
+
14
+ # Unique poll identifier.
15
+ def id
16
+ @poll.id
17
+ end
18
+
19
+ # Poll question, 1-255 characters.
20
+ def question
21
+ @poll.question
22
+ end
23
+
24
+ # Returns array of PollOption s. else false is returned.
25
+ def options
26
+ opt = @poll.options
27
+ unless opt.nil?
28
+ poll_options = []
29
+ opt.each do |o|
30
+ poll_options << PollOption.new(o)
31
+ end
32
+ return poll_options
33
+ end
34
+
35
+ false
36
+ end
37
+
38
+ # Total number of users that voted in the poll.
39
+ def total_voter_count
40
+ @poll.total_voter_count
41
+ end
42
+
43
+ # True, if the poll is closed.
44
+ def closed?
45
+ @poll.is_closed
46
+ end
47
+
48
+ # True, if the poll is anonymous.
49
+ def anonymous?
50
+ @poll.is_anonymous
51
+ end
52
+
53
+ # Poll type, currently can be "regular" or "quiz"
54
+ def type
55
+ @poll.type
56
+ end
57
+
58
+ # +Optional+. 0-based identifier of the correct answer option.
59
+ # Available only for polls in the quiz mode, which are closed, or was
60
+ # sent (not forwarded) by the bot or to the private chat with the bot.
61
+ def correct_option_id
62
+ @poll.correct_option_id
63
+ end
64
+
65
+ # +Optional.+ Text that is shown when a user chooses an incorrect answer
66
+ # or taps on the lamp icon in a quiz-style poll, 0-200 characters.
67
+ def explanation
68
+ @poll.explanation
69
+ end
70
+
71
+ # +Optional.+ Special entities like *usernames*, *URLs*, bot commands,
72
+ # etc. that appear in the explanation.
73
+ def explanation_entities
74
+ data = @poll.explanation_entities
75
+ unless data.nil?
76
+ explanations = []
77
+ data.each do |exp|
78
+ explanations << MessageEntity.new(exp)
79
+ end
80
+ return explanations
81
+ end
82
+
83
+ false
84
+ end
85
+
86
+ # +Optional.+ Amount of time in seconds the poll will be active after
87
+ # creation.
88
+ def open_period
89
+ @poll.open_period
90
+ end
91
+
92
+ # +Optional.+ Point in time (Unix timestamp) when the poll will be
93
+ # automatically closed.
94
+ def close_date
95
+ @poll.close_date
96
+ end
97
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+
6
+ # +Sunday,+ +August+ +23+ +2020+
7
+
8
+ # ===This object represents an answer of a user in a non-anonymous poll.
9
+ class PollAnswer
10
+ def initialize(poll) # :nodoc:
11
+ @poll = poll
12
+ end
13
+
14
+ # Unique poll identifier.
15
+ def poll_id
16
+ @poll.poll_id
17
+ end
18
+
19
+ # The user, who changed the answer to the poll. Return User object
20
+ def user
21
+ User.new(@poll.user)
22
+ end
23
+
24
+ # 0-based identifiers of answer options, chosen by the user.
25
+ # May be empty if the user retracted their vote.
26
+ def option_ids
27
+ @poll.option_ids
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday,+ +August+ +24+ 2020+ +EAT+
6
+ # ===This object contains information about one answer option in a poll.
7
+ class PollOption
8
+ def initialize(poll) # :nodoc:
9
+ @poll = poll
10
+ freeze
11
+ end
12
+
13
+ # +Option+ text, 1-100 characters.
14
+ def text
15
+ @poll.text
16
+ end
17
+
18
+ # Number of users that voted for this option.
19
+ def voter_count
20
+ @poll.voter_count
21
+ end
22
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'order_info'
6
+
7
+ # This object contains information about an incoming pre-checkout query.
8
+ class PreCheckoutQuery
9
+ def initialize(query) # :nodoc:
10
+ @query = query
11
+ end
12
+
13
+ # Unique query identifier.
14
+ def id
15
+ @query.id
16
+ end
17
+
18
+ # User who sent the query.
19
+ def from
20
+ User.new(@query.from)
21
+ end
22
+
23
+ # Three-letter ISO 4217 currency code
24
+ def currency
25
+ @query.currency
26
+ end
27
+
28
+ # Total price in the smallest units of the currency
29
+ # (integer, not float/double). For example, for a price of US$ 1.45
30
+ # pass amount = 145 . See the exp parameter in currencies.json,
31
+ # it shows the number of digits past the decimal point for each
32
+ # currency (2 for the majority of currencies).
33
+ def total_count
34
+ @query.total_count
35
+ end
36
+
37
+ # Bot specified invoice payload.
38
+ def invoice_option_id
39
+ @query.invoice_option_id
40
+ end
41
+
42
+ def order_info
43
+ info = @query.order_info
44
+ unless info.nil?
45
+ return OrderInfo.new(info)
46
+ end
47
+
48
+ false
49
+ end
50
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===Common class
7
+ class Common
8
+ def initialize(obj) # :nodoc:
9
+ @obj = obj
10
+ end
11
+
12
+ def file_id
13
+ @obj['file_id']
14
+ end
15
+
16
+ def file_unique_id
17
+ @obj['file_unique_id']
18
+ end
19
+
20
+ def width
21
+ @obj['width']
22
+ end
23
+
24
+ def heigth
25
+ @obj['heigth']
26
+ end
27
+
28
+ def file_size
29
+ @obj['file_size']
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday,+ +August+ +24+ +2020+
6
+ # ===common class for Audio, Video, and Document and Voice
7
+ class Common2
8
+ def initialize(obj) # :nodoc:
9
+ @obj = obj
10
+ freeze
11
+ end
12
+
13
+ # File id for the object
14
+ def file_id
15
+ @obj['file_id']
16
+ end
17
+
18
+ # File unique id for the object.
19
+ def file_unique_id
20
+ @obj['file_unique_id']
21
+ end
22
+
23
+ # +Optional+. MIME type of the file as defined by sender.
24
+ def mime_type
25
+ @obj['mime_type']
26
+ end
27
+
28
+ # +Optional.+ File size
29
+ def file_size
30
+ @obj['file_size']
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # ===This object represents a shipping address
5
+ class ShippingAddress
6
+ def initialize(shipping) # :nodoc:
7
+ @shipping = shipping
8
+ end
9
+
10
+ # ISO 3166-1 alpha-2 country code.
11
+ def country_code
12
+ @shipping.country_code
13
+ end
14
+
15
+ # State, if applicable.
16
+ def state
17
+ @shipping.state
18
+ end
19
+
20
+ # City
21
+ def city
22
+ @shipping.city
23
+ end
24
+
25
+ # First line for the address.
26
+ def street_line1
27
+ @shipping.street_lin2
28
+ end
29
+
30
+ # Second line for the address
31
+ def street_line2
32
+ @shipping.street_line2
33
+ end
34
+
35
+ # Address post code
36
+ def post_code
37
+ @shipping.post_code
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'shipping_address'
6
+
7
+ # ===This object contains information about an incoming shipping query.
8
+ class ShippingQuery
9
+ def initialize(query) # :nodoc:
10
+ @query = query
11
+ end
12
+
13
+ # Unique query identifier.
14
+ def id
15
+ @query.id
16
+ end
17
+
18
+ # User who sent the query.
19
+ def from
20
+ User.new(@query.from)
21
+ end
22
+
23
+ # Bot specified invoice payload.
24
+ def invoice_payload
25
+ @query.invoice_payload
26
+ end
27
+
28
+ # User specified shipping address.
29
+ def shipping_address
30
+ ShippingAddress.new(@query.shipping_address)
31
+ end
32
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'file'
5
+ require_relative 'photo_size'
6
+ require_relative 'mask_position'
7
+
8
+ ##
9
+ # This object represents a sticker.
10
+ # Extends from TFile
11
+ class Sticker < TFile
12
+ def initialize(sticker) # :nodoc:
13
+ super(sticker)
14
+ end
15
+
16
+ # Sticker width
17
+ def width
18
+ @file.width
19
+ end
20
+
21
+ # Sticker height
22
+ def height
23
+ @sticker.height
24
+ end
25
+
26
+ # True, if the sticker is animated
27
+ def animated?
28
+ @sticker.is_animated
29
+ end
30
+
31
+ # Optional. Sticker thumbnail in the .WEBP or .JPG format
32
+ def thumb
33
+ tmb = @sticker.thumb
34
+ if tmb
35
+ return PhotoSize.new(tmb)
36
+ end
37
+
38
+ false
39
+ end
40
+
41
+ # Optional. Emoji associated with the sticker
42
+ def emoji
43
+ @sticker.emoji
44
+ end
45
+
46
+ # Optional. Name of the sticker set to which the sticker belongs.
47
+ def set_name
48
+ @sticker.set_name
49
+ end
50
+
51
+ def mask_position
52
+ msk_pos = @sticker.mask_position
53
+ if msk_pos
54
+ return MaskPosition.new(msk_pos)
55
+ end
56
+
57
+ false
58
+ end
59
+ end