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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81fad88c2c153f95b4ef9982e697ed9880879e5b
4
- data.tar.gz: 979778e05bf58d07b2ad3d0e33db74720251804b
3
+ metadata.gz: ffea29a66826bae04166449e185b9f4ef54ce99c
4
+ data.tar.gz: e7a5ffba454e1ddb4d33f92248e11648dde00a83
5
5
  SHA512:
6
- metadata.gz: e951568444fc8e649b5d2b90f165537800a7a230509672e4f117b19b3d0ac86acdc69784256092d961c357ea219c4a19ecde55db2a0a73f4e382419f8e70e144
7
- data.tar.gz: 514d4c4ca7e5309ae3dfba4571029bf9ffb8bf3a5068d5c2596e44783b59986dd9a83ef8d1b8618e134ac40ecb46bb6eac9c0a58bcdc71a60aa248aa32545e18
6
+ metadata.gz: c9a1c5aca2949b844c5cbecedfb05c781de4b2d8fdbb13eba8b06f558d827b4432180929aac809b839f78e5185784a19f4096a61c2fb2f337966e4ca74b1b642
7
+ data.tar.gz: 433bdd8eb803ec18e77b62fa0324ddfa1df321859bb51babad9fcaaecdc4aaaed3b342ab726482348b395fa9be9ac05596c083055acb5e917c9b70722aa5927c
@@ -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
- @bot.parse_request(request)
41
+ bot.parse_request(request)
38
42
 
39
43
  handler = handler.new(self)
40
44
 
41
- if @bot.message.cmd?
42
- @cache.write(@bot.chat.id, @bot.message.cmd)
45
+ if bot.message.cmd?
46
+ @cache.write(bot.chat.id, message.cmd)
43
47
  else
44
- @bot.message.cmd = @cache.fetch(@bot.chat.id)
48
+ message.cmd = @cache.fetch(chat.id)
45
49
  end
46
50
 
47
- if handler.respond_to? "cmd_#{@bot.message.cmd}"
48
- handler.public_send("cmd_#{@bot.message.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(@bot.chat.id)
59
+ @cache.delete(chat.id)
56
60
  end
57
61
 
58
62
  def send(method, query = {})
59
- @bot.send(method, query)
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
- @bot.send_message(text, options)
73
+ bot.send_message(text, options)
70
74
  end
71
75
 
72
76
  def send_message!(text, options = {})
@@ -5,8 +5,6 @@ module Botomizer
5
5
  # Exception raised when you attempt to set a non-existent client
6
6
  class UnsupportedClient < Error; end
7
7
 
8
- class WebhookError < Error; end
9
-
10
8
  class ChatError < Error; end
11
9
 
12
10
  class MessageError < Error; end
@@ -3,7 +3,7 @@ class Botomizer::Message
3
3
 
4
4
  def initialize(params)
5
5
  @id = params[:id]
6
- @text = params[:text]
6
+ @text = params[:text].to_s
7
7
 
8
8
  if @text.index('/') == 0
9
9
  sp = @text.split(' ')
@@ -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'].detect do |key|
13
- request.has_key? 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
- if message_key
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
- begin
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
- begin
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
@@ -1,3 +1,3 @@
1
1
  module Botomizer
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
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.6
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-16 00:00:00.000000000 Z
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
@@ -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