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.

Utimer question

Old posts that have not been replied to for several years.
Locked
O
OnFire
Voice
Posts: 23
Joined: Tue Oct 01, 2002 1:51 pm

Utimer question

Post by OnFire »

I'm trying to make a script which would op someone on the channel for 5 seconds then de-op them. The problem is I can't work out how the utimer command works. I've looked in tcl-commands.doc but I haven't found anything useful. Please help me!

Cheers.
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Hmm.

Post by spyda »

utimer <seconds> <tcl-command>
Description: executes the given Tcl command after a certain number of
seconds have passed
Returns: a timerID
Module: core
Ok. havn't realy worked with timers much. But I will give it a go!

I am not sure how many ways you can use a timer, but there is one way that I know of that worked in one of my scritps. With using a timer you can make it goto another proc or make it exec the command after the set time.

Code: Select all

utimer 5 another_proc $nick
or

Code: Select all

utimer 5 "pushmode $chan -o $who"
So I hope that helps you out a little and if anyone has anymore infomation on using timers, I would love to know!

------------
ThePope
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

If I had a better monitor, it would be better, because I could read the text people are writting. This system has seen too many games in it's time, so I excuse me if somthign has been covered, or I have misread anything.

utimer (and timer for that matter), use the same format.
(u)timer <(seconds)mins> <command>
As such, the command used, and the time vaklue used, are simple to work out.

The command, is pretty simple too, yet you have to be a little carful, as this is an area, where backdoors/exploits can be left in a script (accidentaly thoug, it's just bad coding practice that causes it).

In your case, you would use somthing like.

Code: Select all

utimer 5 [list putserv "MODE $chan -o $nick"]
While this will work for you (making sure the variables $chan and $nick are set correctly), it does pose one small issue.

What if the user changes there nickname in that 5 seconds?

Well, the answer is, they will remain +o in the channel.

For this, you will need to create a seperate proc, that will track nickname changes, and deop the person acordingly.
O
OnFire
Voice
Posts: 23
Joined: Tue Oct 01, 2002 1:51 pm

Post by OnFire »

Thanks a lot!
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:The command, is pretty simple too, yet you have to be a little carful, as this is an area, where backdoors/exploits can be left in a script (accidentaly thoug, it's just bad coding practice that causes it).

In your case, you would use somthing like.

Code: Select all

utimer 5 [list putserv "MODE $chan -o $nick"]
It's not actually 'bad coding' related per-se.. more like 'bad implementation' by robey and co. in the early eggdrop 1.2.x/1.3.x
days when they changed the behaviour of 'timer' and 'utimer'.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It has nothing to do with implimentation.

The same thing would apply for commands like "fileevent", and these do not use bad implimentation.

Tcl uses lists heavily, this is true for callin commands too.

Tcl will build a list, to pass to a proc it will call. This list is no different to any other list, it must be handled properly, IE, you shouldn't use string commands or treat it as a string (though each element in the list can be).

IE

Code: Select all

timer 5 "callproc $arg1 $arg2 $arg3"
This is a string, when it wants a list.

You can simply pass it a single command, wihtout fail

Code: Select all

timer 5 callproc
as you are only passing it a single item in a list, and Tcl will handle this correctly.

If timer was to use a method, that would escape the list for you, this would be incorrect, and wouldn't follow the standard.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote: IE

Code: Select all

timer 5 "callproc $arg1 $arg2 $arg3"
This is a string, when it wants a list.
Check the tcl-commands.doc and you will find this to be an incorrect statement. The quoting method was fine up to eggdrop1.1.5,
the only reason it was changed was to add stacking of commands to timers via semi-colon, which the tcl-commands.doc does not even reflect.

It says:
timer <minutes> <tcl-command>
Description: executes the given Tcl command after a certain number of minutes have passed
Also, note the "tcl-command" .. not "tcl-commands" or "tcl-command(s)".
Singular.

So in conclusion, I have successfully shown that, yes, indeed, it is bad implementation.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I beleive that "Bad documentation".

If eggdrop is following the same method as fileevent (Tcl provided), with it's (u)timer (eggdrop provided) command, then the implimentation is the same.

Documentation, whould reflect the implimentation. Implimentation should follow specifications. tcl-commands.doc is documentation, and as such, make it wrong, and not the command (as we don't have a specification).

Thus, the documenation should read
timer <minutes> <script>
Description: evaluates the given script after a certain number of
minutes have passed
Returns: a timerID
Module: core

utimer <seconds> <script>
Description: executes the given script after a certain number of
seconds have passed
Returns: a timerID
Module: core
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:I beleive that "Bad documentation".

If eggdrop is following the same method as fileevent (Tcl provided), with it's (u)timer (eggdrop provided) command, then the implimentation is the same.
No one said that it was following the same method as fileevent.
filevent's parameter is a "script"... (u)timer's parameter was "tcl-command" since pre-eggdrop 1.1.5... by changing it to "script"
in 1.2.x/1.3.x was rather both bad implementation AND bad judgment, in the fact that it could have caused scripts to break.
Locked