Last active
August 20, 2018 17:11
-
-
Save jkanev/5236752 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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