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.

Logger TCL

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Ashoq
Voice
Posts: 11
Joined: Sat Jul 17, 2010 4:35 pm

Logger TCL

Post by Ashoq »

hi everyone :)

i have a Logger TCL Script it works fine

i just need to add a REFRESH every 60 secondes plz

Code: Select all

########################################################
#        Eggdrop Logger 2.0 - www.mircstats.com        #
#        Logging in mIRC 6.17 format. 27/04/2006       #
#                                                      #
#   Make sure you have created the dir 'logger(dir)'   #
#                                                      #
#         Created by Lanze <simon@freeworld.dk>        #
#         Improved by zowtar <zowtar@gmail.com>        #
#                                                      #
########################################################


### Configuration ###

#;;; Where the logs will be saved.
set logger(dir) "~/public_html/irc/"

#;;; Strip codes?
#;;; 0 = save codes\colors
#;;; 1 = no save codes\colors
set logger(strip) "1"

#;;; Save by Day, Week, Month or Disable?
set logger(time) "Day"

# Modes
set logger(color1) "<font color='#FF0000'>"
# Text
set logger(color2) "<font color='#008080'>"
# Action
set logger(color3) "<font color='#9C009C'>"
# Notice / other
set logger(color4) "<font color='#7F0000'>"
# Timestamps
set logger(color5) "<font color='#0000FF'>"
# Topic
set logger(color6) "<font color='#D889B8'>"
# Join
set logger(color7) "<font color='#FFCC00'>"
# Part
set logger(color8) "<font color='#669900'>"
# Nick
set logger(color9) "<font color='#AA0078'>"
# Quit
set logger(color10) "<font color='#CCCCCC'>"


# # # # # # # # # # # # # # # #   DO NOT CHANGE ANYTHING BELOW HERE   # # # # # # # # # # # # # # # #


bind raw - "MODE" logger:raw

proc logger:raw { from keyword text } {
	global logger
	set nick [lindex [split $from "!"] 0]
	set chan [lindex [split $text] 0]
	set mode [lindex [split $text] 1]
	set arguments [lrange [split $text] 2 end]
	if {[validchan $chan] && [string tolower $chan] == "#maroc-love" } {
		logger:save $chan "$logger(color1)* $nick sets mode: $mode $arguments"
	}
}


### Events
bind join - "#maroc-love *!*@*" logger:join
bind part - "#maroc-love *!*@*" logger:part
bind sign - "#maroc-love *!*@*" logger:quit
bind pubm - "#maroc-love *" logger:text
bind nick - "#maroc-love *" logger:nick
bind kick - "#maroc-love *" logger:kick
# bind mode - "#maroc-love *" logger:mode
bind topc - "#maroc-love *" logger:topic
bind raw - "333" logger:topic-author
bind ctcp - "ACTION" logger:action
bind notc - * logger:notice
bind rejn - "#maroc-love *!*@*" logger:rejn
bind splt - "#maroc-love *!*@*" logger:split


### Primary Commands
proc logger:join {nick uhost handle chan} {
  global logger botnick
  if {$nick == $botnick} {
    if {[file exists "$logger(dir)$chan.html"] == "0" } {
      set log "[open "$logger(dir)$chan.html" a]"
      puts $log "<html><head><title>$chan [strftime "%d%b%G"]</title></head>"
      puts $log "<body bgcolor=\"#000000\"><tt>"
      close $log
#      putquick "TOPIC $chan"
    }
    set log "[open "$logger(dir)$chan.html" a]"
    puts $log "<br>"
    puts $log "$logger(color5)Session Start: [strftime "%a %b %d %T %Y"]</font><br>"
    puts $log "$logger(color5)Session Ident: $chan</font><br>"
    puts $log "$logger(color5)\[[strftime "%a%d%b.%H:%M:%S"]\]</font> $logger(color1)* Now talking in $chan</font><br>"
    close $log
  } else {
    logger:save $chan "$logger(color7)* Joins: $nick ($uhost)"
  }
}

proc logger:rejn { nick uhost handle chan } {
	global logger
	logger:save $chan "$logger(color7)* Rejoin from split: $nick ($uhost)"
}

proc logger:part {nick uhost handle chan msg} {
  global logger
  if {$msg == ""} {
    logger:save $chan "$logger(color8)* Parts: $nick ($uhost)"
    #logger:save $chan "$logger(color1)* $nick ($uhost) has left $chan"
  } else {
    logger:save $chan "$logger(color8)* Parts: $nick ($uhost) ($msg)"
    #logger:save $chan "$logger(color1)* $nick ($uhost) has left $chan ($msg)"
  }
}

proc logger:quit {nick uhost handle chan reason} {
  global logger
  logger:save $chan "$logger(color10)* Quits: $nick ($uhost) ($reason)"
  #logger:save $chan "$logger(color1)* $nick ($uhost) Quit ($reason)"
}

proc logger:split { nick uhost handle chan } {
	global logger
	logger:save $chan "$logger(color10)* Lost in the netsplit: $nick ($uhost)"
}

