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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4671740deec6d2329c21c4490362beb78bb5f1e1
4
- data.tar.gz: 1957c49d1478ca07df8ba1782f489d6fde6de439
3
+ metadata.gz: 822522aaa1345e4257dc5834ba167a98df411629
4
+ data.tar.gz: ad850b291f243194c5e8800319ac3d2535cd92aa
5
5
  SHA512:
6
- metadata.gz: 0162d0149a1e214492adada0d0ebb805e97ea0b225a50ba883da87768f35f5cca2720db61d57a9fd9a100a22d7500c77d6f4adb0a5f670f78798fc2eb990beb6
7
- data.tar.gz: 75586edd7237637bab3f2192665361ac8876e945c9440c3c2f1a2f46c35f80133a245244f8ac0ca294079b63730725e7bad1e1c357e29d906c406ff359800981
6
+ metadata.gz: 2730005630d96b88c68afb6878cebd5e225b39819fb993c6236f6a0d089cc73aaa650b6adfbebaf53387e6161b263df59b378e2596622629a0043153ee579893
7
+ data.tar.gz: 6df62562aa3f1b2213e8accc8f1de45d39b6788f401b33a0f69c9f660700a428f5843e640105917c54992872d294f3c9de083fd8909cf151e474ff3f15632614
@@ -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
- delete_message(@cache.fetch("prev_#{chat.id}")) if @cache.exists?("prev_#{chat.id}")
96
- end
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
@@ -41,10 +41,12 @@ module Botomizer::Telegram
41
41
  end
42
42
 
43
43
  def send(method, query = {})
44
- response = HTTParty.post("#{API_URL}#{@options[:token]}/#{method}", {query: query}).parsed_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, result: response['result'], message: response['description']}
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
@@ -1,3 +1,3 @@
1
1
  module Botomizer
2
- VERSION = '0.1.15'
2
+ VERSION = '0.1.16'
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.15
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-02 00:00:00.000000000 Z
11
+ date: 2017-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler