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 に答える