Skip to content

Instantly share code, notes, and snippets.

@secos
Created July 24, 2019 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secos/15bf9986133506ba720339610dd543d1 to your computer and use it in GitHub Desktop.
Save secos/15bf9986133506ba720339610dd543d1 to your computer and use it in GitHub Desktop.
require 'twitter'
require 'json'
require 'hashie'
client = Twitter::REST::Client.new do |config|
# get yer own
end
the_nought = {}
File.readlines("thenoughtcache").each do |l|
status = Hashie::Mash.new JSON.load l
the_nought[status.id] = status
end
puts "Starting cache: #{the_nought.size} tweets"
id = ARGV[0] || "1154065461052616705"
begin
loop do
if !(status = the_nought[id])
status = client.status id
break if status.user.id != 132029493
status = Hashie::Mash.new status.to_h
the_nought[status.id] = status
sleep 0.9 # Twitter API rulez
end
id = status.in_reply_to_status_id
p [the_nought.count, status.created_at, status.text ]
end
rescue => ex
puts ex
end
puts "Final Count: #{the_nought.size}"
File.open("thenoughtcache","w") {|f| the_nought.each {|k,v| f.puts v.to_json }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment