Skip to content

Instantly share code, notes, and snippets.

@alyssais
Created March 23, 2018 10:53
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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