lib/streambot.rb in streambot-0.2.1 vs lib/streambot.rb in streambot-0.2.2
- old
+ new
@@ -2,22 +2,28 @@
require 'tweetstream'
require 'retweet'
class StreamBot
- def initialize(auth, *keywords)
+ # initialize method aka constructor
+ def initialize(auth, blacklist=nil, *keywords)
@stream = TweetStream::Client.new(auth[:username],auth[:password])
@retweet = Retweet.new(auth)
@keywords=keywords.join(',')
+ @blacklist=blacklist if !blacklist.nil?
end
+ # starts the bot
def start
@stream.track(@keywords) do |status|
- puts "#{status.text} - #{status.id}"
- @retweet.retweet(status.id)
+ if !@blacklist.include?(status.user)
+ #puts "#{status.text} - #{status.id}"
+ @retweet.retweet(status.id)
+ end
end
end
+ # stop bot
def stop
@stream.stop
end
end