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,207 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'message'
5
+ require_relative 'poll'
6
+ require_relative 'poll_answer'
7
+ require_relative 'callback_query'
8
+ require_relative 'chosen_inline_result'
9
+ require_relative 'inline_query'
10
+ require_relative 'pre_checkout_query'
11
+ require_relative 'shipping_query'
12
+
13
+ # ===This object represents an incoming update.
14
+ class Update
15
+ def initialize(update) # :nodoc:
16
+ @update = update
17
+ end
18
+
19
+
20
+ # The update's unique identifier. Update identifiers start from a
21
+ # certain positive number and increase sequentially. This ID becomes
22
+ # especially handy if you're using Webhooks, since it allows you to
23
+ # ignore repeated updates or to restore the correct update sequence,
24
+ # should they get out of order. If there are no new updates for at
25
+ # least a week, then identifier of the next update will be chosen
26
+ # randomly instead of sequentially.
27
+ def update_id
28
+ @update.update_id
29
+ end
30
+
31
+ ##
32
+ # New incoming message of any kind — text, photo, sticker, etc else
33
+ # false is returned.
34
+ # returns Message object
35
+ def message
36
+ msg = @update.message
37
+ unless msg.nil?
38
+ return Message.new(msg)
39
+ end
40
+
41
+ false
42
+ end
43
+
44
+ ##
45
+ # New version of a message that is known to the bot and was edited else
46
+ # false is returned.
47
+ def edited_message
48
+ e_msg = @update.edited_message
49
+ unless e_msg.nil?
50
+ return Message.new(e_msg)
51
+ end
52
+
53
+ false
54
+ end
55
+
56
+ ##
57
+ # New incoming channel post of any kind — text, photo, sticker, etc else
58
+ # false is returned.
59
+ def channel_post
60
+ c_post = @update.channel_post
61
+ unless c_post.nil?
62
+ return Message.new(c_post)
63
+ end
64
+
65
+ false
66
+ end
67
+
68
+ ##
69
+ # New version of a channel post that is known to the bot and was edited.
70
+ # else false is returned.
71
+ def edited_channel_post
72
+ e_c_post = @update.edited_channel_post
73
+ unless e_c_post.nil?
74
+ return Message.new(e_c_post)
75
+ end
76
+
77
+ false
78
+ end
79
+
80
+ ##
81
+ # +Optional.+ New incoming inline query.
82
+ def inline_query
83
+ i_query = @update.inline_query
84
+ unless i_query.nil?
85
+ return InlineQuery.new(i_query)
86
+ end
87
+
88
+ false
89
+ end
90
+
91
+ ##
92
+ # +Optional.+ The result of an inline query that was chosen by a user
93
+ # and sent to their chat partner. Please see our documentation on the
94
+ # feedback collecting for details on how to enable these updates for
95
+ # your bot.
96
+ def chosen_inline_result
97
+ inline_result = @update.chosen_inline_result
98
+ unless inline_result
99
+ return ChoseInlineResult.new(inline_result)
100
+ end
101
+
102
+ false
103
+ end
104
+
105
+ ##
106
+ # +Optional+. New incoming callback query. Returns CallBackQuery object
107
+ def callback_query
108
+ qury = @update.callback_query
109
+ unless qury.nil?
110
+ return CallBackQuery.new(qury)
111
+ end
112
+
113
+ false
114
+ end
115
+
116
+ ##
117
+ # +Optional.+ New incoming shipping query. Only for invoices with
118
+ # flexible price
119
+ def shipping_query
120
+ s_query = @udpate.shipping_query
121
+ unless s_query.nil?
122
+ return ShippingQuery.new(s_query)
123
+ end
124
+
125
+ false
126
+ end
127
+
128
+ ##
129
+ # +Optional+. New incoming pre-checkout query. Contains full
130
+ # information about checkout
131
+ def pre_checkout_query
132
+ p_c_query = @update.pre_checkout_query
133
+ unless p_C_query.nil?
134
+ return PreCheckoutQuery.new(p_c_query)
135
+ end
136
+
137
+ false
138
+ end
139
+
140
+ ##
141
+ # +Optional+. New poll state. Bots receive only updates about stopped
142
+ # polls and polls, which are sent by the bot.
143
+ def poll
144
+ pol = @udpate.poll
145
+ unless pol.nil?
146
+ return Poll.new(pol)
147
+ end
148
+
149
+ false
150
+ end
151
+
152
+ ##
153
+ # New poll state. Bots receive only updates about stopped polls and
154
+ # polls, which are sent by the bot.
155
+ def poll_answer
156
+ p_answer = @update.poll_answer
157
+ unless p_answer.nil?
158
+ return PollAnswer.new(p_answer)
159
+ end
160
+
161
+ false
162
+ end
163
+
164
+ def msg?
165
+ @update.message ? true : false
166
+ end
167
+
168
+ def channel_post?
169
+ @update.channel_post ? true : false
170
+ end
171
+
172
+ def edited_msg?
173
+ @update.edited_message ? true : false
174
+ end
175
+
176
+ def edited_channel_post?
177
+ @update.edited_channel_post ? true : false
178
+ end
179
+
180
+ def inline_query?
181
+ @update.inline_query ? true : false
182
+ end
183
+
184
+ def new_state_poll?
185
+ @update.poll ? true : false
186
+ end
187
+
188
+ def chosen_inline_result?
189
+ @update.chosen_inline_result ? true : false
190
+ end
191
+
192
+ def callback_query?
193
+ @update.callback_query ? true : false
194
+ end
195
+
196
+ def shipping_query?
197
+ @update.shipping_query ? true : false
198
+ end
199
+
200
+ def pre_checkout_query?
201
+ @update.pre_checkout_query ? true : false
202
+ end
203
+
204
+ def poll_answer?
205
+ @update.poll_answer ? true : false
206
+ end
207
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a Telegram user.
7
+ class User
8
+ def initialize(user) # :nodoc:
9
+ @user = user
10
+ end
11
+
12
+ # Unique identifier for this user or bot.
13
+ def id
14
+ @user.id
15
+ end
16
+
17
+ # True, if this user is a bot.
18
+ def bot?
19
+ @user.is_bot
20
+ end
21
+
22
+ # User's or bot's first name.
23
+ def first_name
24
+ @user.first_name
25
+ end
26
+
27
+ # +Optional.+ User 's or BotUser 's last name.
28
+ def last_name
29
+ @user.last_name
30
+ end
31
+
32
+ # +Optional+. User's or bot's username
33
+ def username
34
+ @user.username
35
+ end
36
+
37
+ # +Optional+.
38
+ # {IETF language}[https://en.wikipedia.org/wiki/IETF_language_tag]
39
+ # tag of the user's language.
40
+ def language_code
41
+ @user.language_code
42
+ end
43
+ end
44
+
45
+ # ===Class returned only in get_me method.
46
+ # This class extends from User class.
47
+ class BotUser < User
48
+ def initialize(bot) # :nodoc:
49
+ super(bot)
50
+ end
51
+
52
+ # +Optional.+ True, if the bot can be invited to groups.
53
+ def can_join_groups
54
+ @user.can_join_groups
55
+ end
56
+
57
+ # +Optional.+ True, if privacy mode is disabled for the bot.
58
+ def can_read_all_group_messages?
59
+ @user.can_read_all_group_messages
60
+ end
61
+
62
+ # +Optional.+ True, if the bot supports inline queries.
63
+ def supports_inline_queries?
64
+ @user.supports_inline_queries
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'photo_size'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+
8
+ # ==This object represent a user's profile pictures.
9
+ class UserProfilePhotos
10
+ def initialize(photo) # :nodoc:
11
+ @photo = photo
12
+ end
13
+
14
+ #
15
+ # Total number of profile pictures the target user has.
16
+ def total_count
17
+ @photo.total_count
18
+ end
19
+
20
+ ##
21
+ # Requested profile pictures (in up to 4 sizes each).
22
+ # Returns array of array of PhotoSize.
23
+ def photos
24
+ data = @photo.photos
25
+ photo_size = []
26
+ data.each do |e|
27
+ ary = []
28
+ e.each do |e_d|
29
+ ary << PhotoSize.new(e_d)
30
+ end
31
+ photo_size << ary
32
+ end
33
+
34
+ photo_size
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'location'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+ +EAT+
8
+ # ====This object represents a venue.
9
+ class Venue
10
+ def initialize(vn) # :nodoc:
11
+ @vn = vn
12
+ end
13
+
14
+ # Venue location. Returns Location Object.
15
+ def location
16
+ @vn.location
17
+ end
18
+
19
+ # Name of the venue.
20
+ def title
21
+ @vn.title
22
+ end
23
+
24
+ # Address of the venue.
25
+ def address
26
+ @vn.address
27
+ end
28
+
29
+ # +Optional+. Foursquare identifier of the venue
30
+ def foursquare_id
31
+ @vn.foursquare_id
32
+ end
33
+
34
+ # Optional. Foursquare type of the venue.
35
+ # (For example, +“arts_entertainment/default”+,
36
+ # +“arts_entertainment/aquarium”+ or +“food/icecream”.+)
37
+ def foursquare_type
38
+ @vn.foursquare_type
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'same/common_2'
5
+ require_relative 'photo_size'
6
+
7
+ ##
8
+ # ===This object represents a video file.
9
+ # Extends Common2 class.
10
+ class Video < Common2
11
+ def initialize(obj) # :nodoc:
12
+ super(obj)
13
+ end
14
+
15
+ # Video width as defined by sender.
16
+ def width
17
+ @obj.width
18
+ end
19
+
20
+ # Video height as defined by sender.
21
+ def heigth
22
+ @obj.heigth
23
+ end
24
+
25
+ # Duration of the video in seconds as defined by sender.
26
+ def duration
27
+ @obj.duration
28
+ end
29
+
30
+ # +Optional+. Video thumbnail.
31
+ def thumb
32
+ data = @obj.thumb
33
+ unless data
34
+ return PhotoSize.new(data)
35
+ end
36
+
37
+ false
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'photo_size'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+ +EAT+
8
+ # ===This object represents a video message
9
+ # (available in Telegram apps as of v.4.0).
10
+ class VideoNote
11
+ def initialize(obj) # :nodoc:
12
+ @note = obj
13
+ end
14
+
15
+ # Identifier for this file, which can be used to download or reuse the file.
16
+ def file_id
17
+ @note.file_id
18
+ end
19
+
20
+ # Unique identifier for this file, which is supposed to be the same over
21
+ # time and for different bots. Can't be used to download or reuse the file.
22
+ def file_unique_id
23
+ @note.file_unique_id
24
+ end
25
+
26
+ # Video width and height (diameter of the video message) as defined by sender.
27
+ def length
28
+ @note.length
29
+ end
30
+
31
+ # Duration of the video in seconds as defined by sender.
32
+ def duration
33
+ @note.duration
34
+ end
35
+
36
+ # +Optional+. File size
37
+ def file_size
38
+ @note.file_size
39
+ end
40
+
41
+ # +Optional+. Video thumbnail. Returns PhotoSize object.
42
+ def thumb
43
+ data = @note.thumb
44
+ unless data.nil?
45
+ return PhotoSize.new(data)
46
+ end
47
+
48
+ false
49
+ end
50
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'same/common_2'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+ +EAT+
8
+ # ===This object represents a voice note.
9
+ # Extends Common2 class.
10
+
11
+ class Voice < Common2
12
+ def initialize(obj) # :nodoc:
13
+ super(obj)
14
+ end
15
+
16
+ # Duration of the audio in seconds as defined by sender.
17
+ def duration
18
+ @obj.duration
19
+ end
20
+ end