telegrammer 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/telegrammer/bot.rb +38 -85
- data/lib/telegrammer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc5d677c010ce352e77dff0485af04688cd6937
|
4
|
+
data.tar.gz: ecaaf9602bf7bc7912e1fd0665d088f0773e8b61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc3a0bb233f5fc8c1255cae7a3087442f5ec4fa930da8b8840163f3c9e73582d741bd8c0f403b114f7a954cfa658a356be75adffaff805ca5e980b15df58bb8
|
7
|
+
data.tar.gz: 6af421ebee380d692566e26cac7857de19b8be19911022f8ac6c68315e98829fbe25823f2c7d0b6b8d8a9d47cd9785eff2ed5818ed01bd938003ad9f3c0e863b
|
data/CHANGELOG.md
CHANGED
data/lib/telegrammer/bot.rb
CHANGED
@@ -109,21 +109,12 @@ module Telegrammer
|
|
109
109
|
#
|
110
110
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
111
111
|
def send_message(params)
|
112
|
-
|
113
|
-
chat_id: { required: true, class: [Fixnum] },
|
112
|
+
extra_params_validation = {
|
114
113
|
text: { required: true, class: [String] },
|
115
|
-
disable_web_page_preview: { required: false, class: [TrueClass, FalseClass] }
|
116
|
-
reply_to_message_id: { required: false, class: [Fixnum] },
|
117
|
-
reply_markup: { required: false, class: [
|
118
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
119
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
120
|
-
Telegrammer::DataTypes::ForceReply,
|
121
|
-
]}
|
114
|
+
disable_web_page_preview: { required: false, class: [TrueClass, FalseClass] }
|
122
115
|
}
|
123
116
|
|
124
|
-
|
125
|
-
|
126
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
117
|
+
send_something(:message, params, extra_params_validation)
|
127
118
|
end
|
128
119
|
|
129
120
|
# Forward message to a user or group chat.
|
@@ -178,21 +169,12 @@ module Telegrammer
|
|
178
169
|
# @see #send_document
|
179
170
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
180
171
|
def send_photo(params)
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
caption: { required: false, class: [String] },
|
185
|
-
reply_to_message_id: { required: false, class: [String] },
|
186
|
-
reply_markup: { required: false, class: [
|
187
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
188
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
189
|
-
Telegrammer::DataTypes::ForceReply,
|
190
|
-
]}
|
172
|
+
extra_params_validation = {
|
173
|
+
photo: { required: false, class: [File, String] },
|
174
|
+
caption: { required: false, class: [String] }
|
191
175
|
}
|
192
176
|
|
193
|
-
|
194
|
-
|
195
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
177
|
+
send_something(:photo, params, extra_params_validation)
|
196
178
|
end
|
197
179
|
|
198
180
|
# Sends audio file to a user or group chat.
|
@@ -216,20 +198,11 @@ module Telegrammer
|
|
216
198
|
# @see #send_document
|
217
199
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
218
200
|
def send_audio(params)
|
219
|
-
|
220
|
-
|
221
|
-
audio: { required: true, class: [File, String] },
|
222
|
-
reply_to_message_id: { required: false, class: [String] },
|
223
|
-
reply_markup: { required: false, class: [
|
224
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
225
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
226
|
-
Telegrammer::DataTypes::ForceReply,
|
227
|
-
]}
|
201
|
+
extra_params_validation = {
|
202
|
+
audio: { required: false, class: [File, String] }
|
228
203
|
}
|
229
204
|
|
230
|
-
|
231
|
-
|
232
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
205
|
+
send_something(:audio, params, extra_params_validation)
|
233
206
|
end
|
234
207
|
|
235
208
|
# Sends a document to a user or group chat.
|
@@ -250,20 +223,11 @@ module Telegrammer
|
|
250
223
|
#
|
251
224
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
252
225
|
def send_document(params)
|
253
|
-
|
254
|
-
|
255
|
-
document: { required: false, class: [File, String] },
|
256
|
-
reply_to_message_id: { required: false, class: [String] },
|
257
|
-
reply_markup: { required: false, class: [
|
258
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
259
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
260
|
-
Telegrammer::DataTypes::ForceReply,
|
261
|
-
]}
|
226
|
+
extra_params_validation = {
|
227
|
+
document: { required: false, class: [File, String] }
|
262
228
|
}
|
263
229
|
|
264
|
-
|
265
|
-
|
266
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
230
|
+
send_something(:document, params, extra_params_validation)
|
267
231
|
end
|
268
232
|
|
269
233
|
# Send WebP images as stickers.
|
@@ -285,20 +249,11 @@ module Telegrammer
|
|
285
249
|
# @see #send_document
|
286
250
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
287
251
|
def send_sticker(params)
|
288
|
-
|
289
|
-
|
290
|
-
sticker: { required: true, class: [File, String] },
|
291
|
-
reply_to_message_id: { required: false, class: [String] },
|
292
|
-
reply_markup: { required: false, class: [
|
293
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
294
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
295
|
-
Telegrammer::DataTypes::ForceReply,
|
296
|
-
]}
|
252
|
+
extra_params_validation = {
|
253
|
+
sticker: { required: true, class: [File, String] }
|
297
254
|
}
|
298
255
|
|
299
|
-
|
300
|
-
|
301
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
256
|
+
send_something(:sticker, params, extra_params_validation)
|
302
257
|
end
|
303
258
|
|
304
259
|
# Sends a video file to a user or group chat.
|
@@ -322,20 +277,11 @@ module Telegrammer
|
|
322
277
|
# @see #send_document
|
323
278
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
324
279
|
def send_video(params)
|
325
|
-
|
326
|
-
|
327
|
-
video: { required: true, class: [File, String] },
|
328
|
-
reply_to_message_id: { required: false, class: [String] },
|
329
|
-
reply_markup: { required: false, class: [
|
330
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
331
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
332
|
-
Telegrammer::DataTypes::ForceReply,
|
333
|
-
]}
|
280
|
+
extra_params_validation = {
|
281
|
+
video: { required: true, class: [File, String] }
|
334
282
|
}
|
335
283
|
|
336
|
-
|
337
|
-
|
338
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
284
|
+
send_something(:video, params, extra_params_validation)
|
339
285
|
end
|
340
286
|
|
341
287
|
# Sends point on the map to a user or group chat.
|
@@ -356,21 +302,12 @@ module Telegrammer
|
|
356
302
|
#
|
357
303
|
# @return [Telegrammer::DataTypes::Message] Message object sent to the user or group chat
|
358
304
|
def send_location(params)
|
359
|
-
|
360
|
-
chat_id: { required: true, class: [Fixnum] },
|
305
|
+
extra_params_validation = {
|
361
306
|
latitude: { required: true, class: [Float] },
|
362
|
-
longitude: { required: true, class: [Float] }
|
363
|
-
reply_to_message_id: { required: false, class: [String] },
|
364
|
-
reply_markup: { required: false, class: [
|
365
|
-
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
366
|
-
Telegrammer::DataTypes::ReplyKeyboardHide,
|
367
|
-
Telegrammer::DataTypes::ForceReply,
|
368
|
-
]}
|
307
|
+
longitude: { required: true, class: [Float] }
|
369
308
|
}
|
370
309
|
|
371
|
-
|
372
|
-
|
373
|
-
Telegrammer::DataTypes::Message.new(response.result)
|
310
|
+
send_something(:location, params, extra_params_validation)
|
374
311
|
end
|
375
312
|
|
376
313
|
# Sends a status action to a user or group chat.
|
@@ -470,5 +407,21 @@ module Telegrammer
|
|
470
407
|
|
471
408
|
ApiResponse.new(response)
|
472
409
|
end
|
410
|
+
|
411
|
+
def send_something(object_kind, params, extra_params_validation = {})
|
412
|
+
params_validation = {
|
413
|
+
chat_id: { required: true, class: [Fixnum] },
|
414
|
+
reply_to_message_id: { required: false, class: [String] },
|
415
|
+
reply_markup: { required: false, class: [
|
416
|
+
Telegrammer::DataTypes::ReplyKeyboardMarkup,
|
417
|
+
Telegrammer::DataTypes::ReplyKeyboardHide,
|
418
|
+
Telegrammer::DataTypes::ForceReply,
|
419
|
+
]}
|
420
|
+
}
|
421
|
+
|
422
|
+
response = api_request("send#{object_kind.to_s.capitalize}", params, extra_params_validation.merge(params_validation))
|
423
|
+
|
424
|
+
Telegrammer::DataTypes::Message.new(response.result)
|
425
|
+
end
|
473
426
|
end
|
474
427
|
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.2.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-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|