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.

qstat map change notify

Old posts that have not been replied to for several years.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

well it works sort of :)

while inkey=""
RUN "/usr/local/bin/qstat -ut2s 217.77.176.198:7777 -xml -of /home/lee/documents/qstat.output"
OPEN "/home/lee/documents/qstat.output" for INPUT as #1
for a=1 to 6 : LINEINPUT #1, blank$ : next a
LINEINPUT #1, mapline$
qstat$=mid(mapline$,8,len(mapline$)-13)
if qstat$<>map$ then map$=qstat$ : print map$;" is now on titan 32p Onslaught" : gosub runtelnet
close #1
pause 30
wend

LABEL runtelnet
OPEN "/home/lee/documents/telnetscript.sh" for OUTPUT as #2
PRINT #2,"eggdrop="+chr(34)+"127.0.0.1 3333"+chr(34)
print #2, "username=myusername"
print #2, "password=mypassword"
print #2, "(echo $username;\"
print #2, "echo $password;\"
print #2, "echo "+chr(34)+".say #titanonslaught "+map$+" is now on titan 32p onslaught"+chr(34)+";\"
print #2, "sleep 1;) | telnet $eggdrop"
close #2
RUN "/bin/bash /home/lee/documents/telnetscript.sh"

return
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

again, congratulations for your creativity :) seriously
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I assume

Code: Select all

lindex [split $res] 8
would be the map name, try to do some tests and see.

Edit: it shouldn't be [split $res \n]
Last edited by Sir_Fz on Mon Jul 18, 2005 6:33 pm, edited 1 time in total.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

well i had a go at writing a tcl script, i had problems getting to grips with catch and lindex so i went the external file bit again.
though i'm having problems with the map change bit.

-----------------------------------------------------------------------------------------
bind time - * qstat ;# runs every minute
proc qstat {m h d mo y} {

set blank [exec /usr/local/bin/qstat -ut2s 217.77.176.198:7777 -xml -of /home/lee/documents/tclmapchange.output]

# File name to read.
set fname "/home/lee/documents/tclmapchange.output"

# Open file for read access (note we're not catching errors, you might
# want to use catch {} if the file might not exist.
set fp [open $fname "r"]

# Here we read in all of the data.
set data [read -nonewline $fp]

# Close the file, since we're done reading.
close $fp

# Now we split the data into lines.
set lines [split $data "\n"]

# Get the map line from the list!
set mapline [lindex $lines 6]
# get the string length of the line
set maplinelength [string length $mapline]
# get end of map name by trimming 7 characters off mapline
set maplineend [expr $maplinelength - 7]
# cut out <map> and </map> leaving only the map name
set mapname [string range $mapline 7 $maplineend]
}
---------------------------------------------------------------------------------------

how can i display the map name in irc if it changed since the last time the procedure ran?
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

well since you've figured out how to extract the mapname, what you need to do is create a variable at the beginning of the script, like "oldmap" or something, then right after

Code: Select all

set mapname [string range $mapline 7 $maplineend]
add

Code: Select all

  if {$mapname != $oldmap} {
    puthelp "PRIVMSG #channel :New map: $mapname"
  }
  set oldmap $mapname
