Created
February 27, 2016 00:40
-
-
Save mindplace/d7ad80bf2b5e539a643c 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
require 'jumpstart_auth' | |
require 'bitly' | |
class MicroBlogger | |
attr_reader :client | |
def initialize | |
@client = JumpstartAuth.twitter | |
end | |
def tweet | |
puts "\nWhat would you like to tweet?" | |
print "> " | |
message = gets.chomp | |
if message.length < 140 | |
@client.update(message) | |
puts "Tweet posted!" | |
else puts "Tweet too long to post" | |
end | |
end | |
def send_dm(username) | |
print "\nMessage: " | |
message = "d #{username} #{gets.chomp}" | |
if message.length < 140 | |
@client.update(message) | |
puts "Message sent!" | |
else puts "Message too long to send" | |
end | |
end | |
def route_dm | |
puts "\nFriends: #{friends.join(", ")}" | |
print "\nSend message to: " | |
target = gets.chomp | |
if friends.include?(target) | |
sending_to_target = MicroBlogger.new | |
sending_to_target.send_dm(target) | |
else puts "Sorry, can't DM someone who isn't your friend!" | |
end | |
end | |
def friends | |
client.followers.map{|person| client.user(person).screen_name} | |
end | |
def get_all_latest_friends_tweets | |
client.followers.each do |friend| | |
puts | |
puts client.user(friend).screen_name | |
puts client.user(friend).status.text | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment