coke wrote:
I need a script that would make the bot send /map command to the ircd (unreal) and then save ircd's replay to a txt file, say every 15 minutes.
Code: Select all
# tested on a version 1.6.19 Windrop test bot. I haven't upgraded any bots to .20 yet.
# Version .20 may have better capability to handle the 15 minute requirement
# I believe this method used below still works on ver .20 though
bind time - "00 * * * *" do:map
bind time - "15 * * * *" do:map
bind time - "30 * * * *" do:map
bind time - "45 * * * *" do:map
#you need to set this - path and filename
set mapfile "scripts/path/to/your/map_output.txt"
proc do:map {min hour day month year} {
bind raw -|- 006 mapstuff006
bind raw -|- 007 mapstuff007
putserv "map"
utimer 10 [list unbind raw "-|-" 006 mapstuff006]
utimer 10 [list unbind raw "-|-" 007 mapstuff007]
# reference: http://forum.egghelp.org/viewtopic.php?t=6885
set fname $mapfile
set fp [open $fname "a"]
puts $fp [strftime %c]
close $fp
}
proc mapstuff006 {from key text} {
set line_to_add "[string trimleft [lrange $text 1 end] :]"
set fname $mapfile
set fp [open $fname "a"]
puts $fp $line_to_add
close $fp
}
proc mapstuff007 {from key text} {
set line_to_add "[string trimleft [lrange $text 1 end] :]"
set fname $mapfile
set fp [open $fname "a"]
puts $fp $line_to_add
puts $fp "-----------------"
close $fp
}
This is basic, no frills.Nothing else.
Since I can't answer this part, I too would be interested to know.If you have any better idea how to monitor network status, don't hesitate to let me know.
Code: Select all
<bot> [23:45] Tcl error [do:map]: can't read "mapfile": no such variable
<bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable
<bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable
<bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable
<bot> [23:45] Tcl error [mapstuff007]: can't read "mapfile": no such variable
da**it !!coke wrote:Thank you very much for helping me. I edited set mapfile "map.txt" and I run the script. There were errors:
I compared the script with some other script and added global mapfile to every proc. It seemed to fix it - eggdrop 1.6.19Code: Select all
<bot> [23:45] Tcl error [do:map]: can't read "mapfile": no such variable <bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable <bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable <bot> [23:45] Tcl error [mapstuff006]: can't read "mapfile": no such variable <bot> [23:45] Tcl error [mapstuff007]: can't read "mapfile": no such variable
And I'm very glad that you realized the problem, and got it fixed and working for you.The script works fine. /map is being saved to a file. That's exactly what i wanted.
As long as you are sure - Yes.One more thing. Could the script overwrite mapfile instead of appending to it?
Code: Select all
proc do:map {min hour day month year} {
global mapfile
bind raw -|- 006 mapstuff006
bind raw -|- 007 mapstuff007
....
Code: Select all
proc do:map {min hour day month year} {
global mapfile
if {[file exists $mapfile]} {
file delete $mapfile
}
bind raw -|- 006 mapstuff006
bind raw -|- 007 mapstuff007
....
Code: Select all
set fp [open $fname "a"]
Code: Select all
set fp [open $fname "w]"
Right.Luminous wrote:Just wanted to say that I am pretty sure you can accomplish the same thing by simply changing this:
toCode: Select all
set fp [open $fname "a"]
This basically accomplishes an "overwrite" of the file. In tcl, when you open a file with write permissions, it clears any existing content first. This is why there is "a" for "append" and "w" for "write".Code: Select all
set fp [open $fname "w]"
"w" will also create the file if it does not exist.
http://www.astro.princeton.edu/~rhl/Tcl ... pen.n.html
Perhaps you missed that.It's not going to work, with a true "overwrite", when opening the file.
willyw wrote:Code: Select all
if {[file exists $mapfile]} { file delete $mapfile }