#!/bin/bash #### NetHack Google Abuser v. 0.6 #### # by Stanislav Traykov # # The NetHack Google Abuser displays some YAFAP and YAAP statistics. # It requires bash and nc (netcat). # # Changes: # 0.6 - added filter and num for more accurate results # - added sleeping gaver=0.6 #CONFIG------------ # location of Dylan O'Donnell's gods spoiler for name lookup godspoil="/home/glimz/documents/nhspoilers/gods-342.txt" # netcat program netcat=nc # sleep between queries? dosleep=false # if you don't like the defaults, uncomment and change the following: # sleep=sleep #sleep command # sleep_amount=0.5 #seconds #end CONFIG-------- firstq=false roles="Arc Bar Cav Hea Kni Mon Pri Rog Ran Sam Tou Val Wiz" alignments="Cha Neu Law" sclasses="$roles $alignments" newsgrp="rec.games.roguelike.nethack" search="GET /groups?num=100&filter=0&q=group%%3A${newsgrp}" insub="insubject%%3A" exclRe="-${insub}re" exclAln=`eval "echo -${insub}{\`echo -n $alignments|sed 'y/ /,/'\`} | sed 'y/ /+/'"` lookupGod() { if [ -r "$godspoil" ]; then echo `grep -A3 $1 $godspoil | grep "^$2" | sed "s/.*: *\([A-Za-z ]*\).*/\1/"` else echo "$1$2" fi } google() { $dosleep && $firstq && ${sleep:-sleep} ${sleep_amount:-0.5} echo `\ printf "$* HTTP/1.0\n\n" \ | $netcat groups.google.com 80 \ | (grep "^\([0-9]*\).*#\2#"` } gtotal=0 echo gabuse $gaver echo Ascension posts in $newsgrp / `date` echo for atype in YA{F,}AP; do total=0 echo "*** $atype ***" for class in $sclasses; do num=`google $search+$insub$atype+$insub$class+$exclRe` firstq=true echo -n "$class: $num" if echo "$roles" | grep -q "$class"; then let total=$num+$total printf " \t" for aln in $alignments; do num=`google $search+$insub$atype+$insub$class+$insub$aln+$exclRe` printf "\t" [ $num != none ] && echo -n "$aln: $num" let $atype$class$aln=num done else let $class=$class+$num fi echo done #google accepts 10 args so we use alignment to exclude laconic YAFAP nospec=`google $search+$insub$atype+$exclRe+$exclAln` echo "bad subject format: $nospec" let total=$nospec+$total let gtotal=$total+$gtotal echo "Total: $total"; echo done echo "*** Summary ***" amax=0 for aln in $alignments; do echo Total $aln: ${!aln} for class in $roles; do yaap=YAAP$class$aln yafap=YAFAP$class$aln let t=yaap+yafap if [ $t -ge $amax ]; then godclass=$class; godaln=$aln; amax=$t fi done done echo echo "Happiest God: `lookupGod $godclass $godaln` ($amax)" echo echo "Total ascensions (formatted & unformatted): $gtotal"