botomizer 0.1.15 → 0.1.16
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 +8 -10
- data/lib/botomizer/telegram.rb +4 -2
- data/lib/botomizer/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: 822522aaa1345e4257dc5834ba167a98df411629
|
4
|
+
data.tar.gz: ad850b291f243194c5e8800319ac3d2535cd92aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2730005630d96b88c68afb6878cebd5e225b39819fb993c6236f6a0d089cc73aaa650b6adfbebaf53387e6161b263df59b378e2596622629a0043153ee579893
|
7
|
+
data.tar.gz: 6df62562aa3f1b2213e8accc8f1de45d39b6788f401b33a0f69c9f660700a428f5843e640105917c54992872d294f3c9de083fd8909cf151e474ff3f15632614
|
data/lib/botomizer/client.rb
CHANGED
@@ -42,8 +42,6 @@ class Botomizer::Client
|
|
42
42
|
|
43
43
|
handler = handler.new(self)
|
44
44
|
|
45
|
-
@cache.write("prev_#{chat.id}", message.id)
|
46
|
-
|
47
45
|
if message.cmd?
|
48
46
|
@cache.write(chat.id, message.cmd)
|
49
47
|
else
|
@@ -72,7 +70,11 @@ class Botomizer::Client
|
|
72
70
|
end
|
73
71
|
|
74
72
|
def send_message(text, options = {})
|
75
|
-
bot.send_message(text, options)
|
73
|
+
result = bot.send_message(text, options)
|
74
|
+
|
75
|
+
@cache.write("prev_#{chat.id}", result[:message_id]) if result.has_key?(:message_id)
|
76
|
+
|
77
|
+
result
|
76
78
|
end
|
77
79
|
|
78
80
|
def send_message!(text, options = {})
|
@@ -92,12 +94,8 @@ class Botomizer::Client
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def delete_previous_message
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
def delete_previous_message!
|
99
|
-
result = delete_previous_message
|
100
|
-
raise Botomizer::ResponseError.new(result[:message]) if result[:status] == :failed
|
101
|
-
result
|
97
|
+
if @cache.exists?("prev_#{chat.id}")
|
98
|
+
delete_message(@cache.fetch("prev_#{chat.id}"))
|
99
|
+
end
|
102
100
|
end
|
103
101
|
end
|
data/lib/botomizer/telegram.rb
CHANGED
@@ -41,10 +41,12 @@ module Botomizer::Telegram
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def send(method, query = {})
|
44
|
-
response
|
44
|
+
response = HTTParty.post("#{API_URL}#{@options[:token]}/#{method}", {query: query}).parsed_response
|
45
|
+
result = response['result'] || nil
|
46
|
+
message_id = result.kind_of?(Hash) && result.has_key?('message_id') ? result['message_id'].to_i : nil
|
45
47
|
|
46
48
|
if response['ok']
|
47
|
-
{status: :success,
|
49
|
+
{status: :success, message_id: message_id, message: response['description'], result: result}
|
48
50
|
else
|
49
51
|
{status: :failed, error: response['error_code'], message: response['description']}
|
50
52
|
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.16
|
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-12-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|