Sha256: 0f1d68781dd437cbdd448410d954d3c23e37137dca265312cb2158c52d5421d1
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
#!/usr/bin/env ruby # Trap interrupts to quit cleanly. See # https://twitter.com/mitchellh/status/283014103189053442 Signal.trap('INT') { abort } require 'oauth' require 't' require 'twitter' # Output message to $stderr, prefixed with the program name def pute(*args) first = args.shift.dup first.insert(0, "#{$PROGRAM_NAME}: ") args.unshift(first) abort(args.join("\n")) end begin T::CLI.start(ARGV) rescue Interrupt pute 'Quitting...' rescue OAuth::Unauthorized pute 'Authorization failed' rescue Twitter::Error::TooManyRequests => error pute error.message, "The rate limit for this request will reset in #{error.rate_limit.reset_in} #{error.rate_limit.reset_in == 1 ? 'second' : 'seconds'}.", 'While you wait, consider making a polite request for Twitter to increase the API rate limit at https://twittercommunity.com/t/discussing-api-v1-1/10180' rescue Twitter::Error::BadRequest => error pute error.message, 'Run `t authorize` to authorize.' rescue Twitter::Error::Forbidden, Twitter::Error::Unauthorized => error if error.message == 'Error processing your OAuth request: Read-only application cannot POST' || error.message == 'This application is not allowed to access or delete your direct messages' $stderr.puts(%q(Make sure to set your Twitter application's Access Level to "Read, Write and Access direct messages".)) require 'thor' Thor::Shell::Basic.new.ask 'Press [Enter] to open the Twitter Developer site.' require 'launchy' Launchy.open('https://dev.twitter.com/apps') { |u, _, _| $stderr.puts "Manually open #{u}" } else pute error.message end rescue Twitter::Error => error pute error.message end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
t-2.8.0 | bin/t |