This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
uHost
Voice
Posts: 2 Joined: Thu Aug 20, 2009 2:13 pm
Post
by uHost » Thu Aug 20, 2009 2:29 pm
Hello.
can anyone help with a script?
I need a script calculating time in minutes. For exemple:
18:55 20/08/2009 >> Today
<uHost> !time 10
<Eggie> 19:05 20/08/2009
<uHost> !time 1440
<Eggie> 18:55 21/08/2009
I think you can understand me.
tomekk
Master
Posts: 255 Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:
Post
by tomekk » Thu Aug 20, 2009 2:47 pm
Code: Select all
# tomekk, http://forum.egghelp.org/viewtopic.php?t=17119
bind pub -|- !time make_time
proc make_time { nick uhost hand chan arg } {
set arg [lindex [split $arg] 0]
if {[regexp {^[0-9]+$} $arg]} {
set cdate [clock format [expr [clock seconds] + [expr $arg * 60]] -format "%H:%M %d/%m/%Y"]
putquick "PRIVMSG $chan :$cdate"
}
}
putlog "make-time.tcl ver 0.1 by tomekk loaded"
try, didn't test ;p
uHost
Voice
Posts: 2 Joined: Thu Aug 20, 2009 2:13 pm
Post
by uHost » Thu Aug 20, 2009 4:28 pm
Hehe
It works, but has a bug. I can't use more than 9 numbers.
<uHost> !time 12345678
<Eggie> 06:41 09/02/2033
<uHost> !time 123456789
<Eggie> 05:35 01/03/
1972
Thanks
arfer
Master
Posts: 436 Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK
Post
by arfer » Thu Aug 20, 2009 4:47 pm
The value of the supplied argument is too high and the result of the expr command has wrapped to a negative integer value. Hence, instead of adding to [clock seconds] which results in a future time string, it has been deducted from [clock seconds] which has given a past time string. It is not so much a bug, more of a limitation.
I must have had nothing to do