telbe 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/telbe/media.rb CHANGED
@@ -1,48 +1,355 @@
1
1
  module Telbe
2
+ class Bot
3
+ def get_url(file)
4
+ "https://api.telegram.org/file/bot#{@token}/#{file.file_path}"
5
+ end
6
+
7
+ def send_photo(send_photo_descriptor)
8
+ Message.new(request(:sendPhoto, send_photo_descriptor))
9
+ end
10
+
11
+ def send_audio(send_audio_descriptor)
12
+ Message.new(request(:sendAudio, send_audio_descriptor))
13
+ end
14
+
15
+ def send_document(send_document_descriptor)
16
+ Message.new(request(:sendDocument, send_document_descriptor))
17
+ end
18
+
19
+ def send_video(send_video_descriptor)
20
+ Message.new(request(:sendVideo, send_video_descriptor))
21
+ end
22
+
23
+ def send_animation(send_animation_descriptor)
24
+ Message.new(request(:sendAnimation, send_animation_descriptor))
25
+ end
26
+
27
+ def send_voice(send_voice_descriptor)
28
+ Message.new(request(:sendVoice, send_voice_descriptor))
29
+ end
30
+
31
+ def send_video_note(send_video_note_descriptor)
32
+ Message.new(request(:sendVideoNote, send_video_note_descriptor))
33
+ end
34
+
35
+ def send_media_group(send_media_group_descriptor)
36
+ request(:sendMediaGroup, send_media_group_descriptor).collect do |m|
37
+ Message.new(m)
38
+ end
39
+ end
40
+ end
41
+
42
+ # file_id String Unique identifier for this file
43
+ # file_size Integer Optional. File size, if known
44
+ # file_path String Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
45
+ class File
46
+ include SimplifyApi
47
+ attribute :file_id, String, mandatory: true
48
+ attribute :file_size, Integer
49
+ attribute :file_path, String
50
+ end
51
+
52
+ # file_id String Yes File identifier to get info about
53
+ class GetFileDescriptor
54
+ include SimplifyApi
55
+ attribute :file_id, String, mandatory: true
56
+ end
57
+
58
+ class InputFile
59
+ include SimplifyApi
60
+ end
61
+
62
+ # file_id String Unique identifier for this file
63
+ # width Integer Photo width
64
+ # height Integer Photo height
65
+ # file_size Integer Optional. File size
2
66
  class PhotoSize
3
- include InitializeFromHash
67
+ include SimplifyApi
68
+ attribute :file_id, String, mandatory: true
69
+ attribute :width, Integer, mandatory: true
70
+ attribute :height, Integer, mandatory: true
71
+ attribute :file_size, Integer
4
72
  end
5
73
 
74
+ # file_id String Unique file identifier
75
+ # width Integer Video width as defined by sender
76
+ # height Integer Video height as defined by sender
77
+ # duration Integer Duration of the video in seconds as defined by sender
78
+ # thumb PhotoSize Optional. Animation thumbnail as defined by sender
79
+ # file_name String Optional. Original animation filename as defined by sender
80
+ # mime_type String Optional. MIME type of the file as defined by sender
81
+ # file_size Integer Optional. File size
6
82
  class Animation
7
- include InitializeFromHash
83
+ include SimplifyApi
84
+ attribute :file_id, String, mandatory: true
85
+ attribute :width, Integer, mandatory: true
86
+ attribute :height, Integer, mandatory: true
87
+ attribute :duration, Integer, mandatory: true
88
+ attribute :thumb, PhotoSize
89
+ attribute :file_name, String
90
+ attribute :mime_type, String
91
+ attribute :file_size, Integer
8
92
  end
9
93
 
94
+ # file_id String Unique file identifier
95
+ # thumb PhotoSize Optional. Document thumbnail as defined by sender
96
+ # file_name String Optional. Original filename as defined by sender
97
+ # mime_type String Optional. MIME type of the file as defined by sender
98
+ # file_size Integer Optional. File size
10
99
  class Document