... see how that works? (someone correct me if i'm wrong)
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

are variables reset at the start of the proc running?
if so $oldmap will always be different to $mapname every time the proc runs.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

ok someone online suggested reading the qstat output file before running exec qstat to get the olmap name
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

and we have a winner, had to change how the file was read that line split thing messed it up.
its a bit belt and braces but it works

Code: Select all

bind time - * qstat ;# runs every minute
proc qstat {m h d mo y} {

# read old map name
set fname "/home/lee/documents/tclmapchange.output"
set fp [open $fname "r"]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set maplinelength [string length $mapline]
set maplineend [expr $maplinelength - 7]
set oldmap [string range $mapline 7 $maplineend]

# run qstat
set blank [exec /usr/local/bin/qstat -ut2s 217.77.176.198:7777 -xml -of /home/lee/documents/tclmapchange.output]

# read new map name
set fname "/home/lee/documents/tclmapchange.output"
set fp [open $fname "r"]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set blank [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set maplinelength [string length $mapline]
set maplineend [expr $maplinelength - 7]
set mapname [string range $mapline 7 $maplineend]

# if old map different from new map name then print change message.
if {$mapname != $oldmap}  {
   puthelp "PRIVMSG #titanonslaught :$mapname now running on Titan 32Player Onslaught"
   }
}
Last edited by deadite66 on Fri Jul 22, 2005 5:40 pm, edited 1 time in total.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

re-wrote 1/2 of it to make it multi-server and multi irc channel
http://ghostpilot.org/mcn/mapchangenotify_v0.1.0.tar.gz

Code: Select all

#########################################################################
#                qstat UT2004 map change notify script                  #
#                  this is a TCL script for eggdrop                     #
#              written by Lee Donaghy lee295012@yahoo.com               #
#               Titan Internet 32 Player Onslaught server               #
#  ut2004://217.77.176.198:7777 http://ut2004.titaninternet.co.uk/vbb/  #
#########################################################################

# set your qstatpath
set qstatpath "/usr/local/bin/qstat"

# number of servers to check
set server_number 3

# edit the mapchangenotify.serverlist file
# ie.
# -ut2s
# 123.123.123.123:7777
# now running on myonslaught server
# #myirchannel
# -ut2s
# etc...
set mcn_version "v0.1.0"

###############################################################
# TCL code begins, don't edit unless you know what your doing #
###############################################################
putlog "mapchangenotify $mcn_version loaded"
set scan_delay 30000
bind time - * qstatrun ;# runs every minute
proc qstatrun {m h d mo y} {
global qstatpath
global server_number
global scan_delay
set server_count 0
set slcount 0
while {$server_count != $server_number} {
# if the files don't exist then create them
if {![file exists mapchangenotify$server_count.output]} {

# read the serverlist
set slname "mapchangenotify.serverlist"
set sl [open $slname "r"]
set sdlist [split [read $sl] \n]

set qstatgametype [lindex $sdlist $slcount] ; incr slcount
set qstatserverip [lindex $sdlist $slcount] ; incr slcount
set qstataddedtext [lindex $sdlist $slcount] ; incr slcount
set qstatircchan [lindex $sdlist $slcount] ; incr slcount

exec $qstatpath $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output
 }
incr server_count
}

set server_count 0
set slcount 0
while {$server_count != $server_number} {

# read old map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set oldmap [string range $mapline 7 [expr [string length $mapline] - 7]]

#-------------------------------------------------------------------------------------------------------------------------------------------
# read the serverlist
set slname "mapchangenotify.serverlist"
set sl [open $slname "r"]
set sdlist [split [read $sl] \n]

set qstatgametype [lindex $sdlist $slcount] ; incr slcount
set qstatserverip [lindex $sdlist $slcount] ; incr slcount
set qstataddedtext [lindex $sdlist $slcount] ; incr slcount
set qstatircchan [lindex $sdlist $slcount] ; incr slcount

#-------------------------------------------------------------------------------------------------------------------------------------------
#puts "$qstatircchan $qstatgametype $qstatserverip $qstataddedtext"
exec $qstatpath $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]


#------------------------------------------------------------------------------------------------------------------------------------------
# if qstat hit the server at the wrong time nothing is returned so having another crack at it
while {[string length $mapline] < 1} {
#after $scan_delay
exec /usr/local/bin/qstat $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
# strip out <gametype> and <\gametype>
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]
}
#-----------------------------------------------------------------------------------------------------------------------------------------

incr server_count

if {$newmap != $oldmap}  {
     puthelp "PRIVMSG $qstatircchan :$newmap $qstataddedtext ($gametype)"
   }
}
close $sl
}
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

can anyone see what may be causing a memory leak?
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

From what i see, your not closing qstat
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

if you mean the program i'm using in exec it should return server details then terminate..

edit..
perhaps i used the wrong word, what ment to say was the eggdrop memory footprint keeps slowly increasing.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

