Skip to content

Instantly share code, notes, and snippets.

@steinuil
Last active August 29, 2015 14:23
Show Gist options
  • Save steinuil/65bebad8f85a7feb231a to your computer and use it in GitHub Desktop.
Save steinuil/65bebad8f85a7feb231a to your computer and use it in GitHub Desktop.
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
if ARGV[1].nil?
puts <<EOF
Usage: ruby twitter-avatar-changer.rb [FREQUENCY] [DIRECTORY]
The frequency is a number from 1 to 12 which determines how many times a day
should the avatar change.
The pictures directory should only contain png, gif or jpg files under 700kb.
EOF
exit
end
frequency = ARGV[0].to_i
directory = ARGV[1]
img_list = []
loop do
img_list = Dir.glob(directory + "/*").shuffle if img_list.empty?
image = File.new(img_list.first)
img_list = img_list.drop(1)
client.update_profile_image(image, options = {})
sleep(24 * 60 * 60 / frequency)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment