This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

bot logging

General support and discussion of Eggdrop bots.
Post Reply
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

bot logging

Post by Aariancya »

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"
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Edited: Totally misread that; scripting at the same time is not a good idea (apparently). :oops:
Last edited by Alchera on Wed Oct 11, 2006 1:08 am, edited 1 time in total.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

But if I use 'v' I'll get ALL of the messages the bot sent to ALL channels..
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

it can be done but means changing bits of the tcl script

in eggdrop conf

Code: Select all

logfile jkp1 #channel "/eggdrop/logs/channel.log"
and in each tcl script where the puthelp etc are

Code: Select all

global botnick
putloglev 1 #channel "<$botnick> text to add to log file."
<- tcl newb
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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: Select all

# 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.
Have you ever read "The Manual"?
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

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
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I forgot that scan rules are not evaluated :P Try the edited version :)
Have you ever read "The Manual"?
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

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.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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: Select all

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"?
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

Thank you very much, that works!

Edit:
I just saw it: the order of the messages and commands is reversed:
<Bot> reaction to the command
<Name> the message with the command
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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"?
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

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
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Aariancya wrote:Now the command is logged first, but the multiple lines said by the bot are reversed
Try this one:

Code: Select all

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"?
A
Aariancya
Voice
Posts: 7
Joined: Tue Oct 10, 2006 1:41 am

Post by Aariancya »

Yes, now it logs in the right order, thanks :)
Post Reply