egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

about timer

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Wed Nov 14, 2007 1:08 pm    Post subject: about timer Reply with quote

hello

when i put:

timer 1 procname

sometimes doesnt run the proc in 1 minite but 50 seconds

or utimer 100 procname

sometimes runs on 50 seconds can i fix that?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Nov 14, 2007 6:13 pm    Post subject: Reply with quote

How do you know that?
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Wed Nov 14, 2007 6:35 pm    Post subject: Reply with quote

i see the proc's results.. and some messages
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Nov 14, 2007 6:50 pm    Post subject: Reply with quote

Check to run timers are triggered by the "HOOK_MINUTELY" hook, which will occur whenever the minute-value has changed (usually at 00 seconds), and thus have an inaccuracy of less than a minute. If you need exactly 60 seconds, use utimer instead, as these timers are checked each second.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Wed Nov 14, 2007 6:58 pm    Post subject: Reply with quote

i use utimer.. but sometimes runs proc early.. ;/
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Nov 14, 2007 7:42 pm    Post subject: Reply with quote

utimers have an inaccuracy of less than a second, compared to timers which have an inaccuracy of less than a minute. If an utimer triggers much more early than this, it would usually indicate that the local clock on the system was advanced while the timer was "waiting".
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Nov 15, 2007 12:12 am    Post subject: Reply with quote

You could always set a var with [unixtime] at the beginning when the utimer is set, then within the proc set a different var with [unixtime] again and then subtract var2 from var1 and "if" it's 60 seconds, execute the rest of the proc, if not, calculate how many seconds remain and set a new utimer to run the proc again (which will calculate the time diff each time, etc.)
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Nov 15, 2007 4:56 am    Post subject: Reply with quote

That check would be pretty useless, as unixtime relies on the same timesource as HOOK_SECONDLY and timer-tracking. As such, the apparent time passed would always seem to be within one second of the desired time (or possibly longer, but never shorter).

The pretty much only reason why an utimer would start more than a second early, is as stated, that someone is playing around with the system-clock.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Fri Jan 09, 2009 6:58 pm    Post subject: Reply with quote

i have again that problem when i use eggdrop 1.6.9 version.. maybe the old that version have that problem? i want to run somethin on 5 minites and when i user timer 5 sometimes runs on ~3 minites etc.. and if i use utimer 300 (300 seconds) i have again the problem if the seconds is high.. the problem will be fixed if i use new version of eggdrop?


**i Use old version for something else because with new doesnt run Razz if you know about timer tell me Smile thanks
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Jan 09, 2009 9:26 pm    Post subject: Reply with quote

I made a small script as follows to test the accuracy of timers/utimers on my 1.6.19 bot :-

Code:

# time.tcl
# syntax !time <integer> <minute||second>

bind PUB - !time pTimeTrigger

proc pTimeTrigger {nick uhost hand chan text} {
    set txt [split [string trim $text]]
    if {[llength $txt] == 2} {
        set number [lindex $txt 0]
        set type [lindex $txt 1]
        if {![string equal $number 0]} {
            if {[string is integer $number]} {
                switch -- $type {
                    minute {
                        pTimeStarted $number $type $chan
                        timer $number [list pTimeEnded $number $type $chan]
                    }
                    second {
                        pTimeStarted $number $type $chan
                        utimer $number [list pTimeEnded $number $type $chan]
                    }
                }
            }
        }
    }
    return 0
}

proc pTimeStarted {number type chan} {
    putserv "PRIVMSG $chan :Time Started ($number $type test) [ctime [unixtime]]"
    return 0
}

proc pTimeEnded {number type chan} {
    putserv "PRIVMSG $chan :Time Ended ($number $type test) [ctime [unixtime]]"
    return 0
}


Output is as follows :-

