Skip to content

Instantly share code, notes, and snippets.

@pnlybubbles
Created March 9, 2013 08:45
Show Gist options
  • Save pnlybubbles/5123524 to your computer and use it in GitHub Desktop.
Save pnlybubbles/5123524 to your computer and use it in GitHub Desktop.
Rubyの投稿専用クライアント(CUI) ・Requirement: Twitter gem ・コンスマなどは自分で ・140文字自動分割 ・フッター設定(例 foot:#yuruyuri) ・ぐちゃぐちゃ
# encoding: utf-8
require 'twitter'
Twitter.configure do |config|
config.consumer_key = ''
config.consumer_secret = ''
config.oauth_token = ''
config.oauth_token_secret = ''
end
puts "#### post only twitter client t.rb ####"
def t() $o||="";loop{((x=gets.chomp.strip).empty?.!&&(x=~/^foot:/).nil?) ? h=Thread.new{catch(:s){loop{(Twitter.update((x.length-(c||=0)*(140-((f=$o.empty?.!) ? l=1+$o.length : 0)))>0 ? lambda{c+=1;return x[(c-1)*140,140-(f ? l : 0)]+(f ? " "+$o : "")}.call : lambda{puts "=> tweet with separating" if c>1;throw :s}.call));redo}} rescue puts "=> error: #{$!}"} : (($o=x.gsub(/foot:/,"");puts "=> footer: #{$o}") if x=~/^foot:/)};end
t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment