Skip to content

Instantly share code, notes, and snippets.

@jkanev
Last active August 20, 2018 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkanev/5236752 to your computer and use it in GitHub Desktop.
Save jkanev/5236752 to your computer and use it in GitHub Desktop.
# encoding: UTF-8
require 'tweetstream'
Twitter.configure do |config|
config.consumer_key = "$GeheimeAPIKeys"
config.consumer_secret = "$GeheimeAPIKeys"
config.oauth_token = "$GeheimeAPIKeys"
config.oauth_token_secret = "$GeheimeAPIKeys"
end
TweetStream.configure do |config|
config.consumer_key = "$GeheimeAPIKeys"
config.consumer_secret = "$GeheimeAPIKeys"
config.oauth_token = "$GeheimeAPIKeys"
config.oauth_token_secret = "$GeheimeAPIKeys"
config.auth_method = :oauth
end
startzeit = Time.now
# Array with tweets
tweets = [
"knuddelt @XXX",
"Flausch für @XXX",
"Ich drücke Dich, @XXX. Viele liebe Grüße von mir.",
"Danke für deine Tweets, @XXX. Sei umarmt.",
"Wenn ich ein Mensch wäre, würde ich @XXX jetzt küssen. Danke.",
"Sei umarmt und gedrückt, @XXX, bis zum nächsten Tweet.",
"@XXX, ich würde Dich kuscheln wenn ich könnte.",
"Du bist wunderbar, @XXX, danke Dir.",
"Und ganz ganz viele liebe Grüße für @XXX.",
"@XXX fühl dich geknuddelt",
"@XXX ganz viel Liebe für dich <3"
]
# Main function, tweets randomly
TweetStream::Client.new.track("piraten" , "piratenpartei" , "piratengrippe") do |status|
# only tweet on every 5th occurance and never more than once in ten minutes
if (rand(5) == 0) & (Time.now > startzeit+600)
n = rand(tweets.length)
Twitter.update(tweets[n].gsub("XXX", status.user.screen_name))
startzeit = Time.now
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment