mirror of
https://github.com/thewesker/twitter_ebooks.git
synced 2025-12-20 04:11:08 -05:00
@@ -30,8 +30,8 @@ module Ebooks
|
|||||||
end
|
end
|
||||||
|
|
||||||
def log(*args)
|
def log(*args)
|
||||||
STDERR.puts "@#{@username}: " + args.map(&:to_s).join(' ')
|
STDOUT.puts "@#{@username}: " + args.map(&:to_s).join(' ')
|
||||||
STDERR.flush
|
STDOUT.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure
|
def configure
|
||||||
@@ -49,8 +49,10 @@ module Ebooks
|
|||||||
config.oauth_token_secret = @oauth_token_secret
|
config.oauth_token_secret = @oauth_token_secret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
needs_stream = [@on_follow, @on_message, @on_mention, @on_timeline].any? {|e| !e.nil?}
|
||||||
|
|
||||||
@twitter = Twitter::Client.new
|
@twitter = Twitter::Client.new
|
||||||
@stream = TweetStream::Client.new
|
@stream = TweetStream::Client.new if needs_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
# Connects to tweetstream and opens event handlers for this bot
|
# Connects to tweetstream and opens event handlers for this bot
|
||||||
@@ -59,6 +61,12 @@ module Ebooks
|
|||||||
|
|
||||||
@on_startup.call if @on_startup
|
@on_startup.call if @on_startup
|
||||||
|
|
||||||
|
if not @stream
|
||||||
|
log "not bothering with stream for #@username"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
log "starting stream for #@username"
|
||||||
@stream.on_error do |msg|
|
@stream.on_error do |msg|
|
||||||
log "ERROR: #{msg}"
|
log "ERROR: #{msg}"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user