I've found this script on the internet. It's a bit old, and the developers page is long gone. The code works, but I'm trying to clean it up a bit. For example: If weeks = 0, then don't display it. I'm getting errors from the console about extra tokens. I've tried to google this error, but nothing solid is coming up. Looking for some insight.
The commented section is my attempt at "cleaning it up". Here's the error I'm receiving.
Tcl error [uptime]: syntax error in expression "$::time(week) = 0": extra tokens at end of expression
With the section commented, it works fine. Just trying to clean things up so it doesn't return "I've been online for 0 weeks 0 days 0 hours 1 minute".
bind pub "-|-" !uptime uptime
proc uptime { nick host handle channel text } {
putquick "PRIVMSG $channel :I have been online for [eggtime]."
}
proc eggtime {} {
set ::time(uptime) [expr [clock seconds]-$::uptime]
set ::time(week) [expr $::time(uptime)/604800]
set ::time(uptime) [expr $::time(uptime)-$::time(week)*604800]
set ::time(days) [expr $::time(uptime)/86400]
set ::time(uptime) [expr $::time(uptime)-$::time(days)*86400]
set ::time(hour) [expr $::time(uptime)/3600]
set ::time(uptime) [expr $::time(uptime)-$::time(hour)*3600]
set ::time(mins) [expr $::time(uptime)/60]
set ::time(uptime) [expr $::time(uptime)-$::time(mins)*60]
set ::time(secs) $::time(uptime)
#if {$::time(week) = 0} {
# set ::time(return) "$::time(days) day\(s\), $::time(hour) hour\(s\), $::time(mins) minute\(s\) and $::time(secs) second\(s\)"
#} else if {$::time(days) = 0} {
# set ::time(return) "$::time(hour) hour\(s\), $::time(mins) minute\(s\) and $::time(secs) second\(s\)"
#} {
# set ::time(return) "$::time(week) week\(s\), $::time(days) day\(s\), $::time(hour) hour\(s\), $::time(mins) minute\(s\) and $::time(secs) second\(s\)"
#}
set ::time(return) "$::time(week) week\(s\), $::time(days) day\(s\), $::time(hour) hour\(s\), $::time(mins) minute\(s\) and $::time(secs) second\(s\)"
return $::time(return)
}