| View previous topic :: View next topic |
| Author |
Message |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Tue Oct 10, 2006 1:52 am Post subject: bot logging |
|
|
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" |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Tue Oct 10, 2006 3:39 am Post subject: |
|
|
Edited: Totally misread that; scripting at the same time is not a good idea (apparently).  _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Last edited by Alchera on Wed Oct 11, 2006 1:08 am; edited 1 time in total |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Tue Oct 10, 2006 4:14 am Post subject: |
|
|
| But if I use 'v' I'll get ALL of the messages the bot sent to ALL channels.. |
|
| Back to top |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Tue Oct 10, 2006 10:14 am Post subject: |
|
|
it can be done but means changing bits of the tcl script
in eggdrop conf
| Code: | logfile jkp1 #channel "/eggdrop/logs/channel.log"
|
and in each tcl script where the puthelp etc are
| Code: | global botnick
putloglev 1 #channel "<$botnick> text to add to log file." |
_________________ <- tcl newb |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Oct 10, 2006 11:02 am Post subject: |
|
|
| 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):
| Code: | # 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) _________________ Have you ever read "The Manual"?
Last edited by user on Wed Oct 11, 2006 7:14 pm; edited 3 times in total |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Tue Oct 10, 2006 12:12 pm Post subject: |
|
|
I've tried the code for overwriting the put* commands and it does log something - but it kinda cuts the end off.
An example: the bot says to the channel:
<Geistereule> Willkommen, Niniane!
In the logfile is written only:
<Geistereule> Willkomme |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Oct 10, 2006 12:50 pm Post subject: |
|
|
I forgot that scan rules are not evaluated Try the edited version  _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Tue Oct 10, 2006 1:11 pm Post subject: |
|
|
That works, thanks a lot!
One more question: Is it possible to log the actions like
Action: Geistereule does something.
Instead of:
<Geistereule> ACTION does something. |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Oct 10, 2006 2:53 pm Post subject: |
|
|
| Aariancya wrote: | One more question: Is it possible to log the actions like
Action: Geistereule does something.
Instead of:
<Geistereule> ACTION does something. |
Short answer: yes.
Long answer: | Code: | 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"
}
}
} |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Tue Oct 10, 2006 3:27 pm Post subject: |
|
|
Thank you very much, that works!
Edit:
I just saw it: the order of the messages and commands is reversed:
| Quote: | <Bot> reaction to the command
<Name> the message with the command |
|
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Oct 11, 2006 7:10 pm Post subject: |
|
|
| 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) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Thu Oct 12, 2006 3:58 am Post subject: |
|
|
Now the command is logged first, but the multiple lines said by the bot are reversed
| Quote: | [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 |
|
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Oct 12, 2006 6:38 am Post subject: |
|
|
| Aariancya wrote: | | Now the command is logged first, but the multiple lines said by the bot are reversed |
Try this one: | Code: | set outlog(#fegefeuer) "#fegefeuer"
if {![llength [info procs puthelp]]} {
rename puthelp __puthelp
rename putserv __putserv
rename putquick __putquick
}
proc puthelp args {
global __log
eval __puthelp $args
lappend __log [lindex $args 0]
if {[llength __log]==1} {utimer 0 __log}
}
proc putserv args {
global __log
eval __putserv $args
lappend __log [lindex $args 0]
if {[llength __log]==1} {utimer 0 __log}
}
proc putquick args {
global __log
eval __putquick $args
lappend __log [lindex $args 0]
if {[llength __log]==1} {utimer 0 __log}
}
proc __log {} {
global outlog __log botnick
foreach s $__log {
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]} {
set a [string range $a 1 end-1]
if {[string match "ACTION *" $a]} {
putloglev p $outlog($c) "Action: $botnick [string range $a 7 end]"
} else {
putloglev p $outlog($c) "\[$botnick $a\]"
}
} else {
putloglev p $outlog($c) "<$botnick> $a"
}
}
}
set __log {}
} |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Aariancya Voice
Joined: 10 Oct 2006 Posts: 7
|
Posted: Thu Oct 12, 2006 7:00 am Post subject: |
|
|
Yes, now it logs in the right order, thanks  |
|
| Back to top |
|
 |
|