Sha256: ab08c8c3b0f47e23ab218a6d55cf2949353930bc7829ccf380cdcff9d2f98f0d

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

#! /usr/bin/env ruby
require 'twitter'
require 'cablegator'
require 'cablegator/twitter'

Twitter.command_line_login
tweeted = CableGator.save_file("~/.cablegator/tweeted")

puts "Tweeting cables" 
WikiLeaks.with_each_cable do |cable_url|
  reference_id = WikiLeaks.reference_id(cable_url) 
  if tweeted.include?(reference_id)
    puts "Already tweeted #{reference_id}"
  else
    tweet = "#cablegate ##{reference_id} #{WikiLeaks.base_uri + cable_url}"
    puts "Tweeting: #{tweet}"
    begin 
      Twitter.update(tweet) 
      tweeted << reference_id
      delay = ARGV[0].to_i rescue nil
      sleep(delay || 1)
    rescue 
      "Tweet #{reference_id} failed"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cablegator-1.0.0 bin/tweet_cables
cablegator-0.9.9 bin/tweet_cables