Only read recent twits
authorJoachim Breitner <mail@joachim-breitner.de>
Sat, 27 Jun 2009 14:13:26 +0000 (16:13 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Sat, 27 Jun 2009 14:13:26 +0000 (16:13 +0200)
twitreader.sh

index c387d33..efc6c1d 100755 (executable)
@@ -1,16 +1,21 @@
-while sleep 10;
+while sleep 30;
 do
-GET "http://search.twitter.com/search.atom?q=%23GPN8&rpp=1" > msg.atom 
-echo -n \
-$(echo $(
-       xpath -q -e '//author/name/text()' msg.atom  |
-       lynx -dump -stdin|lynx -dump -stdin -nolist |
-       cut -d\( -f1
-))\
-"@twitter:" \
-$(
-       xpath -q -e '//content/text()' msg.atom  |
-       lynx -dump -stdin|lynx -dump -stdin -nolist
-) \
- > msg.txt
+GET "http://search.twitter.com/search.atom?q=%23GPN8&rpp=1&since_id=$(cat msg.id)" > msg.atom 
+if xpath -q -e "//entry" msg.atom |grep -q .
+then
+       xpath -q -e "//entry/id/text()" msg.atom |cut -d: -f3 > msg.id
+       echo -n \
+       $(echo $(
+               xpath -q -e '//author/name/text()' msg.atom  |
+               lynx -dump -stdin|lynx -dump -stdin -nolist |
+               cut -d\( -f1
+       ))"@twitter:" \
+       $(
+               xpath -q -e '//content/text()' msg.atom  |
+               lynx -dump -stdin|lynx -dump -stdin -nolist
+       ) \
+        > msg.txt
+else
+       echo -n > msg.txt
+fi
 done