egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

qstats4eggdrop

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
FuE-
Halfop


Joined: 27 Nov 2004
Posts: 57

PostPosted: Fri Mar 11, 2005 8:08 pm    Post subject: qstats4eggdrop Reply with quote

hi when i use !cs ip:port i get this in partyline

Code:
(01:05:55) (_aLexi) [01:05] Tcl error [pub:qstat]: couldn't duplicate input handle: bad file number


What can be wrong?

Code:

# $Id: qstat.tcl,v 1.3 2003/06/22 12:43:47 peter Exp $

# Qstat script for an eggdrop, version 2.2, 22/06/2003
#
# 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 <peter@webdeveloping.nl>
#    - security hole fixed. (passing bad arguments to TCL's exec)
#    - display players fixed.
#  1.8 Peter Postma <peter@webdeveloping.nl>
#    - 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 <peter@webdeveloping.nl>
#    - very nasty bugs fixed: endless long flood and bad errors
#    - wiped out alot code, rewrote the main function
#  2.1 by Peter Postma <peter@webdeveloping.nl>
#    - support for RTCW, Quake 1
#    - installation steps added :^)
#    - windrop fix (but still doesn't work perfect)
#  2.2 by Peter Postma <peter@webdeveloping.nl>
#    - added BF, Gamespy, QW and UT2003.
#    - added '-timeout 5' option in qstat exec
#
# 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) Optionally change some other configuration settings below.
# 6) Edit your eggdrop's configuration file and add the qstat.tcl script.
#    If you don't how to do this, please RTFM :)
# 7) Rehash
# 8) Typ !qstat in the channel for a command list.
# 9) Have fun :)
#
# 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 "C:/SL/scripts/srv/qstat/"

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

# End configuration settings



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

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
}

putlog "Qstat4Eggdrop version $qversion: Loaded!"
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Mar 11, 2005 10:58 pm    Post subject: Reply with quote

poorly written pipeline handler - blocking, and not checking properly for errors

instead, it should be non-blocking and checking the condition of the pipe with [eof]
Back to top
View user's profile Send private message Visit poster's website
FuE-
Halfop


Joined: 27 Nov 2004
Posts: 57

PostPosted: Sat Mar 12, 2005 6:05 am    Post subject: Reply with quote

cold you say it in more 'begginer' way Smile
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat Mar 12, 2005 9:03 am    Post subject: Reply with quote

I can give a very simply answer:
TCL executable calls are currently not working in Eggdrop on Cygwin.
I have an unreplied open question on the windrop page relating to this issue:
https://sourceforge.net/forum/forum.php?thread_id=1225162&forum_id=131915

PS: [exec bla] and [open |bla] do the same in the end, so it doesnt matter. At least I get the same error in both syntax variants.
PPS: set pathqstat "C:/SL/scripts/srv/qstat/" + $pathqstat/qstat -> C:/SL/scripts/srv/qstat//qstat
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
FuE-
Halfop


Joined: 27 Nov 2004
Posts: 57

PostPosted: Sat Mar 12, 2005 10:46 am    Post subject: Reply with quote

tnx Smile
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Mar 12, 2005 2:37 pm    Post subject: Reply with quote

De Kus wrote:
I can give a very simply answer:
TCL executable calls are currently not working in Eggdrop on Cygwin.
I have an unreplied open question on the windrop page relating to this issue:
https://sourceforge.net/forum/forum.php?thread_id=1225162&forum_id=131915


hmm thats odd

have you tried exec from tclsh under CYGWIN?
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat Mar 12, 2005 9:47 pm    Post subject: Reply with quote

tclsh84:
Code:
% exec bash.exe -c "whois t-online.de"
% Copyright (c)2004 by DENIC
% Version: 1.00.0
%
% Restricted rights.
...
% open "|bash.exe -c \"whois t-online.de\""
file100bb7e8

partyline:
Code:
tcl: evaluate (.tcl): exec bash.exe -c "whois t-online.de"
Tcl error: couldn't duplicate input handle: bad file number
tcl: evaluate (.tcl): open "|bash.exe -c \"whois t-online.de\""
Tcl error: couldn't duplicate input handle: bad file number

I haven't... but you can see the result. It's simply but plain: [exec ...] and [open |...] can't be used with eggdrop under Cygwin. If you can tell me a TCL/eggdrop version combination which works, I am sure many Cygwin users will be happy Smile.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sat Mar 12, 2005 10:08 pm    Post subject: Reply with quote

Your problem may be solved by getting hold of the Window ports of the missing *nix commands in Cygwin. Cygwin comes only with the basic set.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Mar 13, 2005 8:07 am    Post subject: Reply with quote

