forked from creutis/RetweetBot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
retweet.rb
32 lines (27 loc) · 843 Bytes
/
retweet.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "rubygems"
require "twitter"
class RetweetBot
#Twitter configuration
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
end
#Retweet tweets with this topic
topic = "#RETWEET_TOPIC"
#Get all my followers
my_followers = client.follower_ids
#Iterate over all my followers
my_followers.each do |follower_id|
#Check the timeline for my follower
client.user_timeline(follower_id, result_type: "recent").each do |tweet|
#If a tweet includes topic - retweet it
if tweet.text.include? topic
client.retweet(tweet.id)
end
end
end
end
#Initilize my retweet bot
my_retweet_bot = RetweetBot.new