🔙 Back to Top

Wed Jun 8 23:04:34 JST 2016

メモ用のTwitterアカウント

家計簿用のTwitterアカウント

#!/bin/bash

USER=cupfh
PREV=$(twurl accounts | grep -B 1 default | head -1)
twurl set default $USER

twurl "/1.1/statuses/user_timeline.json?screen_name=${USER}&count=20" > /tmp/tmp.json
ruby -r json -r date -e 'tws=JSON.parse(open("/tmp/tmp.json").read());tws.each{|tw|t=tw["text"];if /^[0-9]* /.match(t);d=DateTime.parse(tw["created_at"])+9/24.0;puts "#{"0#{d.month}"[-2..-1]}#{"0#{d.day}"[-2..-1]}   #{t.sub(" ","\t")}";STDERR.puts tw["id_str"];end}' >/tmp/ls 2>/tmp/ids

while read ID; do
  twurl -XPOST "/1.1/statuses/destroy/${ID}.json" >/dev/null
done </tmp/ids

cat /tmp/ls

twurl set default "$PREV"

N.B.