Created
July 24, 2019 18:58
-
-
Save secos/15bf9986133506ba720339610dd543d1 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 '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