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.

[Solved] Error in logger.tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Carlin0
Halfop
Posts: 47
Joined: Tue Dec 04, 2018 3:41 pm
Location: Italy

[Solved] Error in logger.tcl

Post by Carlin0 »

the script

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) "logs/"

#;;; 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) "Month"



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



### Events
bind join - "#* *!*@*" logger:join
bind part - "#* *!*@*" logger:part
bind sign - "#* *!*@*" logger:quit
bind pubm - "#* *" logger:text
bind nick - "#* *" logger:nick
bind kick - "#* *" logger:kick
bind mode - "#* *" logger:mode
bind topc - "#* *" logger:topic
bind raw - "333" logger:topic-author
bind ctcp - "ACTION" logger:action


### Primary Commands
proc logger:join {nick uhost handle chan} {
  global logger botnick
  if {$nick == $botnick} {
    set log "[open "$logger(dir)$chan.log" a]"
    puts $log "\r"
    puts $log "Session Start: [strftime "%a %b %d %T %Y"]\r"
    puts $log "Session Ident: $chan\r"
    puts $log "\[[strftime "%H:%M"]\] * Now talking in $chan\r"
    close $log
  } else {
    logger:save $chan "* $nick ($uhost) has joined $chan"
  }
}

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

proc logger:quit {nick uhost handle chan reason} {
  logger:save $chan "* $nick ($uhost) Quit ($reason)"
}

proc logger:text {nick uhost handle chan text} {
  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 "<$nick> $text"
}

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

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

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

proc logger:topic {nick uhost handle chan topic} {
  if {$nick == "*"} {
    logger:save $chan "* Topic is '$topic'"
  } else {
    logger:save $chan "* $nick changes topic to '$topic'"
  }
}

proc logger:topic-author {from keyword text} {
  logger:save [lindex $text 1] "* Set by [lindex $text 2] on [strftime "%a %b %d %T" [lindex $text 3]]"
}

proc logger:action {nick uhost handle dest keyword text} {
  if {[validchan $dest] == "1"} {
    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 "* $nick $text"
  }
}


### Secondary Commands
proc logger:save {chan text} {
  global logger
  set log "[open "$logger(dir)$chan.log" a]"
  puts $log "\[[strftime "%H:%M"]\] [logger:strip $text]\r"
  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
  foreach channel [channels] {
    if {[file exists "$logger(dir)$channel.log"] == "1"} {
      file rename -force "$logger(dir)$channel.log" "$logger(dir)${channel}_\[[strftime "%Y.%m.%d"]\].log"
    }
    set log "[open "$logger(dir)$channel.log" w]"
    puts $log "\r"
    puts $log "Session Start: [strftime "%a %b %d %T %Y"]\r"
    puts $log "Session Ident: $channel\r"
    puts $log "\[[strftime "%H:%M"]\] * Now talking in $channel\r"
    close $log
    putquick "TOPIC $channel"
  }
  logger:time
}


logger:time


putlog "TCL Logger.tcl Loaded!"
the error

Code: Select all

Tcl error in file 'lurk':
invalid bareword "08"
in expression "1739004974 + ((32 - 08) * 86400)";
should be "$08" or "{08}" or "08(...)" or ... (invalid octal number?)
    (parsing expression "1739004974 + ((32 - 08...")
    invoked from within
"expr [unixtime] + ((32 - [strftime "%d"]) * 86400)"
    (procedure "logger:time" line 16)
    invoked from within
"logger:time"
    (file "scripts/logger.tcl" line 184)
    invoked from within
"source scripts/logger.tcl"
    (file "lurk" line 639)
* FILE DI CONFIGURAZIONE NON CARICATO (NON TROVATO, O ERRORE)
thanks in advance :)
Last edited by Carlin0 on Sat Feb 08, 2025 5:59 pm, edited 1 time in total.
"From the diamonds nothing is born, from the manure the flowers are born ..."
--- F. De Andrè ---
User avatar
CrazyCat
Revered One
Posts: 1330
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Error in logger.tcl

Post by CrazyCat »

This is because in many languages, any number begining with 08 (including 08 itself) is interpreted as an octal number.
Use strfitme "%e" rather than %d which adds a leading 0
User avatar
Carlin0
Halfop
Posts: 47
Joined: Tue Dec 04, 2018 3:41 pm
Location: Italy

Re: [Solved] Error in logger.tcl

Post by Carlin0 »

Thanks CrazyCat it works fine ;)
"From the diamonds nothing is born, from the manure the flowers are born ..."
--- F. De Andrè ---
Post Reply