コマンドラインでタイムラインマルチポスト(twishr)

twitterとwassrのタイムラインをマルチポストするシェルを更新した。
twissrという名前も既に使われてたんでtwishrとした。

ちなみに設定ファイルは、 ~/.twishrrc で、それぞれのユーザIDとパスワードを

  • -

twitter_user=twitterのユーザID
twitter_pass=twitterのパスワード
wassr_user=wassrのユーザID
wassr_pass=wassrのパスワード

  • -

というふうに書いておく。シェルの内容は以下のとおり。

#!/bin/bash -f
#
# twishr
# update timelines for both twitter and wassr.
#
# This original article is found in issue 175(Nov.2008) of Linux Journal.
# Japanese encoding conversion filter is inserted.
#
ap1=twitter
twitter_update=http://twitter.com/statuses/update.json
ap2=wassr
wassr_update=http://api.wassr.jp/statuses/update.json

myconf=~/.twishrrc
if [ -f $myconf ]
then
. $myconf
fi

msg=$(echo $@ | nkf -w | sed 's/+/%2B/g;s/ /+/g')

if [ "$msg" = "" ]
then
echo "specify your status in argument!"
exit
fi

for i in $ap1 $ap2
do
eval "user=\$${i}_user"
eval "pass=\$${i}_pass"
if [ "$user" = "" ] || [ "$pass" = "" ]
then
echo "set your correct $i account in $myconf"
continue
fi
act="$user:$pass"

api="&source=twishr"
eval "url=\$${i}_update"
curl --silent --user $act --data-ascii status="$msg$api" $url >/dev/null

done

exit 0

※ 参照:twitter api 和訳