proc logger:text {nick uhost handle chan text} {
  global logger
  if {[isop $nick $chan] == "1"} {
    set nick "@$nick"
  } elseif {[ishalfop $nick $chan] == "1"} {
    set nick "%$nick"
  } elseif {[isvoice $nick $chan] == "1"} {
    set nick "+$nick"
  }
  logger:save $chan "$logger(color2)($nick) $text"
}

proc logger:nick {nick uhost handle chan newnick} {
  global logger
  logger:save $chan "$logger(color9)* $nick is now known as $newnick"
}

proc logger:kick {nick uhost handle chan target reason} {
  global logger
  logger:save $chan "$logger(color1)* $target was kicked by $nick ($reason)"
}

proc logger:mode {nick uhost handle chan mode victim} {
  global logger
  logger:save $chan "* $nick sets mode: $mode $victim"
}

proc logger:topic {nick uhost handle chan topic} {
  global logger
  if {[string tolower $chan] == "#maroc-love" } {
    if {$nick == "*"} {
      logger:save $chan "$logger(color6)* Topic is '$topic'"
    } else {
      logger:save $chan "$logger(color6)* $nick changes topic to '$topic'"
    }
  }
}

proc logger:topic-author {from keyword text} {
  global logger
  set chan [lindex [split $text] 0]
  if {[validchan $chan] && [string tolower $chan] == "#maroc-love" } {
    logger:save [lindex $text 1] "$logger(color6)* Set by [lindex $text 2] on [strftime "%a %b %d %T" [lindex $text 3]]"
  }
}

proc logger:action {nick uhost handle dest keyword text} {
  global logger
  if {[validchan $dest] == "1" && [string tolower $dest] == "#maroc-love" } {
    if {[isop $nick $dest] == "1"} {
      set nick "@$nick"
    } elseif {[ishalfop $nick $dest] == "1"} {
      set nick "%$nick"
    } elseif {[isvoice $nick $dest] == "1"} {
      set nick "+$nick"
    }
    logger:save $dest "$logger(color3)* $nick $text"
  }
}

proc logger:notice { nick uhost handle text dest } {
        global logger
	if {[validchan $dest] && [string tolower $dest] == "#maroc-love" } {
		logger:save $dest "$logger(color4)-$nick:$dest- $text"
	}
}


### Secondary Commands
proc logger:save {chan text} {
  global logger
   set log "[open "$logger(dir)[string tolower $chan.html]" a]"
   puts $log "$logger(color5)\[[strftime "%a%d%b.%H:%M:%S"]\]</font> [logger:strip $text]</font><br>"
  close $log
}


### Tertiary Commands
proc logger:strip {text} {
  global logger numversion
  if {$logger(strip) == "1"} {
    if {$numversion >= "1061700"} {
      set text "[stripcodes bcruag $text]"
    } else {
      regsub -all -- {\002,\003([0-9][0-9]?(,[0-9][0-9]?)?)?,\017,\026,\037} $text "" text
    }
  }
  return $text
}


### Time
proc logger:time {} {
  global logger
  foreach bind [binds time] {
    if {[string match "time * logger:time-save" $bind] == "1"} {
      unbind time - "[lindex $bind 2]" logger:time-save
    }
  }
  switch [string toupper $logger(time)] {
    DAY {
      bind time - "00 00 [strftime "%d" [expr [unixtime] + 86400]] * *" logger:time-save
    }
    WEEK {
      bind time - "00 00 [strftime "%d" [expr [unixtime] + ((7 - [strftime "%w"]) * 86400)]] * *" logger:time-save
    }
    MONTH {
      bind time - "00 00 01 [strftime "%m" [expr [unixtime] + ((32 - [strftime "%d"]) * 86400)]] *" logger:time-save
    }
  }
}

proc logger:time-save {minute hour day month year} {
  global logger
  if {[file exists "$logger(dir)#maroc-love.html"] == "1" } {
    if {[file exists "$logger(dir)[lindex [split #maroc-love "#"] 1]"] == "0" } {
      file mkdir $logger(dir)[lindex [split #maroc-love "#"] 1]
    }
    file rename -force "$logger(dir)#maroc-love.html" "$logger(dir)[lindex [split #maroc-love "#"] 1]/#maroc-love.[strftime "%G%b%d" [expr [unixtime] - 3600]].html"
  }
  set log "[open "$logger(dir)#maroc-love.html" w]"
  puts $log "<html><head><title>#maroc-love [strftime "%d%b%G"]</title></head>"
  puts $log "<body bgcolor=\'#000000\'><tt>"
  puts $log "<br>"
  puts $log "$logger(color5)Session Start: [strftime "%a %b %d %T %Y"]</font><br>"
  puts $log "$logger(color5)Session Ident: #maroc-love</font><br>"
  puts $log "$logger(color5)\[[strftime "%a%d%b.%H:%M:%S"]\]</font> $logger(color1)* Now talking in #maroc-love</font><br>"
  close $log
  putquick "TOPIC #maroc-love"
  logger:time
}


logger:time


putlog "TCL Logger.tcl Loaded!"
User avatar
DarkRaptor
Voice
Posts: 36
Joined: Sat Apr 15, 2006 2:39 am
Location: Trois-Rivières, Qc

Post by DarkRaptor »

Hi Ashoq,

I found this
DarkRaptor @ irc.undernet.org
Post Reply