11
- include InitializeFromHash
100
+ include SimplifyApi
101
+ attribute :file_id, String, mandatory: true
102
+ attribute :thumb, PhotoSize
103
+ attribute :file_name, String
104
+ attribute :mime_type, String
105
+ attribute :file_size, Integer
12
106
  end
13
107
 
108
+ # file_id String Unique identifier for this file
109
+ # duration Integer Duration of the audio in seconds as defined by sender
110
+ # performer String Optional. Performer of the audio as defined by sender or by audio tags
111
+ # title String Optional. Title of the audio as defined by sender or by audio tags
112
+ # mime_type String Optional. MIME type of the file as defined by sender
113
+ # file_size Integer Optional. File size
114
+ # thumb PhotoSize Optional. Thumbnail of the album cover to which the music file belongs
14
115
  class Audio
15
- include InitializeFromHash
116
+ include SimplifyApi
117
+ attribute :file_id, String, mandatory: true
118
+ attribute :duration, Integer, mandatory: true
119
+ attribute :performer, String
120
+ attribute :title, String
121
+ attribute :mime_type, String
122
+ attribute :file_size, Integer
123
+ attribute :thumb, PhotoSize
16
124
  end
17
125
 
126
+ # file_id String Unique identifier for this file
127
+ # width Integer Video width as defined by sender
128
+ # height Integer Video height as defined by sender
129
+ # duration Integer Duration of the video in seconds as defined by sender
130
+ # thumb PhotoSize Optional. Video thumbnail
131
+ # mime_type String Optional. Mime type of a file as defined by sender
132
+ # file_size Integer Optional. File size
18
133
  class Video
19
- include InitializeFromHash
134
+ include SimplifyApi
135
+ attribute :file_id, String, mandatory: true
136
+ attribute :width, Integer, mandatory: true
137
+ attribute :height, Integer, mandatory: true
138
+ attribute :duration, Integer, mandatory: true
139
+ attribute :thumb, PhotoSize
140
+ attribute :mime_type, String
141
+ attribute :file_size, Integer
20
142
  end
21
143
 
144
+ # file_id String Unique identifier for this file
145
+ # duration Integer Duration of the audio in seconds as defined by sender
146
+ # mime_type String Optional. MIME type of the file as defined by sender
147
+ # file_size Integer Optional. File size
22
148
  class Voice
23
- include InitializeFromHash
149
+ include SimplifyApi
150
+ attribute :file_id, String, mandatory: true
151
+ attribute :duration, Integer, mandatory: true
152
+ attribute :mime_type, String
153
+ attribute :file_size, Integer
24
154
  end
25
155
 
156
+ # file_id String Unique identifier for this file
157
+ # length Integer Video width and height (diameter of the video message) as defined by sender
158
+ # duration Integer Duration of the video in seconds as defined by sender
159
+ # thumb PhotoSize Optional. Video thumbnail
160
+ # file_size Integer Optional. File size
26
161
  class VideoNote
27
- include InitializeFromHash
162
+ include SimplifyApi
163
+ attribute :file_id, String, mandatory: true
164
+ attribute :length, Integer, mandatory: true
165
+ attribute :duration, Integer, mandatory: true
166
+ attribute :thumb, PhotoSize
167
+ attribute :file_size, Integer
28
168
  end
29
169
 
30
- class InputMedia
31
- include InitializeFromHash
32
- end
33
-
170
+ # type String Type of the result, must be animation
171
+ # media String File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
172
+ # thumb InputFile or String Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
173
+ # caption String Optional. Caption of the animation to be sent, 0-1024 characters
174
+ # parse_mode String Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
175
+ # width Integer Optional. Animation width
176
+ # height Integer Optional. Animation height
177
+ # duration Integer Optional. Animation duration
34
178
  class InputMediaAnimation < InputMedia
