telegram-bot-ruby 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 293f3e90dc90b39181a1cee27db8e817f180e83b
|
4
|
+
data.tar.gz: d0e165c9dfbcce35f2ed47c8f754bbb2fe7d9dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2fdd4d4105f5403781427ca4154fcfc59d13040c0041db308acfa70b45e6a3bcb41c383e8df4a7ceec44f8d1a582d3035b8cf2fcecee8c8ca3ceedca6af6e5d
|
7
|
+
data.tar.gz: 16994c1bd51b1083ae6f32bf62d9cc5eed56ec0491b35b70611cd6ea37a942b7688505a432f2129d703106767cea2f6e9c142f1cb6fe20d545685b6de92de090
|
data/lib/telegram/bot.rb
CHANGED
data/lib/telegram/bot/api.rb
CHANGED
@@ -30,7 +30,12 @@ module Telegram
|
|
30
30
|
def call(endpoint, raw_params = {})
|
31
31
|
params = build_params(raw_params)
|
32
32
|
response = self.class.get("/bot#{token}/#{endpoint}", query: params)
|
33
|
-
response.code == 200
|
33
|
+
if response.code == 200
|
34
|
+
response.to_h
|
35
|
+
else
|
36
|
+
fail Exceptions::ResponseError.new(response),
|
37
|
+
'Telegram API has returned the error.'
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
private
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Telegram
|
2
|
+
module Bot
|
3
|
+
module Exceptions
|
4
|
+
class ResponseError < Base
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
super +
|
13
|
+
format(' (%s)', data.map { |k, v| %(#{k}: "#{v}") }.join(', '))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def data
|
19
|
+
@data ||= begin
|
20
|
+
JSON.parse(response.body)
|
21
|
+
rescue JSON::ParserError
|
22
|
+
{ error_code: response.code, uri: response.request.last_uri.to_s }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/telegram/bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram-bot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Tipugin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
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: httparty
|
@@ -126,6 +126,9 @@ files:
|
|
126
126
|
- lib/telegram/bot.rb
|
127
127
|
- lib/telegram/bot/api.rb
|
128
128
|
- lib/telegram/bot/client.rb
|
129
|
+
- lib/telegram/bot/exceptions.rb
|
130
|
+
- lib/telegram/bot/exceptions/base.rb
|
131
|
+
- lib/telegram/bot/exceptions/response_error.rb
|
129
132
|
- lib/telegram/bot/types.rb
|
130
133
|
- lib/telegram/bot/types/audio.rb
|
131
134
|
- lib/telegram/bot/types/base.rb
|