telegrammer 0.3.1 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/lib/telegrammer.rb +24 -24
- data/lib/telegrammer/api_response.rb +4 -4
- data/lib/telegrammer/bot.rb +67 -26
- data/lib/telegrammer/data_types/audio.rb +6 -2
- data/lib/telegrammer/data_types/contact.rb +2 -2
- data/lib/telegrammer/data_types/message.rb +3 -0
- data/lib/telegrammer/data_types/video.rb +0 -2
- data/lib/telegrammer/data_types/voice.rb +18 -0
- data/lib/telegrammer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5bd45c16547dca85e93537a1b095c9d8d7f3d6f
|
4
|
+
data.tar.gz: 897030c54eb66cf9cb0d319aa00a3e48ea074130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9748b37b0edd3420cfc0af683665d38768378136612a260c9569fb4fe4094211cc14b8cfdf0f66ee03b04fa359b88be1ba46cc18e65597a4ee6ecdfcc131336c
|
7
|
+
data.tar.gz: 0237500a40e25bd1d02dd93d18f5d2292f843cbdf2b7bbdec04b104dbe01163d8fc7ddc64e0a0298dafcee88ef318ddeeaa05aa8d36c000cdc08066fc7c72292
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[](http://badge.fury.io/rb/telegrammer)
|
2
2
|
[](https://codeclimate.com/github/mayoral/telegrammer)
|
3
3
|
[](http://inch-ci.org/github/mayoral/telegrammer)
|
4
|
+
[](https://gitter.im/mayoral/telegrammer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
5
|
|
5
6
|
# Telegrammer
|
6
7
|
|
data/lib/telegrammer.rb
CHANGED
@@ -2,29 +2,29 @@ require 'httpclient'
|
|
2
2
|
require 'virtus'
|
3
3
|
require 'multi_json'
|
4
4
|
|
5
|
-
require
|
6
|
-
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
|
26
|
-
require
|
27
|
-
require
|
5
|
+
require 'telegrammer/version'
|
6
|
+
|
7
|
+
require 'telegrammer/data_types/base'
|
8
|
+
require 'telegrammer/data_types/audio'
|
9
|
+
require 'telegrammer/data_types/channel'
|
10
|
+
require 'telegrammer/data_types/contact'
|
11
|
+
require 'telegrammer/data_types/photo_size'
|
12
|
+
require 'telegrammer/data_types/user'
|
13
|
+
require 'telegrammer/data_types/sticker'
|
14
|
+
require 'telegrammer/data_types/video'
|
15
|
+
|
16
|
+
require 'telegrammer/data_types/document'
|
17
|
+
require 'telegrammer/data_types/force_reply'
|
18
|
+
require 'telegrammer/data_types/group_chat'
|
19
|
+
require 'telegrammer/data_types/location'
|
20
|
+
require 'telegrammer/data_types/message'
|
21
|
+
require 'telegrammer/data_types/reply_keyboard_hide'
|
22
|
+
require 'telegrammer/data_types/reply_keyboard_markup'
|
23
|
+
require 'telegrammer/data_types/update'
|
24
|
+
require 'telegrammer/data_types/user_profile_photos'
|
25
|
+
|
26
|
+
require 'telegrammer/bot'
|
27
|
+
require 'telegrammer/api_response'
|
28
28
|
|
29
29
|
module Telegrammer
|
30
30
|
module Errors
|
@@ -38,7 +38,7 @@ module Telegrammer
|
|
38
38
|
# Error returned when a param type is invalid
|
39
39
|
class InvalidParamTypeError < StandardError
|
40
40
|
def initialize(parameter, current_type, allowed_types)
|
41
|
-
super("Invalid parameter type: #{parameter}: #{current_type}. Allowed types: #{allowed_types.each {|type| type.class.to_s }.join(
|
41
|
+
super("Invalid parameter type: #{parameter}: #{current_type}. Allowed types: #{allowed_types.each { |type| type.class.to_s }.join(',')}.")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -9,15 +9,15 @@ module Telegrammer
|
|
9
9
|
@body = response.body
|
10
10
|
|
11
11
|
data = MultiJson.load(@body)
|
12
|
-
@success = data[
|
12
|
+
@success = data['ok']
|
13
13
|
|
14
14
|
if @success
|
15
|
-
@result = data[
|
15
|
+
@result = data['result']
|
16
16
|
else
|
17
|
-
|
17
|
+
fail Telegrammer::Errors::BadRequestError, data['error_code'], data['description']
|
18
18
|
end
|
19
19
|
else
|
20
|
-
|
20
|
+
fail Telegrammer::Errors::ServiceUnavailableError, response.status
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
data/lib/telegrammer/bot.rb
CHANGED
@@ -38,9 +38,9 @@ module Telegrammer
|
|
38
38
|
#
|
39
39
|
# @raise [Telegrammer::Errors::BadRequestError] if something goes wrong in the Telegram API servers with the params received by the operation
|
40
40
|
# @raise [Telegrammer::Errors::ServiceUnavailableError] if Telegram servers are down
|
41
|
-
def get_updates(&
|
41
|
+
def get_updates(&_block)
|
42
42
|
loop do
|
43
|
-
response = api_request(
|
43
|
+
response = api_request('getUpdates', { offset: @offset, timeout: @timeout }, nil)
|
44
44
|
|
45
45
|
response.result.each do |raw_update|
|
46
46
|
update = Telegrammer::DataTypes::Update.new(raw_update)
|
@@ -69,7 +69,7 @@ module Telegrammer
|
|
69
69
|
# @see https://github.com/mayoral/telegrammer/wiki/Using-webhooks
|
70
70
|
# @return [Telegrammer::ApiResponse] Response from the API.
|
71
71
|
def set_webhook(url)
|
72
|
-
api_request(
|
72
|
+
api_request('setWebhook', { url: url }, nil)
|
73
73
|
end
|
74
74
|
|
75
75
|
# Returns basic information about the bot in form of a User object. Used for testing your bot's auth token.
|
@@ -83,7 +83,7 @@ module Telegrammer
|
|
83
83
|
#
|
84
84
|
# @return [Telegrammer::DataTypes::User] User object with info about the bot
|
85
85
|
def get_me
|
86
|
-
response = api_request(
|
86
|
+
response = api_request('getMe', nil, nil)
|
87
87
|
|
88
88
|
Telegrammer::DataTypes::User.new(response.result)
|
89
89
|
end
|
@@ -93,6 +93,7 @@ module Telegrammer
|
|
93
93
|
# @param [Hash] params hash of paramers to send to the sendMessage API operation.
|
94
94
|
# @option params [Integer] :chat_id Required. Unique identifier for the message recipient — User or GroupChat id.
|
95
95
|
# @option params [String] :text Required. Text of the message to be sent
|
96
|
+
# @option params [String] :parse_mode Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
|
96
97
|
# @option params [Boolean] :disable_web_page_preview Optional. Disables link previews for links in this message
|
97
98
|
# @option params [Integer] :reply_to_message_id Optional. If the message is a reply, ID of the original message
|
98
99
|
# @option params [Telegrammer::DataTypes::ReplyKeyboardMarkup,Telegrammer::DataTypes::ReplyKeyboardHide,Telegrammer::DataTypes::ForceReply] :reply_markup Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
|
@@ -112,6 +113,7 @@ module Telegrammer
|
|
112
113
|
def send_message(params)
|
113
114
|
extra_params_validation = {
|
114
115
|
text: { required: true, class: [String] },
|
116
|
+
parse_mode: { required: false, class: [String] },
|
115
117
|
disable_web_page_preview: { required: false, class: [TrueClass, FalseClass] }
|
116
118
|
}
|
117
119
|
|
@@ -145,7 +147,7 @@ module Telegrammer
|
|
145
147
|
message_id: { required: true, class: [Fixnum] }
|
146
148
|
}
|
147
149
|
|
148
|
-
response = api_request(
|
150
|
+
response = api_request('forwardMessage', params, params_validation)
|
149
151
|
|
150
152
|
Telegrammer::DataTypes::Message.new(response.result)
|
151
153
|
end
|
@@ -154,8 +156,8 @@ module Telegrammer
|
|
154
156
|
#
|
155
157
|
# @param [Hash] params hash of paramers to send to the sendPhoto API operation.
|
156
158
|
# @option params [Integer] :chat_id Required. Unique identifier for the message recipient — User or GroupChat id.
|
157
|
-
# @option params [File,String] :photo Required.
|
158
|
-
# @option params [String] :caption Optional.
|
159
|
+
# @option params [File,String] :photo Required. Photo to send. You can either pass a file_id as String to resend a photo that is already on the Telegram servers, or upload a new photo using multipart/form-data.
|
160
|
+
# @option params [String] :caption Optional. Photo caption (may also be used when resending photos by file_id).
|
159
161
|
# @option params [Integer] :reply_to_message_id Optional. If the message is a reply, ID of the original message
|
160
162
|
# @option params [Telegrammer::DataTypes::ReplyKeyboardMarkup,Telegrammer::DataTypes::ReplyKeyboardHide,Telegrammer::DataTypes::ForceReply] :reply_markup Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
|
161
163
|
#
|
@@ -171,7 +173,7 @@ module Telegrammer
|
|
171
173
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
172
174
|
def send_photo(params)
|
173
175
|
extra_params_validation = {
|
174
|
-
photo: { required:
|
176
|
+
photo: { required: true, class: [File, String] },
|
175
177
|
caption: { required: false, class: [String] }
|
176
178
|
}
|
177
179
|
|
@@ -185,6 +187,9 @@ module Telegrammer
|
|
185
187
|
# @param [Hash] params hash of paramers to send to the sendAudio API operation.
|
186
188
|
# @option params [Integer] :chat_id Required. Unique identifier for the message recipient — User or GroupChat id.
|
187
189
|
# @option params [File,String] audio Required. Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data
|
190
|
+
# @option params [Integer] duration Optional. Duration of the audio in seconds.
|
191
|
+
# @option params [String] performer Optional. Performer.
|
192
|
+
# @option params [String] title Optional. Track name.
|
188
193
|
# @option params [Integer] :reply_to_message_id Optional. If the message is a reply, ID of the original message
|
189
194
|
# @option params [Telegrammer::DataTypes::ReplyKeyboardMarkup,Telegrammer::DataTypes::ReplyKeyboardHide,Telegrammer::DataTypes::ForceReply] :reply_markup Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
|
190
195
|
#
|
@@ -200,12 +205,46 @@ module Telegrammer
|
|
200
205
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
201
206
|
def send_audio(params)
|
202
207
|
extra_params_validation = {
|
203
|
-
audio: { required:
|
208
|
+
audio: { required: true, class: [File, String] },
|
209
|
+
duration: { required: false, class: [Integer] },
|
210
|
+
performer: { required: false, class: [String] },
|
211
|
+
title: { required: false, class: [String] }
|
204
212
|
}
|
205
213
|
|
206
214
|
send_something(:audio, params, extra_params_validation)
|
207
215
|
end
|
208
216
|
|
217
|
+
# Sends audio files file to a user or group chat that the users will see as a playable voice message.
|
218
|
+
#
|
219
|
+
# At this moment, Telegram only allows Ogg files encoded with the OPUS codec. If you need to send another file format, you must use #send_document.
|
220
|
+
#
|
221
|
+
# @param [Hash] params hash of paramers to send to the sendAudio API operation.
|
222
|
+
# @option params [Integer] :chat_id Required. Unique identifier for the message recipient — User or GroupChat id.
|
223
|
+
# @option params [File,String] voice Required. Audio file to send. You can either pass a file_id as String to resend an audio that is already on the Telegram servers, or upload a new audio file using multipart/form-data
|
224
|
+
# @option params [Integer] duration Optional. Duration of sent audio in seconds.
|
225
|
+
# @option params [Integer] :reply_to_message_id Optional. If the message is a reply, ID of the original message
|
226
|
+
# @option params [Telegrammer::DataTypes::ReplyKeyboardMarkup,Telegrammer::DataTypes::ReplyKeyboardHide,Telegrammer::DataTypes::ForceReply] :reply_markup Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
|
227
|
+
#
|
228
|
+
# @example
|
229
|
+
# bot = Telegrammer::Bot.new('[YOUR TELEGRAM TOKEN]')
|
230
|
+
# voice_file = File.open("foo.ogg")
|
231
|
+
# bot.send_voice(chat_id: 123456789, voice: audio_file)
|
232
|
+
#
|
233
|
+
# @raise [Telegrammer::Errors::BadRequestError] if something goes wrong in the Telegram API servers with the params received by the operation
|
234
|
+
# @raise [Telegrammer::Errors::ServiceUnavailableError] if Telegram servers are down
|
235
|
+
#
|
236
|
+
# @see #send_document
|
237
|
+
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
238
|
+
def send_voice(params)
|
239
|
+
extra_params_validation = {
|
240
|
+
voice: { required: true, class: [File, String] },
|
241
|
+
duration: { required: false, class: [Integer] }
|
242
|
+
}
|
243
|
+
|
244
|
+
send_something(:audio, params, extra_params_validation)
|
245
|
+
end
|
246
|
+
|
247
|
+
|
209
248
|
# Sends a document to a user or group chat.
|
210
249
|
#
|
211
250
|
# @param [Hash] params hash of paramers to send to the sendDocument API operation.
|
@@ -225,7 +264,7 @@ module Telegrammer
|
|
225
264
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
226
265
|
def send_document(params)
|
227
266
|
extra_params_validation = {
|
228
|
-
document: { required:
|
267
|
+
document: { required: true, class: [File, String] }
|
229
268
|
}
|
230
269
|
|
231
270
|
send_something(:document, params, extra_params_validation)
|
@@ -263,7 +302,9 @@ module Telegrammer
|
|
263
302
|
#
|
264
303
|
# @param [Hash] params hash of paramers to send to the sendVideo API operation.
|
265
304
|
# @option params [Integer] :chat_id Required. Unique identifier for the message recipient — User or GroupChat id.
|
266
|
-
# @option params [File,String] :video Video to send. You can either pass a file_id as String to resend a video that is already on the Telegram servers, or upload a new video file.
|
305
|
+
# @option params [File,String] :video Required. Video to send. You can either pass a file_id as String to resend a video that is already on the Telegram servers, or upload a new video file.
|
306
|
+
# @option params [Integer] :duration Optional. Duration of sent video in seconds.
|
307
|
+
# @option params [String] :caption Optional. Video caption (may also be used when resending videos by file_id).
|
267
308
|
# @option params [Integer] :reply_to_message_id Optional. If the message is a reply, ID of the original message
|
268
309
|
# @option params [Telegrammer::DataTypes::ReplyKeyboardMarkup,Telegrammer::DataTypes::ReplyKeyboardHide,Telegrammer::DataTypes::ForceReply] :reply_markup Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.
|
269
310
|
#
|
@@ -279,7 +320,9 @@ module Telegrammer
|
|
279
320
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
280
321
|
def send_video(params)
|
281
322
|
extra_params_validation = {
|
282
|
-
video: { required: true, class: [File, String] }
|
323
|
+
video: { required: true, class: [File, String] },
|
324
|
+
duration: { required: false, class: [Integer] },
|
325
|
+
caption: { required: false, class: [String] }
|
283
326
|
}
|
284
327
|
|
285
328
|
send_something(:video, params, extra_params_validation)
|
@@ -333,7 +376,7 @@ module Telegrammer
|
|
333
376
|
action: { required: true, class: [String] }
|
334
377
|
}
|
335
378
|
|
336
|
-
api_request(
|
379
|
+
api_request('sendChatAction', params, params_validation)
|
337
380
|
end
|
338
381
|
|
339
382
|
# Get a list of profile pictures for a user.
|
@@ -358,7 +401,7 @@ module Telegrammer
|
|
358
401
|
limit: { required: false, class: [Fixnum] }
|
359
402
|
}
|
360
403
|
|
361
|
-
response = api_request(
|
404
|
+
response = api_request('getUserProfilePhotos', params, params_validation)
|
362
405
|
|
363
406
|
Telegrammer::DataTypes::UserProfilePhotos.new(response.result)
|
364
407
|
end
|
@@ -372,19 +415,19 @@ module Telegrammer
|
|
372
415
|
validated_params = params
|
373
416
|
else
|
374
417
|
# Delete params not accepted by the API
|
375
|
-
validated_params = params.delete_if {|k,
|
418
|
+
validated_params = params.delete_if { |k, _v| !params_validation.key?(k) }
|
376
419
|
|
377
420
|
# Check all required params by the action are present
|
378
|
-
params_validation.each do |key,
|
379
|
-
if params_validation[key][:required] && !params.
|
380
|
-
|
421
|
+
params_validation.each do |key, _value|
|
422
|
+
if params_validation[key][:required] && !params.key?(key)
|
423
|
+
fail Telegrammer::Errors::MissingParamsError.new(key, action)
|
381
424
|
end
|
382
425
|
end
|
383
426
|
|
384
427
|
params.each do |key, value|
|
385
428
|
# Check param types
|
386
|
-
|
387
|
-
|
429
|
+
unless params_validation[key][:class].include?(value.class)
|
430
|
+
fail Telegrammer::Errors::InvalidParamTypeError.new(key, value.class, params_validation[key][:class])
|
388
431
|
end
|
389
432
|
|
390
433
|
# Prepare params for sending in Typhoeus post body request
|
@@ -400,10 +443,8 @@ module Telegrammer
|
|
400
443
|
response = @connection.post(
|
401
444
|
"#{API_ENDPOINT}/#{api_uri}",
|
402
445
|
validated_params,
|
403
|
-
{
|
404
|
-
|
405
|
-
"Accept" => "application/json"
|
406
|
-
}
|
446
|
+
'User-Agent' => "Telegrammer/#{Telegrammer::VERSION}",
|
447
|
+
'Accept' => 'application/json'
|
407
448
|
)
|
408
449
|
|
409
450
|
ApiResponse.new(response)
|
@@ -416,8 +457,8 @@ module Telegrammer
|
|
416
457
|
reply_markup: { required: false, class: [
|
417
458
|
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
418
459
|
Telegrammer::DataTypes::ReplyKeyboardHide,
|
419
|
-
Telegrammer::DataTypes::ForceReply
|
420
|
-
]}
|
460
|
+
Telegrammer::DataTypes::ForceReply
|
461
|
+
] }
|
421
462
|
}
|
422
463
|
|
423
464
|
response = api_request("send#{object_kind.to_s.capitalize}", params, extra_params_validation.merge(params_validation))
|
@@ -4,14 +4,18 @@ module Telegrammer
|
|
4
4
|
#
|
5
5
|
# @attr [String] file_id Unique identifier for this file
|
6
6
|
# @attr [Integer] duration Duration of the audio in seconds as defined by sender
|
7
|
-
# @attr [String]
|
8
|
-
# @attr [
|
7
|
+
# @attr [String] performer Optional. Performer of the audio as defined by sender or by audio tags
|
8
|
+
# @attr [String] title Optional. Title of the audio as defined by sender or by audio tags
|
9
|
+
# @attr [String] mime_type Optional. MIME type of the file as defined by sender
|
10
|
+
# @attr [Integer] file_size Optional. File size
|
9
11
|
#
|
10
12
|
# See more at https://core.telegram.org/bots/api#audio
|
11
13
|
class Audio < Telegrammer::DataTypes::Base
|
12
14
|
# Unique identifier
|
13
15
|
attribute :file_id, String
|
14
16
|
attribute :duration, Integer
|
17
|
+
attribute :performer, String
|
18
|
+
attribute :title, String
|
15
19
|
attribute :mime_type, String
|
16
20
|
attribute :file_size, Integer
|
17
21
|
end
|
@@ -5,14 +5,14 @@ module Telegrammer
|
|
5
5
|
# @attr [String] phone_number Contact's phone number
|
6
6
|
# @attr [String] first_name Contact's first name
|
7
7
|
# @attr [String] last_name Optional. Contact's last name
|
8
|
-
# @attr [
|
8
|
+
# @attr [Integer] user_id Optional. Contact's user identifier in Telegram
|
9
9
|
#
|
10
10
|
# See more at https://core.telegram.org/bots/api#contact
|
11
11
|
class Contact < Telegrammer::DataTypes::Base
|
12
12
|
attribute :phone_number, String
|
13
13
|
attribute :first_name, String
|
14
14
|
attribute :last_name, String
|
15
|
-
attribute :user_id,
|
15
|
+
attribute :user_id, Integer
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -15,6 +15,8 @@ module Telegrammer
|
|
15
15
|
# @attr [Telegrammer::DataTypes::PhotoSize] photo Optional. Message is a photo, available sizes of the photo
|
16
16
|
# @attr [Telegrammer::DataTypes::Sticker] sticker Optional. Message is a sticker, information about the sticker
|
17
17
|
# @attr [Telegrammer::DataTypes::Video] video Optional. Message is a video, information about the video
|
18
|
+
# @attr [Telegrammer::DataTypes::Voice] voice Optional. Message is a voice message, information about the file
|
19
|
+
# @attr [String] caption Optional. Caption for the photo or video
|
18
20
|
# @attr [Telegrammer::DataTypes::Contact] contact Optional. Message is a shared contact, information about the contact
|
19
21
|
# @attr [Telegrammer::DataTypes::Location] location Optional. Message is a shared location, information about the location
|
20
22
|
# @attr [Telegrammer::DataTypes::User] new_chat_participant Optional. A new member was added to the group, information about them (this member may be bot itself)
|
@@ -39,6 +41,7 @@ module Telegrammer
|
|
39
41
|
attribute :photo, Array[PhotoSize]
|
40
42
|
attribute :sticker, Sticker
|
41
43
|
attribute :video, Video
|
44
|
+
attribute :voice, Voice
|
42
45
|
attribute :contact, Contact
|
43
46
|
attribute :location, Location
|
44
47
|
attribute :new_chat_participant, User
|
@@ -9,7 +9,6 @@ module Telegrammer
|
|
9
9
|
# @attr [Telegrammer::DataTypes::PhotoSize] thumb Video thumbnail
|
10
10
|
# @attr [String] mime_type Optional. Mime type of a file as defined by sender
|
11
11
|
# @attr [String] file_size Optional. File size
|
12
|
-
# @attr [String] caption Optional. Text description of the video (usually empty)
|
13
12
|
#
|
14
13
|
# See more at https://core.telegram.org/bots/api#video
|
15
14
|
class Video < Telegrammer::DataTypes::Base
|
@@ -20,7 +19,6 @@ module Telegrammer
|
|
20
19
|
attribute :thumb, PhotoSize
|
21
20
|
attribute :mime_type, String
|
22
21
|
attribute :file_size, Integer
|
23
|
-
attribute :caption, String
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Telegrammer
|
2
|
+
module DataTypes
|
3
|
+
# Telegram Voice data type
|
4
|
+
#
|
5
|
+
# @attr [String] file_id Unique file identifier
|
6
|
+
# @attr [Integer] duration Duration of the audio in seconds as defined by sender
|
7
|
+
# @attr [String] mime_type Optional. Mime type of a file as defined by sender
|
8
|
+
# @attr [String] file_size Optional. File size
|
9
|
+
#
|
10
|
+
# See more at https://core.telegram.org/bots/api#video
|
11
|
+
class Voice < Telegrammer::DataTypes::Base
|
12
|
+
attribute :file_id, String
|
13
|
+
attribute :duration, Integer
|
14
|
+
attribute :mime_type, String
|
15
|
+
attribute :file_size, Integer
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/telegrammer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegrammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Mayoral
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/telegrammer/data_types/user.rb
|
113
113
|
- lib/telegrammer/data_types/user_profile_photos.rb
|
114
114
|
- lib/telegrammer/data_types/video.rb
|
115
|
+
- lib/telegrammer/data_types/voice.rb
|
115
116
|
- lib/telegrammer/version.rb
|
116
117
|
- telegrammer.gemspec
|
117
118
|
homepage: https://github.com/mayoral/telegrammer
|