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