#!/bin/sh

# generates static versions of griefer warning and ban lists

wwwroot=http://dedcon.homelinux.net:8000/dedcon_grief

# first, fetch the griefer list
wget $wwwroot/wiki/TheList?format=txt -O globalbans.txt -o err.txt

# usage: GetReport <report ID>
function GetReport()
{
   for f in $( wget $wwwroot/report/$1?format=tab -O - -o err.txt | tail -n +2 ); do echo $f; done
}

# usage: Ban <report ID for keyID> <report ID for IP> <file>
function Ban()
{
   GetReport $1 | sed -e "s,^,BanKeyID ," >  $3.new
   GetReport $2 | sed -e "s,^\(.*\):,BanIPRange \1:," -e "s,^\(.*\)/,BanIPRange \1:," -e "t" -e "s,^,BanIP ," >> $3.new
   rm -f $3
   mv $3.new $3
}

# usage: Warn <report ID for keyID> <report ID for IP> <message> <file> <include file>
function Warn()
{
   GetReport $1 | sed -e "s/^\([0-9]*\)/MessageKeyID \1 $3/" > $4.new
   #GetReport $2 | sed -e "s/^\([0-9\.]*\)/MessageIP \1 $3/" >> $4.new
   test -z "$5" || cat $5 >> $4.new
   rm -f $4
   mv $4.new $4
}

#Ban 10 14 ban_annoyance.txt
Ban 11 15 ban_pest.txt
Ban 12 16 ban_nemesis.txt
Ban 13 17 ban_larry.txt

Warn 13 17 "WARNING: you have been added to the griefer database and there is consensus by the maintainers that you are a total ass. You probably already are banned from most servers. Watch what you are doing or risk getting banned here, too. Changing your name won't help, by the way." warn_larry.txt
Warn 20 23 "WARNING: you have been added to the griefer database on the 'nemesis' level.You probably already are banned from many servers. Watch what you are doing or risk getting banned here, too. Changing your name won't help, by the way." warn_nemesis.txt warn_larry.txt
Warn 19 22 "WARNING: you have been added to the griefer database on the 'pest' level. Watch what you are doing or risk getting banned on many servers. Changing your name won't help, by the way." warn_pest.txt warn_nemesis.txt
Warn 18 21 "WARNING: you have been added to the griefer database on the 'annoyance' level. You're not in immediate danger of getting banned anywhere, but you should watch what you are doing anyway. Changing your name won't help, by the way." warn_annoyance.txt warn_pest.txt