If you mean that your bot is freezing, or lagging when executing the shell command, then I suggest you use open or bgexec.tcl (not sure if I got the name right) by strikelight from tclscript.com.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

thanks guys
well think i had 2 different problems
1. after command (will have to change bits to stop hammering the server if its down)
2. a missing close statement in a loop which must have kept opening new hooks on the file everytime it looped,supprised TCL didn't flag a warning

i'll leave it a few hours and see how its goes.

thanks MeTroiD and Sir_Fz
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

hopefully working better this time, moved unneeded stuff out of the proc.
should close all open files now, removed after command.
better leave it working for a few days before i add this one to the tcl archive :(

Code: Select all

#########################################################################
#                qstat UT2004 map change notify script                  #
#                  this is a TCL script for eggdrop                     #
#              written by Lee Donaghy lee295012@yahoo.com               #
#               Titan Internet 32 Player Onslaught server               #
#  ut2004://217.77.176.198:7777 http://ut2004.titaninternet.co.uk/vbb/  #
#########################################################################

# set your qstatpath
set qstatpath "/usr/local/bin/qstat"

# number of servers to check
set server_number 3

# edit the mapchangenotify.serverlist file
# ie.
# -ut2s
# 123.123.123.123:7777
# now running on myonslaught server
# #myirchannel
# -ut2s
# etc...
set mcn_version "v0.1.0"

###############################################################
# TCL code begins, don't edit unless you know what your doing #
###############################################################
putlog "mapchangenotify $mcn_version loaded"

# read server list 
set slname "mapchangenotify.serverlist"
set slct [open $slname "r"]
set sdlist [split [read $slct] \n]
close $slct

# create server files if they don't exist
set cfc 0
while { $cfc != $server_number } {
if {![file exists mapchange]} {
set fname "mapchangenotify$cfc.output"
set fp [open $fname "w"]
close $fp
incr cfc
}
}
#---------------------------------------------------------------------

bind time - * qstatrun ;# runs every minute
proc qstatrun {m h d mo y} {
global qstatpath
global server_number
global slct
global sl
global sdlist

set server_count 0
set slcount 0
while {$server_count != $server_number} {

# read old map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set oldmap [string range $mapline 7 [expr [string length $mapline] - 7]]

#-------------------------------------------------------------------------------------------------------------------------------------------
# set server list 
set qstatgametype [lindex $sdlist $slcount] ; incr slcount
set qstatserverip [lindex $sdlist $slcount] ; incr slcount
set qstataddedtext [lindex $sdlist $slcount] ; incr slcount
set qstatircchan [lindex $sdlist $slcount] ; incr slcount

#-------------------------------------------------------------------------------------------------------------------------------------------
exec $qstatpath $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]


#------------------------------------------------------------------------------------------------------------------------------------------
# if qstat hit the server at the wrong time nothing is returned so having another crack at it
set recheckbreak 0
set mlbroken 0
while {[string length $mapline] < 1} {
exec /usr/local/bin/qstat $qstatgametype $qstatserverip -xml -of mapchangenotify$server_count.output

# read new map name
set fname "mapchangenotify$server_count.output"
set fp [open $fname "r"]
set blank [gets $fp] ;set blank [gets $fp] ;set blank [gets $fp];set blank [gets $fp];set blank [gets $fp]
set gametypeline [gets $fp]
set mapline [gets $fp]
close $fp

# strip out <map> and <\map>
set newmap [string range $mapline 7 [expr [string length $mapline] - 7]]
# strip out <gametype> and <\gametype>
set gametype [string range $gametypeline 12 [expr [string length $gametypeline] - 12]]
incr recheckbreak
if {$recheckbreak == 10} { set mlbroken 1 ; break }
}
#-----------------------------------------------------------------------------------------------------------------------------------------

incr server_count

if {$newmap != $oldmap && $mlbroken == 0 }  {
     puthelp "PRIVMSG $qstatircchan :$newmap $qstataddedtext ($gametype)"
   }
}
}
Locked