14/11/2023, 09:03
Hello coders,
good day to all, this tcl is working perfect.
Can someone help me to fix the autoshow message in the channel every 4 hours?
I've added a bind cron, but it is not working. i am not sure if i do it correctly.
And also, can we add it on autotopic every midnight?
Thank you in advance.
good day to all, this tcl is working perfect.
Can someone help me to fix the autoshow message in the channel every 4 hours?
I've added a bind cron, but it is not working. i am not sure if i do it correctly.
And also, can we add it on autotopic every midnight?
Thank you in advance.
tcl
###############################################
# Countdown.tcl 0.1 by #egghelp@efnet (KuNgFo0)
#
# Set the next line as the countdown msg you want to say
set countdown_msg "Its getting nearer - Blackpool get prepared - the nutters are on the way !!!"
# Set the next line as the channels you want to run in
set countdown_chans "#christmas"
# Set the next line as the date to count down to (Month day time year)
set countdown_time "December 25 12:00:00 2023"
# Set the next line as the command you want to initiate the countdown update
set countdown_command "!countdown"
bind cron - "?0 *" pub_countdown:cron
bind pub - $countdown_command pub_countdown:cron
set countdown_time [clock scan $countdown_time]
proc pub_countdown:cron {nick uhost hand chan arg} {
global countdown_msg countdown_chans countdown_time
if {([lsearch -exact [string tolower $countdown_chans] [string tolower $chan]] != -1) || ($countdown_chans == "*")} {
set countdown_diff [expr abs($countdown_time - [unixtime])]
set countdown_secs $countdown_diff
set countdown_mins [expr $countdown_diff / 60]
set countdown_hours [expr $countdown_diff / 3600]
set countdown_days [expr $countdown_diff / 86400]
set countdown_secs [expr int($countdown_secs - (int($countdown_mins) * 60))]
set countdown_mins [expr int($countdown_mins - (int($countdown_hours) * 60))]
set countdown_hours [expr int($countdown_hours - (int($countdown_days) * 24))]
set countdown_days [expr int($countdown_days)]
if {$countdown_days > 0} {
set countdown_temp "$countdown_days day"
if {$countdown_days != 1} {
append countdown_temp "s"
}
}
if {$countdown_hours > 0} {
lappend countdown_temp $countdown_hours hour
if {$countdown_hours != 1} {
append countdown_temp "s"
}
}
if {$countdown_mins > 0} {
lappend countdown_temp $countdown_mins minute
if {$countdown_mins != 1} {
append countdown_temp "s"
}
}
if {$countdown_secs > 0} {
lappend countdown_temp $countdown_secs second
if {$countdown_secs != 1} {
append countdown_temp "s"
}
}
if {$countdown_time > [unixtime]} {
putserv "PRIVMSG $chan :There are: $countdown_temp left till [ctime $countdown_time], $countdown_msg"
} else {
putserv "PRIVMSG $chan :There have been: $countdown_temp since [ctime $countdown_time], $countdown_msg"
}
}
}
putlog "*** Countdown.tcl 0.1 by #egghelp@efnet loaded"