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 +4 -4
- data/lib/botomizer/cache.rb +4 -0
- data/lib/botomizer/client.rb +18 -6
- data/lib/botomizer/telegram.rb +2 -2
- data/lib/botomizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4671740deec6d2329c21c4490362beb78bb5f1e1
|
4
|
+
data.tar.gz: 1957c49d1478ca07df8ba1782f489d6fde6de439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0162d0149a1e214492adada0d0ebb805e97ea0b225a50ba883da87768f35f5cca2720db61d57a9fd9a100a22d7500c77d6f4adb0a5f670f78798fc2eb990beb6
|
7
|
+
data.tar.gz: 75586edd7237637bab3f2192665361ac8876e945c9440c3c2f1a2f46c35f80133a245244f8ac0ca294079b63730725e7bad1e1c357e29d906c406ff359800981
|
data/lib/botomizer/cache.rb
CHANGED
data/lib/botomizer/client.rb
CHANGED
@@ -42,8 +42,10 @@ class Botomizer::Client
|
|
42
42
|
|
43
43
|
handler = handler.new(self)
|
44
44
|
|
45
|
-
|
46
|
-
|
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
|
87
|
-
result =
|
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
|
data/lib/botomizer/telegram.rb
CHANGED
@@ -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
|
data/lib/botomizer/version.rb
CHANGED