我在互联网上找到了这个脚本。它有点旧,开发人员页面早已不复存在。该代码有效,但我正在尝试对其进行一些清理。例如:如果周数 = 0,则不显示它。我从控制台收到有关额外令牌的错误。我试图用谷歌搜索这个错误,但没有任何可靠的东西出现。寻找一些见解。
评论部分是我“清理它”的尝试。这是我收到的错误。
Tcl 错误 [正常运行时间]:表达式“$::time(week) = 0”中的语法错误:表达式末尾的额外标记
评论该部分后,它工作正常。只是想清理一下,所以它不会返回“我已经在线 0 周 0 天 0 小时 1 分钟”。
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)
}