From 77d437d397dbad47c90f1f639b294f362919a3fc Mon Sep 17 00:00:00 2001 From: Jacob Harris Date: Wed, 10 Jul 2013 11:10:53 -0400 Subject: [PATCH] Added support for params to forcibly run and to suppress tweeting --- ebook.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ebook.rb b/ebook.rb index 7f92980..f56c51a 100644 --- a/ebook.rb +++ b/ebook.rb @@ -9,8 +9,10 @@ source_tweets = [] $rand_limit ||= 10 +puts "PARAMS: #{params}" if params.any? + # randomly running only about 1 in $rand_limit times -unless rand($rand_limit) == 0 +unless rand($rand_limit) == 0 || params["force"] puts "Not running this time" else # Fetch a thousand tweets @@ -39,12 +41,12 @@ else 5.times do tweet = markov.generate_sentence - break if !source_tweets.any? {|t| t.text == tweet } + break if tweet.length < 140 && !source_tweets.any? {|t| t.text =~ /#{tweet}/ } end puts "TWEET: #{tweet}" - unless tweet.nil? || tweet == '' + unless tweet.nil? || tweet == '' || !params["tweet"] Twitter.update(tweet) end end