streambot 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -4
- data/lib/retweet.rb +2 -0
- data/lib/streambot.rb +9 -3
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
= streambot
|
2
2
|
|
3
|
-
streambot is using (http://github.com/intridea/tweetstream) for simple access to twitter streaming api
|
4
|
-
streambot is still far away from production usage
|
3
|
+
streambot is using tweetstream (http://github.com/intridea/tweetstream) for simple access to twitter streaming api
|
5
4
|
|
6
5
|
== Installation
|
7
6
|
|
7
|
+
the streambot gem is available on rubygems.org - http://rubygems.org/gems/streambot
|
8
|
+
|
8
9
|
gem install streambot
|
9
10
|
|
10
11
|
== Usage
|
11
12
|
|
12
13
|
require 'streambot'
|
13
14
|
|
14
|
-
|
15
|
+
@auth = {:username=>'username',:password=>'password'}
|
16
|
+
@blacklist = ['mac_rt','apple_rt']
|
17
|
+
bot = StreamBot.new(@auth, @blacklist, 'apple','ipad','iphone os 4','steve jobs')
|
15
18
|
bot.start
|
16
19
|
|
17
20
|
== Todo
|
18
21
|
|
19
|
-
|
22
|
+
All todos are listed in issue-tracker and labeled with todo (http://github.com/gr4y/streambot/issues/labels/todo)
|
20
23
|
|
21
24
|
== Note on Patches/Pull Requests
|
22
25
|
|
data/lib/retweet.rb
CHANGED
@@ -3,11 +3,13 @@ require 'open-uri'
|
|
3
3
|
|
4
4
|
class Retweet
|
5
5
|
|
6
|
+
# intitialize method aka constructor
|
6
7
|
def initialize(auth)
|
7
8
|
return if auth.nil?
|
8
9
|
@auth = auth
|
9
10
|
end
|
10
11
|
|
12
|
+
# retweets the status with given id
|
11
13
|
def retweet(id)
|
12
14
|
url = URI.parse("http://api.twitter.com/1/statuses/retweet/#{id}.json")
|
13
15
|
req = Net::HTTP::Post.new(url.path)
|
data/lib/streambot.rb
CHANGED
@@ -4,19 +4,25 @@ require 'retweet'
|
|
4
4
|
|
5
5
|
class StreamBot
|
6
6
|
|
7
|
-
|
7
|
+
# initialize method aka constructor
|
8
|
+
def initialize(auth, blacklist=nil, *keywords)
|
8
9
|
@stream = TweetStream::Client.new(auth[:username],auth[:password])
|
9
10
|
@retweet = Retweet.new(auth)
|
10
11
|
@keywords=keywords.join(',')
|
12
|
+
@blacklist=blacklist if !blacklist.nil?
|
11
13
|
end
|
12
14
|
|
15
|
+
# starts the bot
|
13
16
|
def start
|
14
17
|
@stream.track(@keywords) do |status|
|
15
|
-
|
16
|
-
|
18
|
+
if !@blacklist.include?(status.user)
|
19
|
+
#puts "#{status.text} - #{status.id}"
|
20
|
+
@retweet.retweet(status.id)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
25
|
+
# stop bot
|
20
26
|
def stop
|
21
27
|
@stream.stop
|
22
28
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sascha Wessel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-13 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|