Is it possible to log what the bot wrote in the channel too? Because it doesn't do that and I would like to have what's said by the bot to the channel in the log file.
The setting in my eggbot.conf is:
logfile jpk #fegefeuer "logs/fege/fegefeuer.log"
deadite66 wrote:it can be done but means changing bits of the tcl script
...or you could override the put* commands, to avoid having to alter every script you load, using something like this (not tested and not including putdccraw):
# log messages sent to #yourchan to the #yourchan log
set outlog(#yourchan) "#yourchan"
# rename the put* commands only once...
if {![llength [info procs puthelp]]} {
rename puthelp __puthelp
rename putserv __putserv
rename putquick __putquick
proc puthelp args {
eval __puthelp $args
utimer 0 [list __log [lindex $args 0]]
}
proc putserv args {
eval __putserv $args
utimer 0 [list __log [lindex $args 0]]
}
proc putquick args {
eval __putquick $args
utimer 0 [list __log [lindex $args 0]]
}
proc __log s {
global outlog
if {[scan $s "PRIVMSG %s %\[^\n\]" c a]&&[info exists outlog([set c [string tolower $c]])]} {
if {[string index $a 0]==":"} {set a [string range $a 1 end]}
### Change this to suit your needs:
putloglev p $outlog($c) "<$::botnick> $a"
}
}
}
...but you'll only capture the output generated by scripts, not messages sent via dcc commands like .say or .dump - to do that you'd need to hack the eggdrop source (or rewrite all commands that have the ability to send messages - patching the source would be better IMO)
Last edited by user on Wed Oct 11, 2006 7:14 pm, edited 3 times in total.
proc __log s {
global outlog
if {[scan $s "PRIVMSG %s %\[^\n\]" c a]&&[info exists outlog([set c [string tolower $c]])]} {
if {[string index $a 0]==":"} {set a [string range $a 1 end]}
if {[string match \001*\001 $a]} {
# ctcp
set a [string range $a 1 end-1]
if {[string match "ACTION *" $a]} {
# ctcp action
putloglev p $outlog($c) "Action: $::botnick [string range $a 7 end]"
} else {
# other ctcp (you'll probably want to change this)
putloglev p $outlog($c) "\[$::botnick $a\]"
}
} else {
# plain privmsg
putloglev p $outlog($c) "<$::botnick> $a"
}
}
}
Aariancya wrote:I just saw it: the order of the messages and commands is reversed
Try the edited version...i added some timers which should make the logging happen after the triggered procs return. (And fixed a bug (allowing options with the put* commands))
PS: Make sure you try it with a script that outputs multiple lines from the same proc (i'm not sure the timers are executed in the right order)
Now the command is logged first, but the multiple lines said by the bot are reversed
[09:56] <User> command
[09:56] <Bot> line 7
[09:56] <Bot> line 6
[09:56] <Bot> line 5
[09:56] <Bot> line 4
[09:56] <Bot> line 3
[09:56] Action: Bot line 2
[09:56] <Bot> line 1