#!/bin/sh

start_year=2004
cur_year=`date +%Y`
name=nazwa-bloga

mkdir $HOME/.blogcomments 2>/dev/null
rm -f $HOME/.blogcomments/$name.mail

for y in `seq $start_year $cur_year`; do
	for m in `seq 1 12`; do
		wget http://$name.blog.pl/archiwum/?rok=$y\&miesiac=$m -O - \
		    -o /dev/null \
		    | grep "^<a href=\"http://$name\.blog\.pl/komentarze/index\.php?nid=" \
		    > $HOME/.blogcomments/$name.$y.$m.new
		diff -u0 $HOME/.blogcomments/$name.$y.$m \
		    $HOME/.blogcomments/$name.$y.$m.new >> \
		    $HOME/.blogcomments/$name.mail
		mv $HOME/.blogcomments/$name.$y.$m.new \
		    $HOME/.blogcomments/$name.$y.$m
	done
done

[ -s $HOME/.blogcomments/$name.mail ] && cat $HOME/.blogcomments/$name.mail \
    | mail -s Raport\ komentarzy gophi
