Skip to content

Instantly share code, notes, and snippets.

@alyssais
Created March 23, 2018 10:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alyssais/22eb17e83ee2c2e455ecd68bf0b48256 to your computer and use it in GitHub Desktop.
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.
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
@djbender
Copy link

This is really cool!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment