egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bot logging

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help
View previous topic :: View next topic  
Author Message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Tue Oct 10, 2006 1:52 am    Post subject: bot logging Reply with quote

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
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Oct 10, 2006 3:39 am    Post subject: Reply with quote

Edited: Totally misread that; scripting at the same time is not a good idea (apparently). Embarassed
_________________
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
View user's profile Send private message Visit poster's website
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Tue Oct 10, 2006 4:14 am    Post subject: Reply with quote

But if I use 'v' I'll get ALL of the messages the bot sent to ALL channels..
Back to top
View user's profile Send private message
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Tue Oct 10, 2006 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Tue Oct 10, 2006 11:02 am    Post subject: Reply with quote

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
View user's profile Send private message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Tue Oct 10, 2006 12:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Tue Oct 10, 2006 12:50 pm    Post subject: Reply with quote

I forgot that scan rules are not evaluated Razz Try the edited version Smile
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Tue Oct 10, 2006 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Tue Oct 10, 2006 2:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Tue Oct 10, 2006 3:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Wed Oct 11, 2006 7:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Thu Oct 12, 2006 3:58 am    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Oct 12, 2006 6:38 am    Post subject: Reply with quote

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
View user's profile Send private message
Aariancya
Voice


Joined: 10 Oct 2006
Posts: 7

PostPosted: Thu Oct 12, 2006 7:00 am    Post subject: Reply with quote

Yes, now it logs in the right order, thanks Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber