use XML::Simple; sub stat_handler; $sfile = ("/tmp/Azureus_Stats.xml"); IRC::register ("AzStat", "1.3.1", "", ""); IRC::print "::Azureus Stat Announcer v1.3.1:: [Loaded]"; IRC::print "Commands: "; IRC::print " /az : Announce your azureus throughput to the current channel. As if anyone cares. "; IRC::add_command_handler("az", "stat_handler"); sub stat_handler { my $file = XMLin($sfile); #open the stats file into a variable $version = $file->{AZUREUS_VERSION}; #The version of azureus is dragged from the xml if ( $file->{DOWNLOADS}->{DOWNLOAD} != 0 ) { #continue only if there are downloads in the stats file $tdspeed = $file->{GLOBAL}->{DOWNLOAD_SPEED}->{TEXT}; # total downstream $tuspeed = $file->{GLOBAL}->{UPLOAD_SPEED}->{TEXT}; # total upstream # make em phear. this bit is split over multiple lines simply for readability $parta = "say Azureus $version throughput: [dl:\002\0037 $tdspeed \003]"; $partb = "[ul:\002\0037 $tuspeed \003]"; Xchat::command ("$parta $partb"); } return 1; # bail out }