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.

Pls help me with this script

Old posts that have not been replied to for several years.
Locked
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Pls help me with this script

Post by Black|Man »

need help to get this script to run in windows with windrop :(

Code: Select all

# qstat.tcl / qstat script for an eggdrop / version 2.1 / 26/10/2002 
# 
# This script will query gameservers using the qstat program to
# display server status and players using public commands. 
#
# History:
#  1.0 (original) by Mikael Blomqvist <micke@peachpuff.com>
#  1.5 by ST8 <st8@q3f.net> and in part by Ad <ad@contempt.org.uk>
#  1.7 by Peter Postma <peterpostma@yahoo.com>
#    - security hole fixed. (passing bad arguments to TCL's exec)
#    - display players fixed. 
#  1.8 Peter Postma <peterpostma@yahoo.com>
#    - 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
#  2.0 by Peter Postma <peterpostma@yahoo.com>
#    - very nasty bugs fixed: endless long flood and bad errors
#    - wiped out alot code, rewrote the main function
#  2.1 by Peter Postma <peterpostma@yahoo.com>
#    - support for RTCW, Quake 1
#    - installation steps added :^)
#    - windrop fix
#
# Installation steps:
# 1) Easiest way of installing: put all Qstat related files (players.qstat, 
#    server.qstat, qstat.tcl, qstat (executable)) into _ONE_ directory.
#    A good choice would be something like: /home/name/eggdrop/qstat 
#    or C:\windrop\qstat
# 2) Download the Qstat program from www.qstat.org and install it
#    to some directory on your system. 
# 3) Change the option "set pathqstat "/home/peter/AI/scripts/my/qstat" 
#    and set it to the path where the Qstat related files are installed.
# 4) Make sure the path you've just set also contains the files:
#    players.qstat & server.qstat. If not, copy them to that directory.
# 5) If you're using windrop then change set the option "set windrop 0" to 1.  
# 6) Optionally change some other configuration settings below.
# 7) Edit your eggdrop's configuration file and add the qstat.tcl script. 
#    If you don't how to do this, please RTFM :)
# 8) Rehash
# 9) Typ !qstat in the channel for a command list.
#
# Configuration settings:

# Flags needed to use the commands
set qstat_flag "-|-"

# Path to qstat folder containing qstat stuff/scripts and the qstat program
set pathqstat "F:/windrop/qstat/"

# Channels you _dont_ want the bot to reply to public triggers on 
# (seperate with spaces):
set nopub ""

# If you're using windrop, set this option to 1, otherwise leave it 0.
set windrop 1

# End configuration settings



################################################################
# This is where the evil TCL code starts, read at your peril!  #
################################################################

set qversion "2.1"

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 "!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 "!utp"  pub:qstat
bind pub $qstat_flag "!hlp"  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 "!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!q1 / !q2 / !q3 / !ut / !hl / !rcw <ip/host>\002 - Displays status of queried Quake 1/2/3, UT, Half-life and RTCW servers"
  putserv "NOTICE $nick :\002!q1 / !q2p / !q3p / !utp / !hlp / !rcwp <ip/host>\002 - Displays all players on queried Quake 1/2/3, UT, Half-life and RTCW servers"
  return 0
}

proc pub:qstat {nick host hand chan arg} {
  global lastbind pathqstat nopub windrop

  # 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] || [qstat:zero_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 }
    "!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 }
    "!hlp"  { set gametype "-hls";  set players 1 }
    "!utp"  { set gametype "-uns";  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 }
    default {
      putquick "NOTICE $nick :Unknown command."
      return 0
    }
  }

 # run the qstat program.
 if {$players} {
 if {$windrop} {
 set stat [exec "|$pathqstat/qstat.exe $gametype $arg -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P"]
 } else {
 set stat [open "|$pathqstat/qstat $gametype $arg -Ts $pathqstat/server.qstat -Tp $pathqstat/players.qstat -P" r]
 close $stat
 }
 } else {
 if {$windrop} {
 set stat [exec "|$pathqstat/qstat.exe $gametype $arg -Ts $pathqstat/server.qstat"]
 } else {
 set stat [open "|$pathqstat/qstat $gametype $arg -Ts $pathqstat/server.qstat" r]
 close $stat
 }
 }
 }

