Code: Select all
bind pub -|- !myserver qstat:myserver
proc qstat:myserver { nick uhost hand chan arg } {
q3s $nick $uhost $hand $chan "127.0.0.1:1337"
}
Code: Select all
Tcl error [qstat:myserver]: invalid command name "q3s"
Code: Select all
set qversion "2.2"
bind pub $qstat_flag "!ut" pub:qstat
bind pub $qstat_flag "!hl" pub:qstat
bind pub $qstat_flag "!cs" pub:qstat
bind pub $qstat_flag "!qw" pub:qstat
bind pub $qstat_flag "!q1" pub:qstat
bind pub $qstat_flag "!q2" pub:qstat
bind pub $qstat_flag "!q3" pub:qstat
bind pub $qstat_flag "!rcw" pub:qstat
bind pub $qstat_flag "!bf" pub:qstat
bind pub $qstat_flag "!gs" pub:qstat
bind pub $qstat_flag "!ut2k3" pub:qstat
bind pub $qstat_flag "!ut2003" pub:qstat
bind pub $qstat_flag "!utp" pub:qstat
bind pub $qstat_flag "!hlp" pub:qstat
bind pub $qstat_flag "!qwp" pub:qstat
bind pub $qstat_flag "!q1p" pub:qstat
bind pub $qstat_flag "!q3p" pub:qstat
bind pub $qstat_flag "!q2p" pub:qstat
bind pub $qstat_flag "!rcwp" pub:qstat
bind pub $qstat_flag "!bfp" pub:qstat
bind pub $qstat_flag "!ut2k3p" pub:qstat
bind pub $qstat_flag "!ut2003p" pub:qstat
bind pub $qstat_flag "!qstat" pub:qstat_help
proc pub:qstat_help {nick host hand chan arg} {
global pathqstat nopub
# check if channel is allowed.
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
# output qstat commands / help.
putserv "NOTICE $nick :Qstat commands:"
putserv "NOTICE $nick :\002!qw / !q1 / !q2 / !q3 / !rcw <ip/host>\002 - Displays status of queried Quake World, 1, 2, 3 or RTCW servers"
putserv "NOTICE $nick :\002!ut / !ut2003 / !hl / !bf / !gs <ip/host>\002 - Displays status of queried UT(2003), Half-life, BF1942 and GameSpy servers"
return 0
}
proc pub:qstat {nick host hand chan arg} {
global lastbind pathqstat nopub
# check if channel is allowed.
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
# only use one argument.
set arg [lindex $arg 0]
# check for input.
if {[string length [string trim $arg]] == 0 || [qstat:input_check $arg]} {
putquick "NOTICE $nick :Syntax: $lastbind <ip/host>"
return 0
}
# figure out which command was used.
switch [string tolower $lastbind] {
"!hl" { set gametype "-hls"; set players 0 }
"!cs" { set gametype "-hls"; set players 0 }
"!ut" { set gametype "-uns"; set players 0 }
"!qw" { set gametype "-qws"; set players 0 }
"!q1" { set gametype "-qs"; set players 0 }
"!q2" { set gametype "-q2s"; set players 0 }
"!q3" { set gametype "-q3s"; set players 0 }
"!rcw" { set gametype "-rwm"; set players 0 }
"!bf" { set gametype "-gps"; set players 0 }
"!gs" { set gametype "-gps"; set players 0 }
"!ut2k3" { set gametype "-ut2s"; set players 0 }
"!ut2003" { set gametype "-ut2s"; set players 0 }
"!hlp" { set gametype "-hls"; set players 1 }
"!utp" { set gametype "-uns"; set players 1 }
"!qwp" { set gametype "-qws"; set players 1 }
"!q1p" { set gametype "-qs"; set players 1 }
"!q2p" { set gametype "-q2s"; set players 1 }
"!q3p" { set gametype "-q3s"; set players 1 }
"!rcwp" { set gametype "-rwm"; set players 1 }
"!bfp" { set gametype "-gps"; set players 1 }
"!ut2k3p" { set gametype "-ut2s"; set players 1 }
"!ut2003p" { set gametype "-ut2s"; set players 1 }
default {
putquick "NOTICE $nick :Unknown command."
return 0
}
}
# run the qstat program.
if {$players} {
set stat [open "|$pathqstat/qstat -timeout 5 $gametype $arg -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
} else {
set stat [open "|$pathqstat/qstat -timeout 5 $gametype $arg -Ts $pathqstat/server.qstat" r]
}
# output the result.
qstat:results $chan $nick $stat
# close fork, end program.
close $stat
return 0
}
# show results.
proc qstat:results {chan nick pf} {
while {[gets $pf line] >= 0} {
if {[string match "DOWN*" $line]} {
putquick "NOTICE $nick :Connection refused while querying server."
break
} elseif {[string match "HOSTNOTFOUND*" $line]} {
putquick "NOTICE $nick :Host not found."
break
} elseif {[string match "TIMEOUT*" $line]} {
putquick "NOTICE $nick :Timeout while querying server."
break
}
putquick "PRIVMSG $chan :$line"
}
}
# check for valid chars
proc qstat:input_check {text} {
if {[regexp \[^\[:alnum:\]_\.\:\] $text]} { return 1 }
if {[string match "0*" $text]} { return 1 }
return 0
}
Code: Select all
bind pub -|- !myserver qstat:myserver
proc qstat:myserver { nick uhost hand chan arg } {
pub:qstat $nick $uhost $hand $chan "127.0.0.1:1337"
}
Code: Select all
"!myserver" { set gametype "-q3s"; set players 0 }