botomizer 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/botomizer/client.rb +13 -9
- data/lib/botomizer/exceptions.rb +0 -2
- data/lib/botomizer/message.rb +1 -1
- data/lib/botomizer/telegram.rb +3 -3
- data/lib/botomizer/telegram/webhook.rb +2 -10
- data/lib/botomizer/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffea29a66826bae04166449e185b9f4ef54ce99c
|
4
|
+
data.tar.gz: e7a5ffba454e1ddb4d33f92248e11648dde00a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a1c5aca2949b844c5cbecedfb05c781de4b2d8fdbb13eba8b06f558d827b4432180929aac809b839f78e5185784a19f4096a61c2fb2f337966e4ca74b1b642
|
7
|
+
data.tar.gz: 433bdd8eb803ec18e77b62fa0324ddfa1df321859bb51babad9fcaaecdc4aaaed3b342ab726482348b395fa9be9ac05596c083055acb5e917c9b70722aa5927c
|
data/lib/botomizer/client.rb
CHANGED
@@ -33,30 +33,34 @@ class Botomizer::Client
|
|
33
33
|
@bot
|
34
34
|
end
|
35
35
|
|
36
|
+
def cache
|
37
|
+
@cache
|
38
|
+
end
|
39
|
+
|
36
40
|
def handle(request, handler)
|
37
|
-
|
41
|
+
bot.parse_request(request)
|
38
42
|
|
39
43
|
handler = handler.new(self)
|
40
44
|
|
41
|
-
if
|
42
|
-
@cache.write(
|
45
|
+
if bot.message.cmd?
|
46
|
+
@cache.write(bot.chat.id, message.cmd)
|
43
47
|
else
|
44
|
-
|
48
|
+
message.cmd = @cache.fetch(chat.id)
|
45
49
|
end
|
46
50
|
|
47
|
-
if handler.respond_to? "cmd_#{
|
48
|
-
handler.public_send("cmd_#{
|
51
|
+
if handler.respond_to? "cmd_#{message.cmd}"
|
52
|
+
handler.public_send("cmd_#{message.cmd}")
|
49
53
|
else
|
50
54
|
handler.cmd_fallback
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
58
|
def clean_history
|
55
|
-
@cache.delete(
|
59
|
+
@cache.delete(chat.id)
|
56
60
|
end
|
57
61
|
|
58
62
|
def send(method, query = {})
|
59
|
-
|
63
|
+
bot.send(method, query)
|
60
64
|
end
|
61
65
|
|
62
66
|
def send!(method, query = {})
|
@@ -66,7 +70,7 @@ class Botomizer::Client
|
|
66
70
|
end
|
67
71
|
|
68
72
|
def send_message(text, options = {})
|
69
|
-
|
73
|
+
bot.send_message(text, options)
|
70
74
|
end
|
71
75
|
|
72
76
|
def send_message!(text, options = {})
|
data/lib/botomizer/exceptions.rb
CHANGED
data/lib/botomizer/message.rb
CHANGED
data/lib/botomizer/telegram.rb
CHANGED
@@ -9,11 +9,11 @@ module Botomizer::Telegram
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse_request(request)
|
12
|
-
message_key = ['message', 'edited_message', 'channel_post', 'edited_channel_post'].
|
13
|
-
request.has_key?
|
12
|
+
message_key = ['message', 'edited_message', 'channel_post', 'edited_channel_post'].find do |key|
|
13
|
+
request.has_key?(key)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
unless message_key.nil?
|
17
17
|
message = request[message_key]
|
18
18
|
@message = Botomizer::Message.new({
|
19
19
|
id: message['message_id'],
|
@@ -8,11 +8,7 @@ class Botomizer::Telegram::Webhook
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def set!(url)
|
11
|
-
|
12
|
-
@client.send!('setWebhook', {url: url})
|
13
|
-
rescue Botomizer::ResponseError => e
|
14
|
-
raise Botomizer::WebhookError.new(e)
|
15
|
-
end
|
11
|
+
@client.send!('setWebhook', {url: url})
|
16
12
|
end
|
17
13
|
|
18
14
|
def info
|
@@ -24,10 +20,6 @@ class Botomizer::Telegram::Webhook
|
|
24
20
|
end
|
25
21
|
|
26
22
|
def delete!
|
27
|
-
|
28
|
-
@client.send!('deleteWebhook')
|
29
|
-
rescue Botomizer::ResponseError => e
|
30
|
-
raise Botomizer::WebhookError.new(e)
|
31
|
-
end
|
23
|
+
@client.send!('deleteWebhook')
|
32
24
|
end
|
33
25
|
end
|
data/lib/botomizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botomizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Belenky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- ".travis.yml"
|
93
93
|
- CODE_OF_CONDUCT.md
|
94
94
|
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
95
|
- LICENSE.txt
|
97
96
|
- README.md
|
98
97
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
botomizer (0.1.0)
|
5
|
-
httparty (>= 0.15.6)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activesupport (5.1.4)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (~> 0.7)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
concurrent-ruby (1.0.5)
|
16
|
-
diff-lcs (1.3)
|
17
|
-
httparty (0.15.6)
|
18
|
-
multi_xml (>= 0.5.2)
|
19
|
-
i18n (0.9.1)
|
20
|
-
concurrent-ruby (~> 1.0)
|
21
|
-
minitest (5.10.3)
|
22
|
-
multi_xml (0.6.0)
|
23
|
-
rake (12.3.0)
|
24
|
-
rspec (3.7.0)
|
25
|
-
rspec-core (~> 3.7.0)
|
26
|
-
rspec-expectations (~> 3.7.0)
|
27
|
-
rspec-mocks (~> 3.7.0)
|
28
|
-
rspec-core (3.7.0)
|
29
|
-
rspec-support (~> 3.7.0)
|
30
|
-
rspec-expectations (3.7.0)
|
31
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.7.0)
|
33
|
-
rspec-mocks (3.7.0)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.7.0)
|
36
|
-
rspec-support (3.7.0)
|
37
|
-
thread_safe (0.3.6)
|
38
|
-
tzinfo (1.2.4)
|
39
|
-
thread_safe (~> 0.1)
|
40
|
-
|
41
|
-
PLATFORMS
|
42
|
-
ruby
|
43
|
-
|
44
|
-
DEPENDENCIES
|
45
|
-
activesupport (~> 5.1)
|
46
|
-
botomizer!
|
47
|
-
bundler (~> 1.16)
|
48
|
-
rake (> 10.0)
|
49
|
-
rspec (~> 3.0)
|
50
|
-
|
51
|
-
BUNDLED WITH
|
52
|
-
1.16.0
|