179
+ attribute :thumb, Object
180
+ attribute :width, Integer
181
+ attribute :height, Integer
182
+ attribute :duration, Integer
35
183
  end
36
184
 
185
+ # type String Type of the result, must be document
186
+ # media String File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
187
+ # thumb InputFile or String Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
188
+ # caption String Optional. Caption of the document to be sent, 0-1024 characters
189
+ # parse_mode String Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
37
190
  class InputMediaDocument < InputMedia
191
+ attribute :thumb, Object
38
192
  end
39
193
 
194
+ # type String Type of the result, must be audio
195
+ # media String File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
196
+ # thumb InputFile or String Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
197
+ # caption String Optional. Caption of the audio to be sent, 0-1024 characters
198
+ # parse_mode String Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
199
+ # duration Integer Optional. Duration of the audio in seconds
200
+ # performer String Optional. Performer of the audio
201
+ # title String Optional. Title of the audio
40
202
  class InputMediaAudio < InputMedia
203
+ attribute :thumb, Object
204
+ attribute :duration, Integer
205
+ attribute :performer, String
206
+ attribute :title, String
41
207
  end
42
208
 
209
+ # type String Type of the result, must be photo
210
+ # media String File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
211
+ # caption String Optional. Caption of the photo to be sent, 0-1024 characters
212
+ # parse_mode String Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
43
213
  class InputMediaPhoto < InputMedia
44
214
  end
45
215
 
216
+ # type String Type of the result, must be video
217
+ # media String File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
218
+ # thumb InputFile or String Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
219
+ # caption String Optional. Caption of the video to be sent, 0-1024 characters
220
+ # parse_mode String Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
221
+ # width Integer Optional. Video width
222
+ # height Integer Optional. Video height
223
+ # duration Integer Optional. Video duration
224
+ # supports_streaming Boolean Optional. Pass True, if the uploaded video is suitable for streaming
46
225
  class InputMediaVideo < InputMedia
