telegram_bot 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/Rakefile +8 -0
- data/lib/telegram_bot/api_response.rb +3 -4
- data/lib/telegram_bot/bot.rb +14 -1
- data/lib/telegram_bot/response_error.rb +17 -0
- data/lib/telegram_bot/version.rb +1 -1
- data/spec/minitest_helper.rb +2 -0
- data/spec/telegram_bot_spec.rb +4 -0
- data/telegram_bot.gemspec +1 -0
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49e3b9501a8d3c9bf71a3d52946c261c84876946
|
4
|
+
data.tar.gz: 0d23a35d5be8af63cdde2f76764373853f53d5c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e094fd6c4bff2b12cc9aa2d8a6c9db49941d8cc333c4a60b5a66e7e84973d95cc8e01391759738a8d5af88f913b1bde4463bca4c218a78530edb3f4a7705308
|
7
|
+
data.tar.gz: 3d3f0ec72ac66d62c661234a24c65fd8d0eb19b20db3debb4d20b1157eaaab47dada05aedce3e6c3c0dbc30bedc6edd69561f83c63cbd5472d9c55ab1148127f
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.4.3
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module TelegramBot
|
2
2
|
class ApiResponse
|
3
|
-
attr_reader :body, :ok, :result
|
3
|
+
attr_reader :body, :ok, :result
|
4
4
|
|
5
5
|
def initialize(res)
|
6
6
|
@body = res.body
|
@@ -9,10 +9,9 @@ module TelegramBot
|
|
9
9
|
@ok = data["ok"]
|
10
10
|
@result = data["result"]
|
11
11
|
else
|
12
|
-
data = JSON.parse(body)
|
13
12
|
@ok = false
|
14
|
-
|
15
|
-
|
13
|
+
error = ResponseError.new(res)
|
14
|
+
fail error, "An error has occurred: #{error.data}", caller
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
data/lib/telegram_bot/bot.rb
CHANGED
@@ -40,11 +40,24 @@ module TelegramBot
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def send_message(out_message)
|
43
|
-
response = request(:sendMessage, out_message.to_h)
|
44
43
|
logger.info "sending message: #{out_message.text.inspect} to #{out_message.chat_friendly_name}"
|
44
|
+
response = request(:sendMessage, out_message.to_h)
|
45
45
|
Message.new(response.result)
|
46
46
|
end
|
47
47
|
|
48
|
+
def set_webhook(url, allowed_updates: %i(message))
|
49
|
+
logger.info "setting webhook url to #{url}, allowed_updates: #{allowed_updates}"
|
50
|
+
settings = {
|
51
|
+
url: url,
|
52
|
+
allowed_updates: allowed_updates.map(&:to_s),
|
53
|
+
}
|
54
|
+
request(:setWebhook, settings)
|
55
|
+
end
|
56
|
+
|
57
|
+
def remove_webhook
|
58
|
+
set_webhook("")
|
59
|
+
end
|
60
|
+
|
48
61
|
private
|
49
62
|
attr_reader :token
|
50
63
|
attr_reader :logger
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
class ResponseError < StandardError
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def initialize(res)
|
6
|
+
@response = res
|
7
|
+
end
|
8
|
+
|
9
|
+
def data
|
10
|
+
@data ||= begin
|
11
|
+
JSON.parse(response.body)
|
12
|
+
rescue JSON::ParserError
|
13
|
+
{ error_code: response.status, error_message: response.reason_phrase }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/telegram_bot/version.rb
CHANGED
data/telegram_bot.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Tomás Albornoz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.10'
|
69
83
|
description: Still in development. Simple client for Telegram's Bot API
|
70
84
|
email:
|
71
85
|
- jojo@eljojo.net
|
@@ -74,6 +88,7 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".tool-versions"
|
77
92
|
- CODE_OF_CONDUCT.md
|
78
93
|
- Gemfile
|
79
94
|
- LICENSE.txt
|
@@ -94,9 +109,12 @@ files:
|
|
94
109
|
- lib/telegram_bot/out_message.rb
|
95
110
|
- lib/telegram_bot/reply_keyboard_hide.rb
|
96
111
|
- lib/telegram_bot/reply_keyboard_markup.rb
|
112
|
+
- lib/telegram_bot/response_error.rb
|
97
113
|
- lib/telegram_bot/update.rb
|
98
114
|
- lib/telegram_bot/user.rb
|
99
115
|
- lib/telegram_bot/version.rb
|
116
|
+
- spec/minitest_helper.rb
|
117
|
+
- spec/telegram_bot_spec.rb
|
100
118
|
- telegram_bot.gemspec
|
101
119
|
homepage: https://github.com/eljojo/telegram_bot
|
102
120
|
licenses:
|
@@ -118,8 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
136
|
version: '0'
|
119
137
|
requirements: []
|
120
138
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.6.14
|
122
140
|
signing_key:
|
123
141
|
specification_version: 4
|
124
142
|
summary: Simple client for Telegram's Bot API
|
125
|
-
test_files:
|
143
|
+
test_files:
|
144
|
+
- spec/minitest_helper.rb
|
145
|
+
- spec/telegram_bot_spec.rb
|