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 

qstat map change notify
Goto page Previous  1, 2, 3  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Sun Jul 17, 2005 4:45 pm    Post subject: Reply with quote

well it works sort of Smile

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 1Wink | telnet $eggdrop"
close #2
RUN "/bin/bash /home/lee/documents/telnetscript.sh"

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


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

PostPosted: Sun Jul 17, 2005 5:00 pm    Post subject: Reply with quote

again, congratulations for your creativity Smile seriously
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Jul 17, 2005 9:01 pm    Post subject: Reply with quote

I assume
Code:
lindex [split $res] 8

would be the map name, try to do some tests and see.

Edit: it shouldn't be [split $res \n]
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts


Last edited by Sir_Fz on Mon Jul 18, 2005 6:33 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Sun Jul 17, 2005 11:40 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
LtPhil
Voice


Joined: 28 Jul 2003
Posts: 26

PostPosted: Mon Jul 18, 2005 3:29 am    Post subject: Reply with quote

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:
set mapname [string range $mapline 7 $maplineend]
add
Code:
  if {$mapname != $oldmap} {
    puthelp "PRIVMSG #channel :New map: $mapname"
  }
  set oldmap $mapname


... see how that works? (someone correct me if i'm wrong)
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Mon Jul 18, 2005 11:21 am    Post subject: Reply with quote

are variables reset at the start of the proc running?
if so $oldmap will always be different to $mapname every time the proc runs.
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Mon Jul 18, 2005 1:06 pm    Post subject: Reply with quote

ok someone online suggested reading the qstat output file before running exec qstat to get the olmap name
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Mon Jul 18, 2005 6:06 pm    Post subject: Reply with quote

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:

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
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Thu Jul 21, 2005 9:16 pm    Post subject: Reply with quote

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:
#########################################################################
#                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
}
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Fri Jul 22, 2005 12:23 am    Post subject: Reply with quote

can anyone see what may be causing a memory leak?
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Fri Jul 22, 2005 3:00 am    Post subject: Reply with quote

From what i see, your not closing qstat
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Fri Jul 22, 2005 3:05 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jul 22, 2005 11:46 am    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Fri Jul 22, 2005 11:58 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Fri Jul 22, 2005 5:37 pm    Post subject: Reply with quote

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 Sad

Code:
#########################################################################
#                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)"
   }
}
}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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