Tw

Twitter client on Ruby.

Download .zip Download .tar.gz View on GitHub

INSTALL:

% gem install tw

SYNOPSIS:

show help

% tw --help

Tweet

% tw hello world
% echo 'hello work' | tw --pipe

read Timeline

% tw @username
% tw @username @user2 @user3
% tw @username/listname
% tw --timeline
% tw --search=ruby

Stream

% tw --stream
% tw --stream:filter=ruby,java --silent

DM

% tw --dm
% tw --dm:to=shokai "hello!"
% echo `date` | tw --dm:to=shokai --pipe

Reply/Fav/RT

% tw @shokai --id
% tw "@shokai wow!!" --id=334749349588377601
% tw --fav=334749349588377601
% tw --rt=334749349588377601

Format

#{user} , #{text} , #{id} , #{time} , #{url}
% tw --format=json
% tw --stream --format="@#{user} #{text} - #{url}"

Switch Accounts

% tw --user:add
open http://twitter.com/oauth/authorize?oauth_token=a1b2cDEF3456gh78
input PIN Number: 19283746
add "@user2"
% tw --user:list
* shokai
  user2
  user3
(3 users)
% tw I am user2  --user=user2
% echo "this is bot tweet" | tw --user=user3 --pipe
% tw --timeline --user=user2
% tw @shokai @user3 --user=user2
% tw --user:default=user2
set default user "@user2"

Recipes

HashTag Radio

Speech hashtag on Mac.
% tw --silent --stream:filter=hashtag1,tag2,tag3 --format="#{text}" | xargs -n1 say

Twitter Reply Bot : Search Stream then Tweet "OK"

--stream, --silent, --format and --pipe.
% tw --silent --stream:filter=BOT_NAME --user=BOT_NAME --format="@#{user} OK" | tw --pipe --user=BOT_NAME

DM when heavy Task finished

% make build && echo 'build success!!' | tw --pipe --dm:to=shokai --user=shokai_log

Morning Call

crontab -e
0 8 * * * echo "@shokai Wake up `/bin/date`" | tw --pipe --user=shokai_log

Read Config File

cat $HOME/tw.yml

Internal API Usage

see samples.