Here's what I have right now:
Code: Select all
# qstat.tcl - Qstat4Eggdrop version 1.8
#
# Modified for UnrealPlayground by Kingster <kingster@unrealplayground.com>
#
# This script will query halflife, quake 2, quake 3 and UT servers to
# display server status and players using the public commands.
#
# Orginal script (1.0) by Mikael Blomqvist <micke@peachpuff.com>
# Modified (1.5) by ST8 <st8@q3f.net> and in part by Ad <ad@contempt.org.uk>
# Modified again (1.7) by Peter Postma <peterpostma@yahoo.com>
# changes: - security hole fixed. (passing bad arguments to TCL's exec)
# - display players fixed.
# Version 1.8 by Peter Postma <peterpostma@yahoo.com>
# changes: - doesn't need a temp file anymore to display player info
# - use regsub for input checking
# - better error checking / error messages
# - lot of clean up
#
# This script requires Qstat! Get it @ http://www.qstat.org
# Typ !qstat for a command list.
# Configuration settings:
# Public trigger
set tr "!"
# Flags needed to use the commands
set qstat_flag "-|-"
# Path to qstat folder containing qstat stuff/scripts and the qstat program
set pathqstat "/home/ircadmin/MonkBOT/qstat"
# Channels you _dont_ want the bot to reply to public triggers on (seperate with spaces):
set nopub ""
################################################################
# This is where the evil TCL code starts, read at your peril! #
################################################################
set qversion "1.8"
bind pub $qstat_flag ${tr}servers pub:servers
bind pub $qstat_flag ${tr}server1 pub:server1
bind pub $qstat_flag ${tr}server2 pub:server2
bind pub $qstat_flag ${tr}server3 pub:server3
proc qstat:check_input {text} {
regsub -all {<|>|&|\|/|%|[|]|[$]} $text "" text
return $text
}
proc pub:servers {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
set stat [open "|$pathqstat/qstat -f $pathqstat/servers.lst -sort l -Ts $pathqstat/servermini.qstat" r]
pub:qstat_results $nick $stat
close $stat
return 0
}
proc pub:server1 {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
set stat [open "|$pathqstat/qstat -uns 204.149.41.5 -sort TF -P -Ts $pathqstat/serverfull.qstat -Tp $pathqstat/players.qstat" r]
pub:qstat_results $nick $stat
close $stat
return 0
}
proc pub:server2 {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
set stat [open "|$pathqstat/qstat -uns 64.246.32.42 -sort TF -P -Ts $pathqstat/serverfull.qstat -Tp $pathqstat/players.qstat" r]
pub:qstat_results $nick $stat
close $stat
return 0
}
proc pub:server3 {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
set stat [open "|$pathqstat/qstat -uns 64.246.42.102 -sort TF -P -Ts $pathqstat/serverfull.qstat -Tp $pathqstat/players.qstat" r]
pub:qstat_results $nick $stat
close $stat
return 0
}
proc pub:qstat_results {nick pf} {
set output_list ""
while {[gets $pf line] >= 0} {
lappend output_list $line
}
set output_line [join $output_list "\n"]
if {[string match "DOWN*" $output_line]} {
putquick "PRIVMSG $nick :Connection refused while querying server"
break
} elseif {[string match "HOSTNOTFOUND*" $output_line]} {
putquick "PRIVMSG $nick :Host not found"
break
} elseif {[string match "TIMEOUT*" $output_line]} {
putquick "PRIVMSG $nick :Timeout while querying server"
break
} else {
putquick "PRIVMSG $nick : $output_line"
}
}
}
Problem is, when it goes to send the line, it only send to where the \n was inserted.
I know there has to be a better way to do this... Can anyone help? Or am I beyond help?
