Created
March 23, 2018 10:53
-
-
Save alyssais/22eb17e83ee2c2e455ecd68bf0b48256 to your computer and use it in GitHub Desktop.
My really hacky livetweeting script. You pass in the ID of the tweet to continue the thread from.
This file contains 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 "yaml" | |
require "twitter" | |
config = YAML.load_file(File.expand_path("~/.trc")).dig("profiles", "qyliss").each_value.first | |
last_status = ARGV.fetch(0) | |
twitter = Twitter::REST::Client.new do |t| | |
t.consumer_key = config.fetch("consumer_key") | |
t.consumer_secret = config.fetch("consumer_secret") | |
t.access_token = config.fetch("token") | |
t.access_token_secret = config.fetch("secret") | |
end | |
loop do | |
file = Tempfile.new("tweet") | |
file.write(" #BathRuby") | |
file.close | |
system ENV.fetch("EDITOR"), file.path | |
text = File.read(file.path) | |
file.unlink | |
break unless text[/\S/] | |
begin | |
last_status = twitter.update(text, in_reply_to_status_id: last_status).tap { |tweet| | |
puts tweet.text | |
puts tweet.id | |
}.id | |
rescue | |
retry | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is really cool!!