mirror of
https://github.com/thewesker/iron_ebooks.git
synced 2025-12-20 12:21:14 -05:00
Added support for params to forcibly run and to suppress tweeting
This commit is contained in:
8
ebook.rb
8
ebook.rb
@@ -9,8 +9,10 @@ source_tweets = []
|
|||||||
|
|
||||||
$rand_limit ||= 10
|
$rand_limit ||= 10
|
||||||
|
|
||||||
|
puts "PARAMS: #{params}" if params.any?
|
||||||
|
|
||||||
# randomly running only about 1 in $rand_limit times
|
# 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"
|
puts "Not running this time"
|
||||||
else
|
else
|
||||||
# Fetch a thousand tweets
|
# Fetch a thousand tweets
|
||||||
@@ -39,12 +41,12 @@ else
|
|||||||
|
|
||||||
5.times do
|
5.times do
|
||||||
tweet = markov.generate_sentence
|
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
|
end
|
||||||
|
|
||||||
puts "TWEET: #{tweet}"
|
puts "TWEET: #{tweet}"
|
||||||
|
|
||||||
unless tweet.nil? || tweet == ''
|
unless tweet.nil? || tweet == '' || !params["tweet"]
|
||||||
Twitter.update(tweet)
|
Twitter.update(tweet)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user