1# CopyLeft Riku Voipio 2001 2# half-life bot script 3use strict; 4use Irssi; 5use Irssi::Irc; 6use vars qw($VERSION %IRSSI); 7 8# header begins here 9 10$VERSION = "1.2"; 11%IRSSI = ( 12 authors => "Riku Voipio", 13 contact => "riku.voipio\@iki.fi", 14 name => "half-life", 15 description => "responds to \"!hl counterstrike.server \" command on channels/msg's to query counter-strike servers", 16 license => "GPLv2", 17 url => "http://nchip.ukkosenjyly.mine.nu/irssiscripts/", 18 ); 19 20 21my $qdir="/home/nchip/qstat/"; 22 23sub cmd_hl { 24 my ($server, $data, $nick, $mask, $target) =@_; 25 if ($data=~/^!hl/){ 26 my @foo=split(/\s+/,$data); 27 my $len=@foo; 28 if ($len==1){ 29 $foo[1]="turpasauna.taikatech.com"; 30 } 31 #fixme, haxxor protection 32 my $word=$foo[1]; 33 $_=$word; 34 $word=~s/[^a-zA-Z����0-9\.]/ /g; 35 open(DAT, "-|", $qdir."qstat -hls $word"); 36 my $count=0; 37 foreach my $line (<DAT>) 38 { 39 if ($count==1) 40 { 41 $_=$line; 42 $line=~s/\s+/ /g; 43 #print($line); 44 $server->command("/notice ".$target." ".$line); 45 } 46 $count++; 47 } 48 close(DAT); 49 } 50} 51 52Irssi::signal_add_last('message public', 'cmd_hl'); 53Irssi::print("Half-life info bot by nchip loaded."); 54