streambot 0.5.0.beta3 → 0.5.0.beta4
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.
- data/lib/streambot/filter.rb +35 -0
- data/lib/streambot/handler.rb +1 -1
- data/lib/streambot/tracker.rb +5 -2
- metadata +4 -3
@@ -0,0 +1,35 @@
|
|
1
|
+
module StreamBot
|
2
|
+
class Filter
|
3
|
+
USER="USER"
|
4
|
+
CONTENT="CONTENT"
|
5
|
+
LANGUAGE="LANGUAGE"
|
6
|
+
TIMEZOME="TIMEZONE"
|
7
|
+
|
8
|
+
def initialize(filters=nil, blacklist=nil)
|
9
|
+
@filters = filters
|
10
|
+
if (!@blacklist.nil?)
|
11
|
+
warn "blacklisting is deprecated and will be removed in 0.6.0"
|
12
|
+
end
|
13
|
+
@blacklist = blacklist
|
14
|
+
end
|
15
|
+
|
16
|
+
def match?(status)
|
17
|
+
username = status.user.screen_name
|
18
|
+
if (@blacklist.nil? || !@blacklist.include?(username)) && !@filters.nil?
|
19
|
+
@filters.each do |key, value|
|
20
|
+
@type = filter["type"]
|
21
|
+
@value = filter["value"]
|
22
|
+
if @type == USER then
|
23
|
+
status.user.screen_name.eql?(@value)
|
24
|
+
elsif @type == CONTENT then
|
25
|
+
status.text.include?(@value)
|
26
|
+
elsif @type == LANGUAGE then
|
27
|
+
status.user.lang.eql?(@value)
|
28
|
+
elsif @type == TIMEZONE then
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/streambot/handler.rb
CHANGED
data/lib/streambot/tracker.rb
CHANGED
@@ -40,12 +40,13 @@ module StreamBot
|
|
40
40
|
if (@blacklist.nil? || !@blacklist.include?(username)) && !@filters.nil?
|
41
41
|
@filters.each do |key, value|
|
42
42
|
matched = match?(status, value)
|
43
|
-
|
43
|
+
puts matched
|
44
|
+
if matched == true
|
44
45
|
match_filter
|
45
46
|
LOG.debug("Tracker#start - filter #{key} matched!")
|
46
47
|
end
|
47
48
|
end
|
48
|
-
if
|
49
|
+
if matched == false
|
49
50
|
before_retweet
|
50
51
|
LOG.debug("Tracker#start - retweet ##{status.id} from @#{username}")
|
51
52
|
@retweet.retweet(status.id)
|
@@ -64,6 +65,8 @@ module StreamBot
|
|
64
65
|
status.text.include?(@value)
|
65
66
|
elsif @type == "LANGUAGE" then
|
66
67
|
status.user.lang.eql?(@value)
|
68
|
+
elsif @type == "SOURCE" then
|
69
|
+
status.source.eql?(@value)
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 5
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.5.0.
|
9
|
+
- beta4
|
10
|
+
version: 0.5.0.beta4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sascha Wessel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-23 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- Rakefile
|
107
107
|
- lib/streambot.rb
|
108
108
|
- lib/streambot/callbacks.rb
|
109
|
+
- lib/streambot/filter.rb
|
109
110
|
- lib/streambot/handler.rb
|
110
111
|
- lib/streambot/http.rb
|
111
112
|
- lib/streambot/oauth.rb
|