<@arfer> !time 1 minute
<@Baal> Time Started (1 minute test) Sat Jan 10 01:04:16 2009
<@Baal> Time Ended (1 minute test) Sat Jan 10 01:05:00 2009
<@arfer> !time 60 second
<@Baal> Time Started (60 second test) Sat Jan 10 01:05:55 2009
<@Baal> Time Ended (60 second test) Sat Jan 10 01:06:55 2009
<@arfer> !time 5 minute
<@Baal> Time Started (5 minute test) Sat Jan 10 01:07:10 2009
<@Baal> Time Ended (5 minute test) Sat Jan 10 01:12:00 2009
<@arfer> !time 300 second
<@Baal> Time Started (300 second test) Sat Jan 10 01:12:10 2009
<@Baal> Time Ended (300 second test) Sat Jan 10 01:17:09 2009

The results confirm above posts suggesting that minutely timers are only accurate to the nearest minute but secondly timers (utimers) are pretty much correct give or take a second.

However, I cannot see why you have a 5 minute timer triggering after approximately 3 minutes. This does not seem possible.

Feel free to use the script to run tests, that is if eggdrop 1.6.9 allows the included commands. Frankly, I think it is time you updated your bot version and accepted that your current scripts will no longer function.
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Jan 10, 2009 11:26 am    Post subject: Reply with quote

thnx for that test script my results..

17:10:16] <@Ultralord> !time 1 minute
[17:10:17] <@botnick> Time Started (1 minute test) Sat Jan 10 17:09:25 2009
[17:10:52] <@botnick> Time Ended (1 minute test) Sat Jan 10 17:10:00 2009
[17:11:04] <@Ultralord> !time 1 minute
[17:11:05] <@botnick> Time Started (1 minute test) Sat Jan 10 17:10:13 2009
[17:11:51] <@botnick> Time Ended (1 minute test) Sat Jan 10 17:11:00 2009
[17:12:04] <@Ultralord> !time 1 minute
[17:12:06] <@botnick> Time Started (1 minute test) Sat Jan 10 17:11:14 2009
[17:12:51] <@botnick> Time Ended (1 minute test) Sat Jan 10 17:12:00 2009
[17:13:23] <@botnick> Time Started (5 minute test) Sat Jan 10 17:12:31 2009
[17:17:51] <@botnick> Time Ended (5 minute test) Sat Jan 10 17:17:00 2009
[17:19:19] <@botnick> Time Started (5 minute test) Sat Jan 10 17:18:14 2009
[17:23:51] <@botnick> Time Ended (5 minute test) Sat Jan 10 17:23:00 2009

some tests.. sometimes like 1st bind i have problem.. is it possible the bot have count problem if the bot have lag? but i dont see any problem with any of my scripts and the scripts doesnt lag because i have some spam message and is ok..

thnx
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Sat Jan 10, 2009 11:36 am    Post subject: Reply with quote

The results shown above using my script would indicate that timer events are working as expected on your bot. ie. triggering to the nearest minute

What I know as lag is generally a time delay in the IRC network connection. This would cause a delay to occur before the channel output is seen, but I would not expect it to affect timer/utimer triggering.
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Jan 10, 2009 11:39 am    Post subject: Reply with quote

so how i can fix that to have correct time ? is it possible to fix that problem if i use the latest version of eggdrop ?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Jan 10, 2009 11:52 am    Post subject: Reply with quote

As stated earlier, use the proper timer for the proper accuracy. timer gives you an accuracy to the minute, utimer gives you an accuracy to the second.

Also, you cannot script around lag, as that is not within the context of eggdrop scripting but network dependant.

The way I see it, there is nothing to fix (apart from using utimers when you need precision down to the second). Upgrading/downgrading your eggdrop will have no impact whatsoever on this issue.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
ultralord
Master


Joined: 06 Nov 2006
Posts: 255

PostPosted: Sat Jan 10, 2009 11:56 am    Post subject: Reply with quote

ye i try the before script with 300 seconds and is ok same second.. i am going to user utimer 300 for timer 5 to see if it works better.

thnx
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber