bobby-b 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bobby-b/bobby.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e847c1c23498f8ffd05cbb5cd5c20f04c4ee4ddf2bf49737e6efdddb62609a41
|
|
4
|
+
data.tar.gz: e5b49a9e89b29552f2ed3618fe55993b143d6b4058a79aeeee00254b4965aca3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e74fb2cf15421e31b103d6fc6a4b51af6bd7e1f2231c68338191e3c21586cc798be37c1c92b4ea5283c501a08ac3030bbe70a493c24cfd2e401c13f463c2d2a
|
|
7
|
+
data.tar.gz: 32b06547932753cbc17c80a35dd889c396deb4f7e8c9258870d284efcc47b18f3e2d813d04a5605cedc6bfa023fa6b20da3184773b539ce488d2f94c5c2b7efc
|
data/lib/bobby-b/bobby.rb
CHANGED
|
@@ -33,16 +33,20 @@ class Bobby
|
|
|
33
33
|
puts "Responded with #{response}"
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def process_queue
|
|
37
|
+
now = Time.now.to_f
|
|
38
|
+
return if @queue.empty? || now - @last_message_time < @cooldown
|
|
39
|
+
|
|
40
|
+
send_newest_message
|
|
41
|
+
@last_message_time = now
|
|
42
|
+
end
|
|
43
|
+
|
|
36
44
|
def start_queue
|
|
37
45
|
Thread.new do
|
|
38
46
|
puts 'Message queue started'
|
|
39
47
|
loop do
|
|
40
48
|
sleep 0.1
|
|
41
|
-
|
|
42
|
-
next unless !@queue.empty? && now - @last_message_time >= @cooldown
|
|
43
|
-
|
|
44
|
-
send_newest_message
|
|
45
|
-
@last_message_time = now
|
|
49
|
+
process_queue
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
end
|