botomizer 0.1.14 → 0.1.15

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: 434d32bee68aab392f92b120521676bbd9ad5116
4
- data.tar.gz: 2b0bf9db9bdc8bc1ecad9dd9f7d16a821afd429f
3
+ metadata.gz: 4671740deec6d2329c21c4490362beb78bb5f1e1
4
+ data.tar.gz: 1957c49d1478ca07df8ba1782f489d6fde6de439
5
5
  SHA512:
6
- metadata.gz: dbf1aaa89104d06185da8fac062b8a01840e239976ae22636b8d7da1318beff509fae6752e58b6f687646ebcb233942dce473f5053590a38f3b35adabd514397
7
- data.tar.gz: 71ae5ea4777518c06cceb8c47d6c91b9eb7e1f52c8e815d79d7afa668250cecae848dfcf62e5619efd5f459d6627db55c39e01adac7cbad3057ed26c3b87986b
6
+ metadata.gz: 0162d0149a1e214492adada0d0ebb805e97ea0b225a50ba883da87768f35f5cca2720db61d57a9fd9a100a22d7500c77d6f4adb0a5f670f78798fc2eb990beb6
7
+ data.tar.gz: 75586edd7237637bab3f2192665361ac8876e945c9440c3c2f1a2f46c35f80133a245244f8ac0ca294079b63730725e7bad1e1c357e29d906c406ff359800981
@@ -17,4 +17,8 @@ class Botomizer::Cache
17
17
  def delete(key)
18
18
  @cache.delete("#{@prefix}_#{key}") if @cache
19
19
  end
20
+
21
+ def exists?(key)
22
+ @cache.exist?("#{@prefix}_#{key}")
23
+ end
20
24
  end
@@ -42,8 +42,10 @@ class Botomizer::Client
42
42
 
43
43
  handler = handler.new(self)
44
44
 
45
- if bot.message.cmd?
46
- @cache.write(bot.chat.id, message.cmd)
45
+ @cache.write("prev_#{chat.id}", message.id)
46
+
47
+ if message.cmd?
48
+ @cache.write(chat.id, message.cmd)
47
49
  else
48
50
  message.cmd = @cache.fetch(chat.id)
49
51
  end
@@ -79,12 +81,22 @@ class Botomizer::Client
79
81
  result
80
82
  end
81
83
 
82
- def delete_message
83
- bot.delete_message
84
+ def delete_message(id = nil)
85
+ bot.delete_message(id)
86
+ end
87
+
88
+ def delete_message!(id = nil)
89
+ result = delete_message(id)
90
+ raise Botomizer::ResponseError.new(result[:message]) if result[:status] == :failed
91
+ result
92
+ end
93
+
94
+ def delete_previous_message
95
+ delete_message(@cache.fetch("prev_#{chat.id}")) if @cache.exists?("prev_#{chat.id}")
84
96
  end
85
97
 
86
- def delete_message!
87
- result = delete_message
98
+ def delete_previous_message!
99
+ result = delete_previous_message
88
100
  raise Botomizer::ResponseError.new(result[:message]) if result[:status] == :failed
89
101
  result
90
102
  end
@@ -54,8 +54,8 @@ module Botomizer::Telegram
54
54
  send(:sendMessage, {chat_id: @chat.id, text: text, parse_mode: 'HTML'}.merge(options))
55
55
  end
56
56
 
57
- def delete_message
58
- send(:deleteMessage, {chat_id: @chat.id, message_id: @message.id})
57
+ def delete_message(id = nil)
58
+ send(:deleteMessage, {chat_id: @chat.id, message_id: id || @message.id})
59
59
  end
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module Botomizer
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: botomizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Belenky