This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

qstat4eggdrop - easy question

Old posts that have not been replied to for several years.
R
Rav
Voice
Posts: 13
Joined: Mon Feb 24, 2003 8:47 am

qstat4eggdrop - easy question

Post by Rav »

Hi,

I have got qstats4eggdrop and all other scripts working perfectly..

Now if a user types !hl 213.208.119.25:27015 for example the bot replies with the information for that server ;)

BUT (always a but)

As we only every query 1 server I would like a global command like

!status to have the same result, this saves people having to enter the IP address.

So if they type !status the bot replies with the server information (predefind server)

Any ideas?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

HMM - without looking at the script.

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
  }
}
R
Rav
Voice
Posts: 13
Joined: Mon Feb 24, 2003 8:47 am

Post by Rav »

Thnaks for that mate..

But how do it set the IP for it to query?

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!"
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

LMAO.

Why on earth I posted, i don't bloody know.

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"
}
I did all the funky code, to save posting needed information, and I blow it by forgetting the simple part.
R
Rav
Voice
Posts: 13
Joined: Mon Feb 24, 2003 8:47 am

Post by Rav »

Thank you very very much.. Works like a charm ;)
R
Rav
Voice
Posts: 13
Joined: Mon Feb 24, 2003 8:47 am

Post by Rav »

Perhaps one final small question..

Using the script below, when the !clanrank results are returned the bots says this in channel:

<b>57</b> Points: 1123 Updated: 2 minutes 5 seconds ago.

Is there are way to remove the <b> and </b> html tags? or is that just tough luck as the rank is in bold on the webite.

Thanks again for your help

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!"
R
Rav
Voice
Posts: 13
Joined: Mon Feb 24, 2003 8:47 am

Post by Rav »

^^ Gentle nudge
S
Storm
Voice
Posts: 36
Joined: Fri Apr 25, 2003 12:59 am
Location: Vancouver, Canada

Post by Storm »

ppslim wrote:LMAO.

Why on earth I posted, i don't bloody know.

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"
}
I did all the funky code, to save posting needed information, and I blow it by forgetting the simple part.
aite, I still don't get it, tell me please the whole this script, not the qstat.tcl script, this script !status.
btw. hey everyone! :)
Thank you.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Rav:
This is a script-bug it seems, you can start searching for it if you want ;)
anyway... here's a way to "avoid it"

Code: Select all

puthelp "PRIVMSG $chan :Rank: [lindex $clanbase_data(rank) 0] Points: [lindex $clanbase_data(rank) 1] Updated: $ts" 
replace this line with:

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"
This will replace the bold html tags and replace them with \002 which is the bold tags used by irc.


Storm:
That is the whole script ;), just edit the ip, copy it to the qstat script, upload the script and rehash and it should work
Elen sila lúmenn' omentielvo
S
Storm
Voice
Posts: 36
Joined: Fri Apr 25, 2003 12:59 am
Location: Vancouver, Canada

Post by Storm »

Yea, right, it works!
It didnt work before, because I have vers 2.2, not 1.8... and its a little different :)
Thanks! :D
S
Storm
Voice
Posts: 36
Joined: Fri Apr 25, 2003 12:59 am
Location: Vancouver, Canada

Post by Storm »

Cool, it works!
and now I got another question :D.
How do I make so for #channel1 will be 1.1.1.1 IP for #channel2 will be different IP but the same command @status???
Thanks :)!
P.S 1.1.1.1 is an example :)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

you have to check which channel it is beeing executed in

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"
  }
}
this is just one of any ways of doing this
Elen sila lúmenn' omentielvo
S
Storm
Voice
Posts: 36
Joined: Fri Apr 25, 2003 12:59 am
Location: Vancouver, Canada

Post by Storm »

Papillon wrote:you have to check which channel it is beeing executed in

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"
  }
}
this is just one of any ways of doing this
Thank you, it works.
But this code works for 2 channels, #somechannel and 1.1.1.1 IP for
other channels, and how to add another channel? Please.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

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
Elen sila lúmenn' omentielvo
S
Storm
Voice
Posts: 36
Joined: Fri Apr 25, 2003 12:59 am
Location: Vancouver, Canada

Post by Storm »

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
Yep. I got it. Thanks again :)!
Locked