226
+ attribute :thumb, Object
227
+ attribute :width, Integer
228
+ attribute :height, Integer
229
+ attribute :duration, Integer
230
+ attribute :supports_streaming, values: [true, false]
231
+ end
232
+
233
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
234
+ # photo InputFile or String Yes Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. More info on Sending Files »
235
+ # caption String Optional Photo caption (may also be used when resending photos by file_id), 0-1024 characters
236
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
237
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
238
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
239
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
240
+ class SendPhotoDescriptor < MediaDescriptor
241
+ attribute :photo, Object, mandatory: true
242
+ end
243
+
244
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
245
+ # audio InputFile or String Yes Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
246
+ # caption String Optional Audio caption, 0-1024 characters
247
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
248
+ # duration Integer Optional Duration of the audio in seconds
249
+ # performer String Optional Performer
250
+ # title String Optional Track name
251
+ # thumb InputFile or String Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
252
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
253
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
254
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
255
+ class SendAudioDescriptor < MediaDescriptor
256
+ attribute :audio, Object, mandatory: true
257
+ attribute :duration, Integer
258
+ attribute :performer, String
259
+ attribute :title, String
260
+ attribute :thumb, Object
261
+ end
262
+
263
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
264
+ # document InputFile or String Yes File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
265
+ # thumb InputFile or String Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
266
+ # caption String Optional Document caption (may also be used when resending documents by file_id), 0-1024 characters
267
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
268
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
269
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
270
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
271
+ class SendDocumentDescriptor < MediaDescriptor
272
+ attribute :document, Object, mandatory: true
273
+ attribute :thumb, Object
274
+ end
275
+
276
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
277
+ # video InputFile or String Yes Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More info on Sending Files »
278
+ # duration Integer Optional Duration of sent video in seconds
279
+ # width Integer Optional Video width
280
+ # height Integer Optional Video height
281
+ # thumb InputFile or String Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
282
+ # caption String Optional Video caption (may also be used when resending videos by file_id), 0-1024 characters
283
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
284
+ # supports_streaming Boolean Optional Pass True, if the uploaded video is suitable for streaming
285
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
286
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
287
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Opt
288
+ class SendVideoDescriptor < MediaDescriptor
289
+ attribute :video, Object, mandatory: true
290
+ attribute :duration, Integer
291
+ attribute :width, Integer
292
+ attribute :height, Integer
293
+ attribute :thumb, Object
294
+ attribute :supports_streaming, values: [true, false]
295
+ end
296
+
297
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
298
+ # animation InputFile or String Yes Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More info on Sending Files »
299
+ # duration Integer Optional Duration of sent animation in seconds
300
+ # width Integer Optional Animation width
301
+ # height Integer Optional Animation height
302
+ # thumb InputFile or String Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
303
+ # caption String Optional Animation caption (may also be used when resending animation by file_id), 0-1024 characters
304
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
305
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
306
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
307
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
308
+ class SendAnimationDescriptor < MediaDescriptor
309
+ attribute :animation, Object, mandatory: true
310
+ attribute :duration, Integer
311
+ attribute :width, Integer
312
+ attribute :height, Integer
313
+ attribute :thumb, Object
314
+ end
315
+
316
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
317
+ # voice InputFile or String Yes Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
318
+ # caption String Optional Voice message caption, 0-1024 characters
319
+ # parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
320
+ # duration Integer Optional Duration of the voice message in seconds
321
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
322
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
323
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
324
+ class SendVoiceDescriptor < MediaDescriptor
325
+ attribute :voice, Object, mandatory: true
326
+ attribute :duration, Integer
327
+ end
328
+
329
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
330
+ # video_note InputFile or String Yes Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More info on Sending Files ». Sending video notes by a URL is currently unsupported
331
+ # duration Integer Optional Duration of sent video in seconds
332
+ # length Integer Optional Video width and height, i.e. diameter of the video message
333
+ # thumb InputFile or String Optional Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
334
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
335
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
336
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
337
+ class SendVideoNoteDescriptor < Descriptor
338
+ attribute :video_note, InputFile or String
339
+ attribute :duration, Integer
340
+ attribute :length, Integer
341
+ attribute :thumb, InputFile or String
342
+ end
343
+
344
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
345
+ # media Array of InputMediaPhoto and InputMediaVideo Yes A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
346
+ # disable_notification Boolean Optional Sends the messages silently. Users will receive a notification with no sound.
347
+ # reply_to_message_id Integer Optional If the messages are a reply, ID of the original message
348
+ class SendMediaGroupDescriptor
349
+ include SimplifyApi
350
+ attribute :chat_id, Integer or String
351
+ attribute :media, [Object]
352
+ attribute :disable_notification, values: [true, false]
353
+ attribute :reply_to_message_id, Integer
47
354
  end
48
355
  end
data/lib/telbe/poll.rb CHANGED
@@ -12,24 +12,32 @@ module Telbe
12
12
  # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
13
13
  # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
14
14
  class PollDescriptor
15
- include InitializeFromHash
16
- def self.factory
17
- self.new(
18
- chat_id: nil,
19
- question: nil,
20
- options: [],
21
- disable_notification: false,
22
- reply_to_message_id: nil,
23
- reply_markup: nil
24
- )
25
- end
15
+ include SimplifyApi
16
+ attribute :chat_id, Object, mandatory: true # Integer or String
17
+ attribute :question, String, mandatory: true
18
+ attribute :options, [String], mandatory: true # 2-10 strings 1-100 characters each
19
+ attribute :disable_notification, values: [true, false]
20
+ attribute :reply_to_message_id, Integer
21
+ attribute :reply_markup, Object
26
22
  end
27
23
 
24
+ # text String Option text, 1-100 characters
25
+ # voter_count Integer Number of users that voted for this option
28
26
  class PollOption