tell us some that might be missing, but Cygwin has already many *nix commands. It's quiet faszinating how much they can emulate Unix on Windows. Still I can't compile TCL directly with Cygwin, okay, but I can't with MinGW, either, even it should be possible Very Happy. If I could, I would try tcl8.4.9, but I am (we are) stuck with 8.4.7 (I don't know how the package from windrop page is compiled, but the one from tcl.tk is not working for me) Sad.

PS: just updated to newst coreutils for cygwin and recompiled v1.6.18+notesfix from scratch (make distclean), same ^-^. just to make it clear, if I try to execute a file that doesn't exist, I will get a file not found error even within eggdrop Wink.
If I didn't encounter problems with removing bans in 1.7, I would verify it there as well.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun Mar 13, 2005 4:05 pm    Post subject: Reply with quote

you should report this also to TCL support mailing list(s), since windrop folks won't answer
Back to top
View user's profile Send private message Visit poster's website
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Mon Mar 14, 2005 12:47 am    Post subject: Reply with quote

Hmmm.. I've yet to have a problem compiling a Windrop under Cygwin. You will encounter errors if not all the dependencies are installed (this also applies to Linux). Read the error output (not the last message but the first error encountered) and you might be able to determine what's missing. Smile

One command missing from Cygwin that comes immediately to mind is "uptime".

For a FULL list of Linux commands see the Alphabetical Directory of Linux Commands and you'll see how much is missing. Wink
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon Mar 14, 2005 8:51 am    Post subject: Reply with quote

Alchera wrote:
Hmmm.. I've yet to have a problem compiling a Windrop under Cygwin. You will encounter errors if not all the dependencies are installed (this also applies to Linux). Read the error output (not the last message but the first error encountered) and you might be able to determine what's missing. Smile

One command missing from Cygwin that comes immediately to mind is "uptime".

For a FULL list of Linux commands see the Alphabetical Directory of Linux Commands and you'll see how much is missing. Wink

yeah a full list of commands... some I have never heared about and some that a cleary not meant to be installed like mail feature ^^, never I need (and I doubt eggdrop/tcl needs) text editors like vi (I am really satisfied with UltraEdit32 Very Happy). of course there are never DNS servers installed never quota/ssh/ssl/ip(chains|table) features @_o. So its quite difficult to find a command that might help. But from the error I think it might be a way in eggdrop the file is opened. perhaps in *nix you can open a file to read/execute at the same time, but Win NT prevents this. I don't know, but I rather think its something like this than its a missing command Very Happy.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Mon Mar 14, 2005 7:27 pm    Post subject: Reply with quote

Your problems compiling the eggdrop source is a missing dependency and not, as you so rightly stated, a missing command (I misread the post). I use tcl/tk 8.4.7 myself and haven't bothered with getting the 8.4.9 tarball as yet.

Check and see if you have these installed: gcc-mingw, mingw-runtime, minires-devel and the latest glib/glib2.

I use NT 5.1 (XP Pro) and initially had to do a bit of fiddling with the Cygwin setup before I could compile the eggdrop source error free.

PS: With some scripts that do use *nix commands it's possible to get hold of the Window ports and just place them in the windrop folder; the scripts then work usually without a drama. Smile
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
sniegas
Voice


Joined: 24 Aug 2006
Posts: 1

PostPosted: Thu Aug 24, 2006 5:41 pm    Post subject: Reply with quote

for me it happened even stranger thing:
Code:
00:40 <@SNow> !cs
00:41 -allstats(~allstats@help.iti.lt)- 1:
00:41 -allstats(~allstats@help.iti.lt)- 2:
00:41 -allstats(~allstats@help.iti.lt)- 3:
00:41 -allstats(~allstats@help.iti.lt)- 4:
00:41 -allstats(~allstats@help.iti.lt)- 5: TIMEOUT (193.219.1.131:27015), /
          players, ,  ms
00:41 -allstats(~allstats@help.iti.lt)- 6: This Server By OMONAS !!!
          (193.219.1.235:27015), 21/23 players, fy_pool_day, 12 ms
00:41 -allstats(~allstats@help.iti.lt)- 7: This server BY OMONAS !!!
          (193.219.1.232:27015), 1/26 players, cs_deagle5, 5 ms
00:41 -allstats(~allstats@help.iti.lt)- 8: cs.sniegas.lt CSDM #sniegas.lt
          server by SNow (84.240.23.4:27015), 19/26 players, de_nuke, 23 ms

the thing is that in the qstat4eggdrop.lst I have only 4 entries:
Code:
debian:/home/stats/.eggdrop# cat qstat4eggdrop.lst
a2s cs.iti.lt
a2s cs.alus.lt
a2s cs.sniegas.lt
a2s cs.police.lt
debian:/home/stats/.eggdrop#
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber