Skip to content

Commit

Permalink
- configurable period of time for new message searching
Browse files Browse the repository at this point in the history
- clarify units for --period and --wait
- only consider twits in the last PERIOD of time
  • Loading branch information
rjp committed Jul 8, 2009
1 parent e23169d commit d7c3001
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/twittermoo.rb
Expand Up @@ -12,11 +12,12 @@
:config => ENV['HOME'] + '/.twittermoo',
:verbose => nil,
:once => nil,
:wait => 20
:wait => 20,
:period => 3600
}

OptionParser.new do |opts|
opts.banner = "Usage: twittermoo.rb [-v] [-p port] [-h host] [-d dbfile] [-c config] [-o] [-w N]"
opts.banner = "Usage: twittermoo.rb [-v] [-p port] [-h host] [-d dbfile] [-c config] [-o] [-w N] [-p N]"

opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
$options[:verbose] = v
Expand All @@ -26,10 +27,14 @@
$options[:once] = p
end

opts.on("-w", "--wait N", Integer, "Delay between sending messages") do |p|
opts.on("-w", "--wait N", Integer, "Delay between sending messages (seconds)") do |p|
$options[:wait] = p
end

opts.on("-p", "--period N", Integer, "Time period to check for new messages (seconds)") do |p|
$options[:period] = p
end

opts.on("-p", "--port N", Integer, "irccat port") do |p|
$options[:port] = p
end
Expand Down Expand Up @@ -80,14 +85,14 @@ def log(x)
twitter.friends_timeline().each do |s|
sha1 = SHA1.hexdigest(s.text + s.user.name)
xtime = Time.parse(s.created_at)
threshold = Time.now - 3600
threshold = Time.now - $options[:period]
if xtime < threshold then
already_seen[sha1] = "s"
end
end
end

prev_time = Time.now - 3600
prev_time = Time.now - $options[:period]
log "L entering main loop"
loop {

Expand Down

0 comments on commit d7c3001

Please sign in to comment.