fuck_facebook 0.5.2 → 0.5.3
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/Gemfile.lock +1 -1
- data/lib/fuck_facebook/version.rb +1 -1
- data/src/fb_duration.rb +15 -4
- data/src/message_handler.rb +5 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 328dfd9c415343629b2aeb3f83e6252fa2ee0c882be23f441442e0170781a0e0
|
|
4
|
+
data.tar.gz: 13369d4a2a3bb32d672385cb47776cdfd37ecb8159c2314d78cefb52ae0376fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 111cd999cfa8dddbfbb72c36ace0dbed922b57a0ed653c3726541bba8f2a17f1bdfc4188e832a07cb6e0cf46938e52218e1973a9ab4b2dce92453d018e2fefee
|
|
7
|
+
data.tar.gz: 44d2fa65bb1b48e4f2294cb314cdd63609135fd4b028e929937f4141064563acba59ec1db3552459d22c92e151d9c42b85941ebd1e423235e67d510880522283
|
data/Gemfile.lock
CHANGED
data/src/fb_duration.rb
CHANGED
|
@@ -3,29 +3,40 @@ require 'active_support/core_ext/numeric/time'
|
|
|
3
3
|
class FbDuration
|
|
4
4
|
DURATION_LETTER_TO_METHOD = {
|
|
5
5
|
'm' => :minutes,
|
|
6
|
-
'd' => :days,
|
|
7
6
|
'h' => :hours,
|
|
7
|
+
'd' => :days,
|
|
8
8
|
'w' => :weeks,
|
|
9
9
|
'y' => :years
|
|
10
10
|
}.freeze
|
|
11
11
|
|
|
12
12
|
DURATION_LETTER_TO_BEGINNING_OF_METHOD = {
|
|
13
13
|
'm' => :beginning_of_minute,
|
|
14
|
-
'd' => :beginning_of_day,
|
|
15
14
|
'h' => :beginning_of_hour,
|
|
15
|
+
'd' => :beginning_of_day,
|
|
16
16
|
'w' => :beginning_of_week,
|
|
17
17
|
'y' => :beginning_of_year
|
|
18
18
|
}.freeze
|
|
19
19
|
|
|
20
|
+
# TODO: Fill in d w y extra time to add
|
|
21
|
+
EXTRA_TIME_TO_ADD_TO_FIX_ROUNDING = {
|
|
22
|
+
'm' => 0,
|
|
23
|
+
'h' => 5.minutes,
|
|
24
|
+
'd' => 0,
|
|
25
|
+
'w' => 0,
|
|
26
|
+
'y' => 0
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
def self.parse_to_time(facebook_format_duration)
|
|
21
30
|
duration = parse(facebook_format_duration)
|
|
22
31
|
time_to_beginning_of_duration_letter(Time.now - duration, facebook_format_duration)
|
|
23
32
|
end
|
|
24
33
|
|
|
25
34
|
def self.parse(facebook_format_duration)
|
|
26
|
-
|
|
35
|
+
number, duration_letter = facebook_format_duration.split
|
|
36
|
+
|
|
37
|
+
extra_rounding_time = EXTRA_TIME_TO_ADD_TO_FIX_ROUNDING[duration_letter]
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
number.to_i.send(DURATION_LETTER_TO_METHOD[duration_letter]) + extra_rounding_time
|
|
29
40
|
end
|
|
30
41
|
|
|
31
42
|
def self.time_to_beginning_of_duration_letter(time, facebook_format_duration)
|
data/src/message_handler.rb
CHANGED
|
@@ -53,12 +53,13 @@ class MessageHandler
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def messages_after_last_message_time(messages)
|
|
56
|
-
|
|
57
|
-
last_check_time_with_buffer = last_message_check_time - 5.minutes
|
|
56
|
+
last_message_time = Storage.get(:last_message_time, default: Time.new(2004, 2, 4))
|
|
58
57
|
|
|
59
|
-
messages_to_return = messages.select { _1.timestamp >
|
|
58
|
+
messages_to_return = messages.select { _1.timestamp > last_message_time }
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
last_message_time = messages.map(&:timestamp).max
|
|
61
|
+
|
|
62
|
+
Storage.set(:last_message_time, last_message_time)
|
|
62
63
|
|
|
63
64
|
messages_to_return
|
|
64
65
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fuck_facebook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keeyan Nejad
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-12-
|
|
11
|
+
date: 2021-12-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|