global time name date txt wait_until ctime
set wait_until [expr [clock seconds]]
bind pub - !ep pub:countdown
bind dcc n add dcc:add

proc pub:countdown {nick uhost hand chan text} {
	set ctime [expr [clock seconds]]
	if {$ctime < $wait_until} {
		return 0
	}
	set fname "sv.txt"
	set fp [open $fname "r"]
	set data [read $fp]
	set line "0"
	while { [clock scan [lindex $data $line]] < $ctime } {
		incr $line 2
		lreplace $data 0 1
		set fp [open $fp "w"]
		puts $fp [join $lines "\n"]
	}
	close $fp
	set txt [lindex $data 1]
	set dur [duration [expr [clock scan [lindex $data 0]]-$ctime]]
	set wait_until [expr [$ctime + 5]]
	putquick "notice $nick :There are $dur until $txt"
}

proc dcc:add {hand idx arg} {
	split $arg
	set time [lindex $arg 0]
	set name [lindex $arg 1]
	set fname "sv.txt"
	set fp [open $fname "a"]
	puts $fp \"$time\"
	puts $fp \"$name\"
	close $fp
	putdcc $idx "$name is on at $time"

}