29
- include InitializeFromHash
27
+ include SimplifyApi
28
+ attribute :text, String, mandatory: true
29
+ attribute :voter_count, Integer, mandatory: true
30
30
  end
31
31
 
32
+ # id String Unique poll identifier
33
+ # question String Poll question, 1-255 characters
34
+ # options Array of PollOption List of poll options
35
+ # is_closed Boolean True, if the poll is closed
32
36
  class Poll
33
- include InitializeFromHash
37
+ include SimplifyApi
38
+ attribute :id, String, mandatory: true
39
+ attribute :question, String, mandatory: true
40
+ attribute :options, [PollOption]
41
+ attribute :is_closed, values: [true, false]
34
42
  end
35
43
  end
data/lib/telbe/sticker.rb CHANGED
@@ -1,16 +1,149 @@
1
1
  module Telbe
2
2
  class Bot
3
+ def send_sticker(send_sticker_descriptor)
4
+ Message.new(request(:sendSticker, send_sticker_descriptor))
5
+ end
6
+
7
+ def get_sticker_set(get_sticker_set_descriptor)
8
+ StickerSet.new(request(:getStickerSet, get_sticker_set_descriptor))
9
+ end
10
+
11
+ def upload_sticker_file(upload_sticker_file_descriptor)
12
+ File.new(request(:uploadStickerFile, upload_sticker_file_descriptor))
13
+ end
14
+
15
+ def create_new_sticker_set(create_new_sticker_set_descriptor)
16
+ request(:createNewStickerSet, create_new_sticker_set_descriptor)
17
+ end
18
+
19
+ def add_sticker_to_set(add_sticker_to_set_descriptor)
20
+ request(:addStickerToSet, add_sticker_to_set_descriptor)
21
+ end
22
+
23
+ def set_sticker_position_in_set(set_sticker_position_in_set_descriptor)
24
+ request(:setStickerPositionInSet, set_sticker_position_in_set_descriptor)
25
+ end
26
+
27
+ def delete_sticker_from_set(delete_sticker_from_set_descriptor)
28
+ request(:deleteStickerFromSet, delete_sticker_from_set_descriptor)
29
+ end
3
30
  end
4
31
 
32
+ # point String The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”.
33
+ # x_shift Float number Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.
34
+ # y_shift Float number Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.
35
+ # scale Float number Mask scaling coefficient. For example, 2.0 means double size.
5
36
  class MaskPosition
6
- include InitializeFromHash
37
+ include SimplifyApi
38
+ attribute :point, String, mandatory: true, values: ["forehead", "eyes", "mouth", "chin"]
39
+ attribute :x_shift, Float, mandatory: true
40
+ attribute :y_shift, Float, mandatory: true
41
+ attribute :scale, Float, mandatory: true
7
42
  end
8
43
 
44
+ # file_id String Unique identifier for this file
45
+ # width Integer Sticker width
46
+ # height Integer Sticker height
47
+ # thumb PhotoSize Optional. Sticker thumbnail in the .webp or .jpg format
48
+ # emoji String Optional. Emoji associated with the sticker
49
+ # set_name String Optional. Name of the sticker set to which the sticker belongs
50
+ # mask_position MaskPosition Optional. For mask stickers, the position where the mask should be placed
51
+ # file_size Integer Optional. File size
9
52
  class Sticker
10
- include InitializeFromHash
53
+ include SimplifyApi
54
+ attribute :file_id, String, mandatory: true
55
+ attribute :width, Integer, mandatory: true
56
+ attribute :height, Integer, mandatory: true
57
+ attribute :thumb, PhotoSize
58
+ attribute :emoji, String
59
+ attribute :set_name, String
60
+ attribute :mask_position, MaskPosition
61
+ attribute :file_size, Integer
11
62
  end
12
63
 
