1
if {[info exists queue($variable)} {
    if {[expr [unixtime] - $queue($variable)]<86400} {
        set calctime [expr [unixtime] - queue($variable)]
        putquick "PRIVMSG $channel :you cant because you need to wait $calctime"
    }
}
set queue($variable) [unixtime]

我的 Tcl 脚本中有这段代码,所以每个用户都需要等待 24 小时才能再次执行该命令。我会倒计时显示他们需要等待多少时间(小时、分钟、秒)才能再次执行此操作。但此刻我唯一能做的就是将秒数与$calctime

知道我该怎么做吗?绝对我的尝试$calctime是失败的:P

4

2 回答 2

1

将秒视为相对于具有时钟格式的纪元。不要遗漏-gmt 1,否则你会弄错几个小时。多少取决于你所在的时区。

putquick "PRIVMSG $channel :you cant because you need to wait \
  [clock format $calctime -format "%T" -gmt 1]"

或者自己计算:

set seconds [expr {$calctime % 60}]
set calctime [expr {$calctime / 60}]
set minutes [expr {$calctime % 60}]
set hours [expr {$calctime / 60}]
putquick "PRIVMSG $channel :you cant because you need to wait \
  $hours hours, $minutes minutes and $seconds seconds"
于 2012-12-30T07:42:47.200 回答
0

要显示用户必须等待的时间,您可以使用 eggdrop 特定命令duration

if {[info exists queue($variable)} {
    if {[clock seconds] - $queue($variable) < 60*60*24 } {
        set calctime [duration [expr {[clock seconds] - queue($variable)}]]
        putmsg $channel "you cant because you need to wait $calctime"
        return
    }
}
set queue($variable) [clock seconds]
# Do the command stuff
于 2012-12-31T15:16:57.800 回答