Code: Select all
bind PUB - !status our:easy:status
proc our:easy:status {nick uh hand chan arg} {
set b [binds PUB]
if {[set idx [lsearch -glob $b "* * !hl * *"]] != -1} {
[lindex [lindex $b $idx] 4] $nick $uh $hand $chan $arg
}
}
Code: Select all
# qstat.tcl - Qstat4Eggdrop version 1.8
#
# 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 "C:/Windrop/scriptsrav/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}qstat pub:qstat_help
bind pub $qstat_flag ${tr}q3 pub:qstat_q3
bind pub $qstat_flag ${tr}q2 pub:qstat_q2
bind pub $qstat_flag ${tr}hl pub:qstat_hl
bind pub $qstat_flag ${tr}ut pub:qstat_ut
bind pub $qstat_flag ${tr}q3p pub:qstat_q3p
bind pub $qstat_flag ${tr}q2p pub:qstat_q2p
bind pub $qstat_flag ${tr}utp pub:qstat_utp
bind pub $qstat_flag ${tr}hlp pub:qstat_hlp
proc qstat:check_input {text} {
regsub -all {<|>|&|\|/|%|[|]|[$]} $text "" text
return $text
}
proc pub:qstat_help {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
putserv "NOTICE $nick :Qstat commands:"
putserv "NOTICE $nick :\002${tr}q2 / ${tr}q3 / ${tr}ut / ${tr}hl <IP>\002 - Displays status of queried Quake 2, Quake 3, UT and Half-life servers"
putserv "NOTICE $nick :\002${tr}q2p / ${tr}q3p / ${tr}utp / ${tr}hlp <IP>\002 - Displays all players on queried Quake 2, Quake 3, UT and Half-life servers"
return 0
}
proc pub:qstat_q3 {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}q3 <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -q3s [qstat:check_input $arg] -Ts $pathqstat/server.qstat" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_q2 {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}q2 <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -q2s [qstat:check_input $arg] -Ts $pathqstat/server.qstat" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_hl {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}hl <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -hls [qstat:check_input $arg] -Ts $pathqstat/server.qstat" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_ut {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}ut <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -uns [qstat:check_input $arg] -Ts $pathqstat/server.qstat" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_q3p {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}q3p <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -q3s [qstat:check_input $arg] -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_q2p {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}q2p <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -q2s [qstat:check_input $arg] -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_hlp {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}hlp <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -hls [qstat:check_input $arg] -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_utp {nick host hand chan arg} {
global pathqstat tr nopub
if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
if {[string length [string trim $arg]] == 0} {
putserv "notice $nick :Usage: ${tr}utp <\002IP Address\002>"
return 0
}
set stat [open "|$pathqstat/qstat -uns [qstat:check_input $arg] -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
pub:qstat_results $chan $stat
close $stat
return 0
}
proc pub:qstat_results {chan pf} {
while {[gets $pf line] >= 0} {
if {[string match "DOWN*" $line]} {
putquick "PRIVMSG $chan :Connection refused while querying server"
break
} elseif {[string match "HOSTNOTFOUND*" $line]} {
putquick "PRIVMSG $chan :Host not found"
break
} elseif {[string match "TIMEOUT*" $line]} {
putquick "PRIVMSG $chan :Timeout while querying server"
break
}
putquick "PRIVMSG $chan :$line"
}
}
putlog "Qstat4Eggdrop version $qversion: LOADED!"
Code: Select all
bind PUB - !status our:easy:status
proc our:easy:status {nick uh hand chan arg} {
pub:qstat_hl $nick $uh $hand $chan "213.208.119.25:27015"
}
Code: Select all
####################
# Code begins here #
####################
if {![string match 1.6.* $version]} {
putlog "\002CLANBASE:\002 \002CRITICAL ERROR\002 ClanBase.tcl requires eggdrop 1.6.x to run."
die "\002CLANBASE:\002 \002CRITICAL ERROR\002 ClanBase.tcl requires eggdrop 1.6.x to run."
}
if {[info tclversion] < 8.2} {
putlog "\002CLANBASE:\002 \002CRITICAL ERROR\002 ClanBase.tcl requires Tcl 8.2 or above to run."
die "\002CLANBASE:\002 \002CRITICAL ERROR\002 ClanBase.tcl requires Tcl 8.2 or above to run."
}
package require http
bind pub $clanbase_setting(flag) $clanbase_setting(cmd_crank) clanbase_showrank
bind pub $clanbase_setting(flag) $clanbase_setting(cmd_nxtwar) clanbase_shownext
bind pub $clanbase_setting(flag) $clanbase_setting(cmd_updt) clanbase_update
if {![string match *clanbase_time_update* [timers]]} { timer $clanbase_setting(timer_update) clanbase_time_update }
proc clanbase_update {nick uhost hand chan text} {
clanbase_time_update
putserv "PRIVMSG $chan :The ClanBase information has been updated."
}
proc clanbase_time_update {} {
global clanbase_data clanbase_setting
set q [::http::formatQuery wars 1 cid $clanbase_setting(cid) lid $clanbase_setting(lid)]
set q2 [::http::formatQuery cid $clanbase_setting(cid)]
::http::config -useragent "ClanBase.tcl"
set tok [::http::geturl http://www.clanbase.com/claninfo.php -query $q]
if {[::http::ncode $tok] != 200} {
set clanbase_data(rank) 0
} else {
if {[regexp {Rank: (.*) \((.*) points\)} [::http::data $tok] match rank points]} {
set clanbase_data(rank) [list $rank $points [unixtime]]
} else {
set clanbase_data(rank) 0
}
}
set tok2 [::http::geturl http://www.clanbase.com/cbjswarupcoming.php -query $q2]
if {[::http::ncode $tok2] != 200} {
set clanbase_data(nextwar) 0
} else {
regsub -all -- "\"" "[::http::data $tok2]" "" data
regsub -all -- "," "$data" "" data
if {[regexp {cbjsWarUpcoming_Start\(\)\;cbjsWarUpcoming_Each\((.*)\)\;cbjsWarUpcoming_End\(\)\;} $data match data]} { set clanbase_data(nextwar) 0 }
if {[llength $data] < 10} {
set clanbase_data(nextwar) 0
putlog "BUG: ClanBase has changed, make sure your cid and lid settings are correct. If not, e-mail wcc@techmonkeys.org with this data: $data"
} else {
set wid [lindex $data 0]
set with [lindex $data 1]
set time [lindex $data 4]
set date [lindex $data 5]
set game [lindex $data 8]/[lindex $data 9]
set clanbase_data(nextwar) [list $with $time $date $game http://www.clanbase.com/warinfo.php?[::http::formatQuery wid $wid] [unixtime]]
}
}
::http::cleanup $tok
::http::cleanup $tok2
if {![string match *clanbase_time_update* [timers]]} { timer $clanbase_setting(timer_update) clanbase_time_update }
}
proc clanbase_showrank {nick uhost hand chan text} {
global clanbase_data
if {![info exists clanbase_data(rank)]} {
puthelp "PRIVMSG $chan :The information has not been downloaded yet. Please wait until the next update."
} elseif {[string equal $clanbase_data(rank) 0]} {
puthelp "PRIVMSG $chan :An error occurred the last time the information was downloaded. Try again later."
} else {
set ts "[duration [expr [unixtime] - [lindex $clanbase_data(rank) end]]] ago."
puthelp "PRIVMSG $chan :Rank: [lindex $clanbase_data(rank) 0] Points: [lindex $clanbase_data(rank) 1] Updated: $ts"
}
}
proc clanbase_shownext {nick uhost hand chan text} {
global clanbase_data
if {![info exists clanbase_data(nextwar)]} {
puthelp "PRIVMSG $chan :The information has not been downloaded yet. Please wait until the next update."
} elseif {[string equal $clanbase_data(nextwar) 0]} {
puthelp "PRIVMSG $chan :An error occurred the last time the information was downloaded. Try again later."
} else {
set ts "[duration [expr [unixtime] - [lindex $clanbase_data(nextwar) end]]] ago."
puthelp "PRIVMSG $chan :Next War: [lindex $clanbase_data(nextwar) 0], [lindex $clanbase_data(nextwar) 1] [lindex $clanbase_data(nextwar) 2], [lindex $clanbase_data(nextwar) 3]. Details: [lindex $clanbase_data(nextwar) 4] Updated: $ts"
}
}
putlog "\002CLANBASE:\002 ClanBase Info updater Loaded!"
aite, I still don't get it, tell me please the whole this script, not the qstat.tcl script, this script !status.ppslim wrote:LMAO.
Why on earth I posted, i don't bloody know.
I did all the funky code, to save posting needed information, and I blow it by forgetting the simple part.Code: Select all
bind PUB - !status our:easy:status proc our:easy:status {nick uh hand chan arg} { pub:qstat_hl $nick $uh $hand $chan "213.208.119.25:27015" }
Code: Select all
puthelp "PRIVMSG $chan :Rank: [lindex $clanbase_data(rank) 0] Points: [lindex $clanbase_data(rank) 1] Updated: $ts"
Code: Select all
set tmp_rank [string map -nocase {"<b>" "\002" "</b>" "\002"} [lindex $clanbase_data(rank) 0]]
puthelp "PRIVMSG $chan :Rank: $tmp_rank Points: [lindex $clanbase_data(rank) 1] Updated: $ts"
Code: Select all
bind PUB - !status our:easy:status
proc our:easy:status {nick uh hand chan arg} {
if {[string equal [string tolower $chan] [string tolower {#somechannel}]]} {
pub:qstat_hl $nick $uh $hand $chan "213.208.119.25:27015"
} else {
pub:qstat_hl $nick $uh $hand $chan "1.1.1.1:27015"
}
}
Thank you, it works.Papillon wrote:you have to check which channel it is beeing executed inthis is just one of any ways of doing thisCode: Select all
bind PUB - !status our:easy:status proc our:easy:status {nick uh hand chan arg} { if {[string equal [string tolower $chan] [string tolower {#somechannel}]]} { pub:qstat_hl $nick $uh $hand $chan "213.208.119.25:27015" } else { pub:qstat_hl $nick $uh $hand $chan "1.1.1.1:27015" } }
Yep. I got it. Thanks again !Papillon wrote:despite what you might think we are actually NOT here to make script for anyone... unless we feel like it... or to get someone to shutup with a problem
From that code you should be able to figure out how to modify it so that it works for just 2,3,4,5 ..... balablaa channels, if not you really should read some tcl-tutorial, also check out what the tcl-manual says about the if command