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,42 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'location'
6
+
7
+ # This object represents an incoming inline query. When the user sends
8
+ # an empty query, your bot could return some default or trending results.
9
+ class InlineQuery
10
+ def initialize(query) # :nodoc:
11
+ @query = query
12
+ end
13
+
14
+ # Unique identifier for this query
15
+ def id
16
+ @query.id
17
+ end
18
+
19
+ # Sender.
20
+ # User object
21
+ def from
22
+ User.new(@query.from)
23
+ end
24
+
25
+ # +Optional+. Sender location, only for bots that request user location,
26
+ def location
27
+ lcation = @query.location
28
+ return Location.new(lcation) if lcation
29
+
30
+ false
31
+ end
32
+
33
+ # Text of the query (up to 256 characters)
34
+ def query
35
+ @query.query
36
+ end
37
+
38
+ # Offset of the results to be returned, can be controlled by the bot.
39
+ def offset
40
+ @query.offset
41
+ end
42
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # ===This object represents one button of an inline keyboard.
5
+ # You must use exactly one of the optional fields.
6
+ class InlineKeyboardButton
7
+ def initialize(button) # :nodoc:
8
+ @button = button
9
+ end
10
+
11
+ # Label text on the button.
12
+ def text
13
+ @button.text
14
+ end
15
+
16
+ # +Optional+. HTTP or tg:// url to be opened when button is pressed
17
+ def url
18
+ @button.url
19
+ end
20
+
21
+ # +Optional+. An HTTP URL used to automatically authorize the user.
22
+ # Can be used as a replacement for the Telegram
23
+ # {Login Widget.}[https://core.telegram.org/widgets/login]
24
+ def login_url
25
+ @button.login_url
26
+ end
27
+
28
+ # +Optional+. Data to be sent in a CallbackQuery to the bot when
29
+ # button is pressed, 1-64 bytes.
30
+ def callback_data
31
+ @button.callback_data
32
+ end
33
+
34
+ # +Optional+. If set, pressing the button will prompt the user to
35
+ # select one of their chats, open that chat and insert the bot's
36
+ # username and the specified inline query in the input field.
37
+ # Can be empty, in which case just the bot's username will be inserted.
38
+ def switch_inline_query
39
+ @button.switch_inline_query
40
+ end
41
+
42
+ # +Optional.+ If set, pressing the button will insert the bot's username
43
+ # and the specified inline query in the current chat's input field.
44
+ # Can be empty, in which case only the bot's username will be inserted.
45
+ def switch_inline_query_current_chat
46
+ @button.switch_inline_query_current_chat
47
+ end
48
+
49
+ # +Optional+. Description of the game that will be launched when the
50
+ # user presses the button.
51
+ def callback_game
52
+ @button.callback_game
53
+ end
54
+
55
+ # +Optional+. Specify True, to send a Pay button.
56
+ def pay?
57
+ @button.pay
58
+ end
59
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'inlinekeyboardbutton'
5
+
6
+ # This object represents an inline keyboard that appears
7
+ # right next to the message it belongs to.
8
+ class InlineKeyboardMarkup
9
+ def initialize(mup) # :nodoc:
10
+ @mup = mup
11
+ end
12
+
13
+ # Array of button rows, each represented by an Array of
14
+ # InlineKeyboardButton objects.
15
+ def inline_keyboard
16
+ data = @mup.inline_keyboard
17
+ if data.empty?
18
+ return false
19
+ end
20
+ ary = []
21
+ data.each do |e|
22
+ ary2 = []
23
+ e.each do |f|
24
+ ary2 << InlineKeyboardButton.new(f)
25
+ end
26
+ ary << ary2
27
+ end
28
+ ary
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a point on the map
7
+ class Location
8
+ def initialize(location) # :nodoc:
9
+ @loc = location
10
+ end
11
+
12
+ # Longitude as defined by sender.
13
+ def longitude
14
+ @loc.longitude
15
+ end
16
+
17
+ # Latitude as defined by sender.
18
+ def latitude
19
+ @loc.latitude
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This object describes the position on faces where a mask should be
5
+ # placed by default.
6
+ class MaskPosition
7
+ def initialize(pos) # :nodoc:
8
+ @pos = pos
9
+ end
10
+
11
+ # The part of the face relative to which the mask should be placed.
12
+ # One of “forehead”, “eyes”, “mouth”, or “chin”.
13
+ def point
14
+ @pos.point
15
+ end
16
+
17
+ # Shift by X-axis measured in widths of the mask scaled to the face size,
18
+ # from left to right. For example, choosing -1.0 will place mask just to
19
+ # the left of the default mask position.
20
+ def x_shift
21
+ @pos.x_shift
22
+ end
23
+
24
+ # Shift by Y-axis measured in heights of the mask scaled to the face size,
25
+ # from top to bottom. For example, 1.0 will place the mask just below the
26
+ # default mask position.
27
+ def y_shift
28
+ @pos.y_shift
29
+ end
30
+
31
+ # Mask scaling coefficient. For example, 2.0 means double size.
32
+ def scale
33
+ @pos.scale
34
+ end
35
+ end
@@ -0,0 +1,378 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'chat'
6
+ require_relative 'message_entity'
7
+ require_relative 'animation'
8
+ require_relative 'audio'
9
+ require_relative 'document'
10
+ require_relative 'photo_size'
11
+ require_relative 'sticker'
12
+ require_relative 'video'
13
+ require_relative 'contact'
14
+ require_relative 'dice'
15
+ require_relative 'venue'
16
+ require_relative 'game'
17
+ require_relative 'location'
18
+ require_relative 'inlinekeyboardmarkup'
19
+
20
+ ##
21
+ # +Monday+, +August+ +24+ +2020+ +EAT+
22
+ # ===This object represents a message.
23
+ class Message
24
+ def initialize(msg) # :nodoc:
25
+ @message = msg
26
+ end
27
+
28
+ # Unique message identifier inside the chat.
29
+ def message_id
30
+ @message.message_id
31
+ end
32
+
33
+ # +Optional.+ Sender, empty for messages sent to channels.
34
+ # Returns User object.
35
+ def from
36
+ frm = @message.from
37
+ return User.new(frm) if frm
38
+
39
+ false
40
+ end
41
+
42
+ # TDate Object the message was sent in Unix time
43
+ def date
44
+ return TDate.new(@message.date)
45
+ end
46
+
47
+ # Conversation the message belongs to.
48
+ # Returns Chat object
49
+ def chat
50
+ Chat.new(@message.chat)
51
+ end
52
+
53
+ # +Optional.+ For forwarded messages, sender of the original message.
54
+ # Returns Chat object
55
+ def forward_from
56
+ f_from = @message.forward_from
57
+ return User.new(f_from) if f_from
58
+
59
+ false
60
+ end
61
+
62
+ # +Optional.+ For messages forwarded from channels, information about
63
+ # the original channel.
64
+ # Returns Chat object.
65
+ def forward_from_chat
66
+ ff_chat = @message.forward_from_chat
67
+ return Chat.new(ff_chat) if ff_chat
68
+
69
+ false
70
+ end
71
+
72
+ # +Optional.+ For messages forwarded from channels, identifier of the
73
+ # original message in the channel.
74
+ def forward_from_message_id
75
+ @message.forward_from_message_id
76
+ end
77
+
78
+ # +Optional.+ For messages forwarded from channels, signature of the
79
+ # post author if present.
80
+ def forward_signature
81
+ @message.forward_signature
82
+ end
83
+
84
+ # +Optional+. Sender's name for messages forwarded from users who
85
+ # disallow adding a link to their account in forwarded messages.
86
+ def forward_sender_name
87
+ @message.forward_sender_name
88
+ end
89
+
90
+ # +Optional.+ For forwarded messages, date the original message was
91
+ # sent in Unix time.
92
+ # Returns TDate object.
93
+ def forward_date
94
+ TDate.new(@message.forward_date)
95
+ end
96
+
97
+ # +Optional.+ For replies, the original message. Note that the Message
98
+ # object in this field will not contain further #reply_to_message
99
+ # fields even if it itself is a reply.
100
+ # Returns Message object
101
+ def reply_to_message
102
+ r_t_msg = @message.reply_to_message
103
+ return Message.new(r_t_msg) if r_t_msg
104
+
105
+ false
106
+ end
107
+
108
+ # +Optional+. Bot through which the message was sent.
109
+ # Returns User object.
110
+ def via_bot
111
+ v_bot = @message.via_bot
112
+ return User.new(v_bot) if v_bot
113
+
114
+ false
115
+ end
116
+
117
+ # +Optional+. Retuns TDate object.
118
+ def edit_date
119
+ TDate.new(@messag.edit_date)
120
+ end
121
+
122
+ # +Optional+. The unique identifier of a media message group this
123
+ # message belongs to.
124
+ def media_group_id
125
+ @message.media_group_id
126
+ end
127
+
128
+ # +Optional.+ Signature of the post author for messages in channels.
129
+ def author_signature
130
+ @message.author_signature
131
+ end
132
+
133
+ # +Optional+. For text messages, the actual UTF-8 text of the message,
134
+ # 0-4096 characters
135
+ def text
136
+ @message.text
137
+ end
138
+
139
+ # +Optional.+ For text messages, special entities like usernames,
140
+ # URLs, bot commands, etc. that appear in the text.
141
+ # Returns array of MessageEntity object
142
+ def entities
143
+ ary_entity = []
144
+ entitys = @message.entities
145
+ if entitys.empty?
146
+ return false
147
+ end
148
+
149
+ entitys.each do |ent|
150
+ ary_entity << MessageEntity.new(ent)
151
+ end
152
+ ary_entity
153
+ end
154
+
155
+ # +Optional.+ Message is an animation, information about the animation.
156
+ # For backward compatibility, when this field is set, the document
157
+ # field will also be set.
158
+ # Returns Animation object
159
+ def animation
160
+ an = @message.animation
161
+ return Animation.new(an) if an
162
+
163
+ false
164
+ end
165
+
166
+ # +Optional+. message is an Audio file, information about the file.
167
+ def audio
168
+ ad = @message.audio
169
+ return Audio.new(ad) if ad
170
+
171
+ false
172
+ end
173
+
174
+ # +Optional+. message is a general file, information about the file.
175
+ # Returns Document object.
176
+ def document
177
+ doc = @message.document
178
+ return Document.new(doc) if doc
179
+
180
+ false
181
+ end
182
+
183
+ # +Optional+. message is a Photo, available sizes of the photo.
184
+ # returns array of PhotoSize object
185
+ def photo
186
+ poto = @message.photo
187
+ if poto.empty?
188
+ return false
189
+ end
190
+
191
+ e_photo = []
192
+ poto.each do
193
+ e_photo << PhotoSize.new(e_photo)
194
+ end
195
+ e_photo
196
+ end
197
+
198
+ # +Optional.+ Message is a sticker, information about the sticker
199
+ # returns Sticker object
200
+ def sticker
201
+ stiker = @message.sticker
202
+ return Sticker.new(stiker) if stiker
203
+
204
+ false
205
+ end
206
+
207
+ # +Optional.+ Message is a Video, information about the video.
208
+ def video
209
+ vd = @message.video
210
+ return Video.new(vd) if vd
211
+
212
+ false
213
+ end
214
+
215
+ # +Optional.+ Message is a VideoNote, information about the video message.
216
+ def video_note
217
+ vnot = @message.video_note
218
+ return VideoNote.new(vnot) if vnot
219
+
220
+ false
221
+ end
222
+
223
+ # +Optional+. message is a Voice message, information about the file.
224
+ def voice
225
+ vc = @message.voice
226
+ return Voice.new(vc) if vc
227
+
228
+ false
229
+ end
230
+
231
+ # +Optional+. Caption for the animation, audio, document, photo, video
232
+ # or voice, 0-1024 characters.
233
+ def caption
234
+ @message.caption
235
+ end
236
+
237
+ # +Optional.+ For messages with a caption, special entities like
238
+ # usernames, URLs, bot commands, etc. that appear in the caption.
239
+ def caption_entities
240
+ c_entitys = @message.caption_entities
241
+ if c_entitys.empty?
242
+ return false
243
+ end
244
+
245
+ ary_ent = []
246
+ c_entitys.each do |ent|
247
+ ary_ent << MessageEntity.new(ent)
248
+ end
249
+ ary_ent
250
+ end
251
+
252
+ # +Optional+. Message is a shared contact, information about the contact.
253
+ def contact
254
+ kontakt = @message.contact
255
+ return Contact.new(kontakt) if kontakt
256
+
257
+ false
258
+ end
259
+
260
+ # +Optional+. Message is a Dice with random value from 1 to 6.
261
+ def dice
262
+ dis = @message.dice
263
+ return Dice.new(dis) if dis
264
+
265
+ false
266
+ end
267
+
268
+ # +Optional+. Message is a Game, information about the game.
269
+ def game
270
+ gam = @message.game
271
+ return Game.new(gam) if gam
272
+
273
+ false
274
+ end
275
+
276
+ def text_msg?
277
+ text ? true : false
278
+ end
279
+
280
+ # returns true if the update is for replied msg
281
+ def reply_msg?
282
+ @message.reply_to_message ? true : false
283
+ end
284
+
285
+ def video_msg?
286
+ @message.video ? true : false
287
+ end
288
+
289
+ def audio_msg?
290
+ @message.audio ? true : false
291
+ end
292
+
293
+ def document_msg?
294
+ @message.document ? true : false
295
+ end
296
+
297
+ def contact_msg?
298
+ @message.contact ? true : false
299
+ end
300
+
301
+ def forward_msg?
302
+ (@update.forward_from) or (@update.forward_from_chat) ? true : false
303
+ end
304
+
305
+ def animation_msg?
306
+ @message.animation ? true : false
307
+ end
308
+
309
+ def photo_msg?
310
+ @message.photo.empty? ? false : true
311
+ end
312
+
313
+ def voice_msg?
314
+ @message.voice ? true : false
315
+ end
316
+
317
+ def video_note_msg?
318
+ @message.video_note ? true : false
319
+ end
320
+
321
+ def sticker_msg?
322
+ @message.sticker ? true : false
323
+ end
324
+
325
+ def game_msg?
326
+ @message.game ? true : false
327
+ end
328
+
329
+ def poll_msg?
330
+ @message.poll ? true : false
331
+ end
332
+
333
+ def venue_msg?
334
+ @message.venue ? true : false
335
+ end
336
+
337
+ def location_msg?
338
+ @message.location ? true : false
339
+ end
340
+
341
+ def new_chat_member?
342
+ @message.new_chat_member ? true : false
343
+ end
344
+
345
+ def left_chat_member?
346
+ @message.left_chat_member ? true : false
347
+ end
348
+
349
+ def new_chat_title?
350
+ @message.new_chat_title ? true : false
351
+ end
352
+
353
+ def new_chat_photo?
354
+ @message.new_chat_photo ? true : false
355
+ end
356
+
357
+ def pinned_msg?
358
+ @message.pinned_message ? true : false
359
+ end
360
+
361
+ def delete_chat_photo?
362
+ @message.delete_chat_photo ? true : false
363
+ end
364
+
365
+ def reply_markup?
366
+ @message.reply_markup ? true : false
367
+ end
368
+
369
+ def forward_from_chat?
370
+ @message.forward_from_chat ? true : false
371
+ end
372
+
373
+ def has_entities?
374
+ @message.entities.empty? ? false : true
375
+ end
376
+ end
377
+
378
+ # ughhhhh God!