Sha256: 777066c03b2fe19353a5747267b80d4d2a0336f264f1a56f4304b8ec12413f9f

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

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

Twitter.command_line_login
tweeted = CableGator.save_file("~/.cablegator/tweeted_fmt_#{ARGV[0].to_s.gsub(/:| /,'')}")

puts "Tweeting cables" 
WikiLeaks.with_each_cable_data do |cable_data|
  reference_id = cable_data['reference_id']

  if tweeted.include?(reference_id)
    puts "Already tweeted #{reference_id}"
  else
    format_string = ARGV[0].to_s.dup
    cable_data.each { |k,v| format_string.gsub!(/\:#{k}/,v) }

    tweet = "#cablegate ##{reference_id} #{format_string}"
    
    puts "Tweeting: #{tweet}"
    begin 
      Twitter.update(tweet) 
      tweeted << reference_id
      delay = ARGV[1].to_i rescue nil
      sleep(delay || 10)
    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_format
cablegator-0.9.9 bin/tweet_cables_format