Ok here is the script that I have, it kinda works, but I need it to do a couple of other things as well. Right now the bot does catch the words being said, however I want the bot to write a log file, and put the log file in a specific place in the directory so I need to be able to put a path to the log. Also I want the script to keep writting the same log for 7 days. Then switch to a new file. Also I am getting an error message which I will post at the end of the script itself.
My guess is cos of the '$channel $botnick' line. Also, a quote from the doc/tcl-commands.doc file:
| stripcodes <strip-flags> <string>
| Description: strips specified control characters from the string given.
| strip-flags can be any combination of the following:
| b - remove all boldface codes
| c - remove all color codes
| r - remove all reverse video codes
| u - remove all underline codes
| a - remove all ANSI codes
| g - remove all ctrl-g (bell) codes
| Returns: the stripped string.
| Module: core
Wich should do the same job and even faster than ppslim's ccodes:filter proc.
Once the game is over, the king and the pawn go back in the same box.
Ok yeah duh that was my bad after removing that one line that takes care of my error message, but it's still not logging the word being said. It does catch the phrase though, because it shows it in the party line, but I want to retrieve this information later on, if somebody could help that would be great, or point me in the direction of a very dummified beginers manual would be great. This is my first attempt at writing something myself, so I have taken bits and pieces of it from other scripts so far, making progress but still a ways to go.
# Set the next line as the file to log to
set filter_words "/home/user/eggdrop/logs/serverstats.log"
### Set Words that you want the Bot to Log on
set words {
"sample"
}
## Binding all Public Messages to our Process
bind pubm - * filter_words
proc ccodes:filter {str} {
regsub -all -- {\003([0-9]{1,2}(,[0-9]{1,2})?)?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}
## Starting Process
proc filter_words {nick uhost handle channel args} {
global words botnick
set args [ccodes:filter $args]
set handle [nick2hand $nick]
foreach word [string tolower $words] {
if {[string match *$word* [string tolower $args]]} {
if {[matchattr $handle flags $channel]} {
putlog "-4Tracking Script -ATTENTION-0 $nick ($handle) said $args on $channel"
} else {
putlog "-4Tracking Script -ATTENTION0 $nick on $channel matched by $args"
}
}
}
}
bind pubm - * filter_words
putlog "FuRiOuS Tracking Script Loaded"
Ok its logging now, but how can I specify what file to put it in? Because right now it is going into the bots normal log file which isn't what I want, thats a lot of lines to look through. I want this to go to a specific file and a specific place.
if {[file exists scripts/trackingscript.log]} {
set loglist [split [read [set file [open scripts/trackingscript.log]]][close $file] \n]
}
bind time - ?0* save:log
proc save:log args {
set f [open scripts/trackingscript.log w]
foreach l $::loglist {
if {$l != ""} {
puts $f $l
}
}
close $f
}
proc myputlog arg {
if {$arg != ""} {
lappend ::loglist $arg
}
}
so now, instead of [putlog] use [myputlog] and everything will be logged into trackingscript.log in the script/ directory. (The file is updated every 10 minutes)
# Set the next line as the file to log to
set filter_words "/home/user/eggdrop/logs/stats.log"
### Set Words that you want the Bot to Log on
set words {
"test"
}
## Binding all Public Messages to our Process
bind pubm - * filter_words
proc ccodes:filter {str} {
regsub -all -- {\003([0-9]{1,2}(,[0-9]{1,2})?)?|\017|\037|\002|\026|\006|\007} $str "" str
return $str
}
## Starting Process
proc filter_words {nick uhost handle channel args} {
global words botnick
set args [ccodes:filter $args]
foreach word [string tolower $words] {
if {[string match *$word* [string tolower $args]]} {
if {[matchattr $handle $channel]} {
myputlog "4\[[strftime "%D %T"]\] $nick said $args on $channel"
}
close $file
}
}
}
if {[file exists scripts/stats.log]} {
set loglist [split [read [set file [open scripts/stats.log]]][close $file] \n]
}
bind time - ?0* save:log
proc save:log args {
set f [open scripts/stats.log w]
foreach l $::loglist {
if {$l != ""} {
puts $f $l
}
}
close $f
}
proc myputlog arg {
if {$arg != ""} {
lappend ::loglist $arg
}
}
bind pubm - * filter_words
putlog " 4f13µ12®8î9ö6µ7§ 8 Tracking Script Loaded"
However that script is now giving me this error message:
Tcl error [filter_words]: can't read "file": no such variable
So aside from this new error its also not logging again. I got the date and time added that I wanted to have, now just a few more small bugs to work out and I'm done.
Thanks Sir_Fz it works fine. As a tweak to it, is there any way to make the script log just the word that matches the specified word instead of the whole sentence?
I would only want it to track instances of the word "trigger" being said. This is just a first draft of this script, once I get this better and finished touching it up, I'll start working on the next version that will be much easier to read and stuff.
Ackkkkkkkkkkk now I have another problem, whenever I delete the logs that the script creates they diappear they are gone completely, but the next time the script updates the logs, it replaces everything that was deleted as well!! Any ideas on how to fix that?