# 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 bad characters, if no check this can be exploited.
proc qstat:input_check {text} {
  foreach char {">" "<" "|" "&"} {
    if [string match "*$char*" $text] { return 1 }
  }
  return 0
}

# a trailing zero leads to an endless flood.
proc qstat:zero_check {text} {
  if {[string match "0*" $text]} { return 1 }
  return 0
}

putlog "Qstat4Eggdrop version $qversion: Loaded!"


Last edited by Black|Man on Sun Oct 27, 2002 8:59 pm, edited 2 times in total.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

For one, you should use

F:\\windrop\\qstat\\

Rather than your current setting.

Beyond that, a little more help on your part would not go amiss.

WHat errors are you getting.
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

hmmm now i got this

Post by Black|Man »

Now i got this error : :cry:

Code: Select all

!rcwp 195.149.21.61:27960

Tcl error [pub:qstat]: couldn't execute "|F:\windrop\qstat\qstat.exe -rwm 195.149.21.61:27960 -Ts F:\windrop\qstat\server.qstat -Tp F:\windrop\qstat\players.qstat -P": no such file or directory

-------------------------------------------------------------------------------------
!rcw 195.149.21.61:27960

Tcl error [pub:qstat]: couldn't execute "|F:\windrop\qstat\qstat.exe -rwm 195.149.21.61:27960 -Ts F:\windrop\qstat\server.qstat": no such file or director


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

Post by ppslim »

As it sugests, have you tried making sure you have everything in the right directory?
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

Yes everything is in the right directory
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OK, some of the following sugestions, should be used.

From what I hear, Tcl has issues when traversing directories under windows.

One way to get around this, is omthing like the following.

This will assume your bot is in "F:\winbot\".

Place the qstat programs and files in a directory called "F:\winbot\qstat\". This may be what you have allready, but, this I am not aware of.

Now set the value of of the path to "qstat\\".

This should be enough for the script, to process the files.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Try using forward slash (/) instead of backslash (\) in your path names.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

All of the conventions used in the post so far are valid.

Both forward slash, and backslash (backslashes need escaping, this is why \\ is used).

FOr more information regarding Tcl and filename convention see This page (Links direct to windows specific information).
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:All of the conventions used in the post so far are valid.

Both forward slash, and backslash (backslashes need escaping, this is why \\ is used).

FOr more information regarding Tcl and filename convention see This page (Links direct to windows specific information).
Just giving a suggestion to try. I know \\ didn't work for me on my windrops, I had to use / ... If it works, great, if not, can't say it wasn't tried. Either way, forward slash would be more efficient since less space is used.
B
Black|Man
Voice
Posts: 21
Joined: Fri Oct 25, 2002 8:49 am
Location: Denmark

Post by Black|Man »

I still got this error, is that a problem ? --> "|F:\

Code: Select all

!rcwp 195.149.21.61:27960 

Tcl error [pub:qstat]: couldn't execute "|F:\windrop\qstat\qstat.exe -rwm 195.149.21.61:27960 -Ts F:\windrop\qstat\server.qstat -Tp F:\windrop\qstat\players.qstat -P": no such file or directory 

------------------------------------------------------------------------------------- 
!rcw 195.149.21.61:27960 

Tcl error [pub:qstat]: couldn't execute "|F:\windrop\qstat\qstat.exe -rwm 195.149.21.61:27960 -Ts F:\windrop\qstat\server.qstat": no such file or director

t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

This is pretty off topic, but does anyone know how to avoid/fix the "couldn't duplicate input handle: bad file number" error when exec'ing something from a tcl script?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The F: may be the issue, and a method of working around it, has been offered. If you setupt he file locations correctly, there should be no need to have the F:.

As for "can't duplicate handle". I believe this is a Tcl issue, and has nothing to do with eggdrop (as such). You could possibly contact the Tcl development team, with regards to it.
Locked