autolog.tcl

autolog.tcl

When you want to make your bot keep a logfile for a new channel, you have to manually add a new `logfile` command to the bot`s config file. This can be a problem if your bot frequently joins new channels and you want to keep a log for each. This script automatically enables a logfile for each chann

Postat de Copyright Categorie Review user Vizualizari Data
btc slennox activity Cod netestat 294 2023-12-24 23:07:24

# autolog.tcl v1.1 (14 July 2000)
# copyright (c) 2000 by slennox <slennox@egghelp.org>
# slennox's eggdrop page - http://www.egghelp.org/
#
# When you want to make your bot keep a logfile for a new channel, you have
# to manually add a new 'logfile' command to the bot's config file. This
# can be a problem if your bot frequently joins new channels and you want
# to keep a log for each. This script automatically enables a logfile for
# each channel the bot joins, so that you don't need to enable it manually.
# The idea for this script came from Zsolt.
#
#
# v1.1 - Added a trigger for sending log file by hd2000 (winstonlim@visto.com)
#         ScriptCorner - http://scriptcorner.cjb.net 
# v1.0 - Initial release.

# Set the modes for new logfiles. These determine what type of things are
# logged (e.g. 'k' for kicks, bans, and mode changes). These modes are
# explained in the logfile section of eggdrop.conf.dist.
set autolog_modes "jkp"

# Specify how the logfiles should be named. There are two variables you can
# use here:
#  %chan for the channel name
#  %stripchan for the channel name with leading #+&! character removed
set autolog_file "%chan.log"

# The script will create a new logfile for every channel the bot joins for
# which no logfile is already specified. If you have some channels you
# don't want the script to create a log for, specify them here in the
# format "#chan1 #chan2 #etc".
set autolog_exempt ""

# Set the next line as the command you want to initiate the file send
set sendfile_command "!sendlog"

# Set the next line as the flag you want to initiate the file send
set sendfile_flag "o|o"

# Set the next line as the path to the log file
# example : set sendfile_path "/home/acratus/"
set sendfile_path "/your/full/path/to/the/log/file/"

# Don't edit below unless you know what you're doing.

proc autolog_join {nick uhost hand chan} {
  global botnick autolog_exempt autolog_file autolog_modes
  if {$nick == $botnick} {
    set stlchan [string tolower $chan]
    if {$autolog_exempt != "" && [lsearch -exact [string tolower [split $autolog_exempt]] $stlchan] != -1} {return 0}
    foreach logfile [logfile] {
      if {[string tolower [lindex $logfile 1]] == $stlchan} {
        return 0
      }
    }
    regsub -all -- "%chan" $autolog_file $chan file
    regsub -all -- "%stripchan" $file [string trim $chan "#+&!"] file
    logfile $autolog_modes $chan $file
  }
  return 0
}

proc pub_sendfile {nick uhost hand chan arg} {
 global sendfile_path stlchan autolog_exempt autolog_file
 
if {$autolog_exempt != "" && [lsearch -exact [string tolower [split $autolog_exempt]] $stlchan] != -1} { return 0 } else {
  
  regsub -all -- "%chan" $autolog_file $chan file
  regsub -all -- "%stripchan" $file [string trim $chan "#+&!"] file   
  
  set sendfile_file ""
  append sendfile_file $sendfile_path $file 

  switch -- [dccsend $sendfile_file $nick] {
   0 { putserv "NOTICE $nick :Sending file." }
   1 { putserv "NOTICE $nick :Error: Too many pending file requests. Try again later, thank you." }
   2 { putserv "NOTICE $nick :Error: Could not open socket. Please notify my admin, thank you." }
   3 { putserv "NOTICE $nick :Error: File does not exist. Please notify my admin, thank you." }
   4 { putserv "NOTICE $nick :Error: Too many file sends already in progress. Your request has been added to the queue, please wait, thank you." }
  }
 }
}

bind pub $sendfile_flag $sendfile_command pub_sendfile 
bind join - * autolog_join

putlog "Loaded autolog.tcl v1.1 by slennox"

return