| View previous topic :: View next topic |
| Author |
Message |
n00bie Voice

Joined: 20 Nov 2005 Posts: 7 Location: localhost
|
Posted: Mon Dec 19, 2005 2:21 am Post subject: Christmas & New Year Countdown |
|
|
Hello Guys, is there any one who can make a tcl scripts for counting down the christmas & new year day, the bot will announce on the set channel every 10 minutes on #countdown channel.
Example: <@Bot> 6 days, 144hours and 5184000 minutes before Christmas [25th December] and some days, some hours, some minutes before New Year [1st January, 2006]
i want the bot to announce that every 10 minutes on the channel and also to set on the topic how many days only before christmas & new year ... umm... if it can be done, i want the bot to set the topic only once a day, not every 10 minutes .. i hope you guys understand my english ... thanks  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Dec 19, 2005 8:02 am Post subject: |
|
|
After RTFM (Reading The F*cking Manual) here I got to this:
| Code: | bind time - "?0 *" count:down
proc count:down args {
set christmas "[duration [expr {[clock scan 12/25/05] - [clock seconds]}]]"
set newyear "[duration [expr {[clock scan 01/01/06] - [clock seconds]}]]"
puthelp "PRIVMSG #channel :$christmas before Christmas \[25th December\] and $newyear before New Year \[1st January, 2006\]"
} |
this will msg #channel every 10 minutes the time left before christmas and new year. As for posting the topic every day, the search function will help you.
Edit: fixed a fragment in my last sentence _________________ Follow me on GitHub
- Opposing
Public Tcl scripts
Last edited by Sir_Fz on Mon Dec 19, 2005 2:21 pm; edited 2 times in total |
|
| Back to top |
|
 |
n00bie Voice

Joined: 20 Nov 2005 Posts: 7 Location: localhost
|
Posted: Mon Dec 19, 2005 1:16 pm Post subject: |
|
|
thanks  |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed Dec 05, 2007 8:33 am Post subject: |
|
|
I know this is an old topic, but where would I change the time between announcing?
I'd like it to announce once every 24 hours. |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Dec 05, 2007 9:50 am Post subject: |
|
|
Change the bind mask to "00 12 *" to have it announced at 12:00 every day. _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Astur Voice
Joined: 23 Nov 2007 Posts: 16
|
Posted: Wed Dec 05, 2007 11:24 am Post subject: |
|
|
Is it possible to have the time in German? (weeks= Wochen, days= Tage, hours= Stunden, minutes= Minuten and seconds= Sekunden)
What I have to change? |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed Dec 05, 2007 12:17 pm Post subject: |
|
|
| user wrote: | | Change the bind mask to "00 12 *" to have it announced at 12:00 every day. |
Thanks alot, i've looked at the manual, and was wondering, the 12:00 is that AM or PM? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Dec 05, 2007 1:33 pm Post subject: |
|
|
| Astur wrote: | Is it possible to have the time in German? (weeks= Wochen, days= Tage, hours= Stunden, minutes= Minuten and seconds= Sekunden)
What I have to change? |
You can apply [string map] over the output (i.e. [string map {weeks Wochen} <output>]). Try it.
| starpossen wrote: | | Thanks alot, i've looked at the manual, and was wondering, the 12:00 is that AM or PM? |
it's PM (00 is AM) _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Wed Dec 05, 2007 1:38 pm Post subject: |
|
|
| Sir_Fz wrote: |
it's PM (00 is AM) |
Thanks, I will read some more in the famous manual  |
|
| Back to top |
|
 |
Astur Voice
Joined: 23 Nov 2007 Posts: 16
|
Posted: Wed Dec 05, 2007 2:26 pm Post subject: |
|
|
| Sir_Fz wrote: | | Astur wrote: | Is it possible to have the time in German? (weeks= Wochen, days= Tage, hours= Stunden, minutes= Minuten and seconds= Sekunden)
What I have to change? |
You can apply [string map] over the output (i.e. [string map {weeks Wochen} <output>]). Try it. |
Thanks, it works  |
|
| Back to top |
|
 |
wiiguy Voice
Joined: 30 Nov 2007 Posts: 9
|
Posted: Wed Dec 05, 2007 3:53 pm Post subject: |
|
|
i live in the time zone gmt+1
how do that work ?
and i want at the last minute of new year or cristmas it will count off from 10 seconds
thank for your time reading this |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Dec 05, 2007 5:48 pm Post subject: |
|
|
| wiiguy wrote: | | i live in the time zone gmt+1 |
You'll have to figure out what time zone your bot's on and add/subtract hour(s). For example if the bot's timezone is gmt+2, you'll have to subtract 3600 seconds from [clock seconds]. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Thu Dec 06, 2007 7:26 am Post subject: |
|
|
Okay it's working nicely:
| Code: |
[12:00:07] <@Bot> 2 weeks 3 days 12 hours untill Christmas [24th December]
|
But i'd like to change it, so it only shows days, and not weeks, I have been looking at that manual mentioened earlier, but I have to admit, i'm a bit lost on this one.
Any help? |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Dec 06, 2007 8:12 am Post subject: |
|
|
| starpossen wrote: | | i'd like to change it, so it only shows days, and not weeks |
That can't be done using the built in duration command, but you can make your own
| Code: | # standard english names
set duration_en {
31536000 {" year" " years"}
604800 {" week" " weeks"}
86400 {" day" " days"}
3600 {" hour" " hours"}
60 {" minute" " minutes"}
1 {" second" " seconds"}
}
# abbreviated english names
set duration_en_compact {
31536000 {"y" "y"}
604800 {"w" "w"}
86400 {"d" "d"}
3600 {"h" "h"}
60 {"m" "m"}
1 {"s" "s"}
}
# english names, but no years/weeks
set duration_en_custom {
86400 {" day" " days"}
3600 {" hour" " hours"}
60 {" minute" " minutes"}
1 {" second" " seconds"}
}
# rename this proc if you want to keep the built in "duration" command
proc duration {time {lang en} {join " "}} {
set out {}
foreach {secs names} [set ::duration_$lang] {
if {$time<$secs} continue
set val [expr {$time/$secs}]
lappend out $val[lindex $names [expr {$val!=1}]]
if {![incr time [expr {-$val*$secs}]]} break
}
join $out $join
} |
| Code: | # tests:
% duration 3317790
5 weeks 3 days 9 hours 36 minutes 30 seconds
% duration 3317790 en_compact
5w 3d 9h 36m 30s
% duration 3317790 en_custom
38 days 9 hours 36 minutes 30 seconds |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Thu Dec 06, 2007 5:48 pm Post subject: |
|
|
Will try and mess around with that, by the way, I was wondering, would it be possible to a public command to show time left until set date?
like !xmas
and bot would respond with the timeleft. |
|
| Back to top |
|
 |
|