| View previous topic :: View next topic |
| Author |
Message |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Sun Jul 17, 2005 4:45 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sun Jul 17, 2005 5:00 pm Post subject: |
|
|
again, congratulations for your creativity seriously |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Jul 17, 2005 9:01 pm Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Sun Jul 17, 2005 11:40 pm Post subject: |
|
|
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 |
|
 |
LtPhil Voice
Joined: 28 Jul 2003 Posts: 26
|
Posted: Mon Jul 18, 2005 3:29 am Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Mon Jul 18, 2005 11:21 am Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Mon Jul 18, 2005 1:06 pm Post subject: |
|
|
| ok someone online suggested reading the qstat output file before running exec qstat to get the olmap name |
|
| Back to top |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Mon Jul 18, 2005 6:06 pm Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Thu Jul 21, 2005 9:16 pm Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Fri Jul 22, 2005 12:23 am Post subject: |
|
|
| can anyone see what may be causing a memory leak? |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Fri Jul 22, 2005 3:00 am Post subject: |
|
|
| From what i see, your not closing qstat |
|
| Back to top |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Fri Jul 22, 2005 3:05 am Post subject: |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jul 22, 2005 11:46 am Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Fri Jul 22, 2005 11:58 am Post subject: |
|
|
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 |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Fri Jul 22, 2005 5:37 pm Post subject: |
|
|
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: | #########################################################################
# 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 |
|
 |
|