64
+ # name String Sticker set name
65
+ # title String Sticker set title
66
+ # contains_masks Boolean True, if the sticker set contains masks
67
+ # stickers Array of Sticker List of all set stickers
13
68
  class StickerSet
14
- include InitializeFromHash
69
+ include SimplifyApi
70
+ attribute :name, String, mandatory: true
71
+ attribute :title, String, mandatory: true
72
+ attribute :contains_masks, values: [true, false]
73
+ attribute :stickers, [Sticker]
74
+ end
75
+
76
+ # chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
77
+ # sticker InputFile or String Yes Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
78
+ # disable_notification Boolean Optional Sends the message silently. Users will receive a notification with no sound.
79
+ # reply_to_message_id Integer Optional If the message is a reply, ID of the original message
80
+ # reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
81
+ class SendStickerDescriptor
82
+ include SimplifyApi
83
+ attribute :chat_id, Object, mandatory: true
84
+ attribute :sticker, Object, mandatory: true
85
+ attribute :disable_notification, values: [true, false]
86
+ attribute :reply_to_message_id, Integer
87
+ attribute :reply_markup, Object
88
+ end
89
+
90
+ # name String Yes Name of the sticker set
91
+ class GetStickerSetDescriptor
92
+ include SimplifyApi
93
+ attribute :name, Sticker, mandatory: true
94
+ end
95
+
96
+ # user_id Integer Yes User identifier of sticker file owner
97
+ # png_sticker InputFile Yes Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
98
+ class UploadStickerFileDescriptor
99
+ include SimplifyApi
100
+ attribute :user_id, Integer, mandatory: true
101
+ attribute :png_sticker, InputFile, mandatory: true
102
+ end
103
+
104
+ # user_id Integer Yes User identifier of created sticker set owner
105
+ # name String Yes Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
106
+ # title String Yes Sticker set title, 1-64 characters
107
+ # png_sticker InputFile or String Yes Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
108
+ # emojis String Yes One or more emoji corresponding to the sticker
109
+ # contains_masks Boolean Optional Pass True, if a set of mask stickers should be created
110
+ # mask_position MaskPosition Optional A JSON-serialized object for position where the mask should be placed on faces
111
+ class CreateNewStickerSetDescriptor
112
+ include SimplifyApi
113
+ attribute :user_id, Integer, mandatory: true
114
+ attribute :name, String, mandatory: true
115
+ attribute :title, String, mandatory: true
116
+ attribute :png_sticker, Object
117
+ attribute :emojis, String, mandatory: true
118
+ attribute :contains_masks, values: [true, false]
119
+ attribute :mask_position, MaskPosition
120
+ end
121
+
122
+ # user_id Integer Yes User identifier of sticker set owner
123
+ # name String Yes Sticker set name
124
+ # png_sticker InputFile or String Yes Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
125
+ # emojis String Yes One or more emoji corresponding to the sticker
126
+ # mask_position MaskPosition Optional A JSON-serialized object for position where the mask should be placed on faces
127
+ class AddStickerToSetDescriptor
128
+ include SimplifyApi
129
+ attribute :user_id, Integer, mandatory: true
130
+ attribute :name, String, mandatory: true
131
+ attribute :png_sticker, Object, mandatory: true
132
+ attribute :emojis, String, mandatory: true
133
+ attribute :mask_position, MaskPosition
134
+ end
135
+
136
+ # sticker String Yes File identifier of the sticker
137
+ # position Integer Yes New sticker position in the set, zero-based
138
+ class SetStickerPositionInSetDescriptor
139
+ include SimplifyApi
140
+ attribute :sticker, String, mandatory: true
141
+ attribute :position, Integer, mandatory: true
142
+ end
143
+
144
+ # sticker String Yes File identifier of the sticker
145
+ class DeleteStickerFromSetDescriptor
146
+ include SimplifyApi
147
+ attribute :sticker, String, mandatory: true
15
148
  end
16
149
  end