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.

Working with timers...

Help for those learning Tcl or writing their own scripts.
Post Reply
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Working with timers...

Post by Fill »

Hi again :lol:

I'm trying to make a script that when I type !nickchange <nickname>, the bot will send a msg to the chan asking that user to change its' nickname.

If he doesn't change the nickname within a minute, the bot will set mode +b Nick!*@* and kick the user.

I've done this:

Code: Select all

bind pubm - "#cyber-world !nickchange*" nickchange

proc nickchange {nick host handle chan text} {
set user [lindex $text 1]
if { ([isop $nick $chan] == 1) || ([isvoice $nick $chan] == 1) || ([ishalfop $nick $chan] == 1) } {
 puthelp "PRIVMSG $chan :\001ACTION $user: You have a minute to change your nickname by typing /nick NewNick. If you don't change it, you'll get banned. Thanks.\001"
  utimer  .... ?? What about now?
 }
}
So now what I need is to say the bot to wait a minute, and if the nickname, after a minute, is still on the channel, ban it and kick it. How could I do that?

Thanks in advance,
Fill
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off, don't do this:

Code: Select all

set user [lindex $text 1]
Text is obviously not a list, and you should thus not use list-operations on it. You'll get away with it in some cases, but it'll come back to haunt you sooner or later. Consider using split to convert the string into a valid tcl-list.

Next, I'd suggest you create a second proc for the check'n'kick part (the code could be done directly in the timer, but it'd be "messy").
Simplest would probably be to pass the nickname as an argument to this proc, test using the onchan command, and if needed, kick/ban.

Code: Select all

proc checkkick {nickname} {
 if {[onchan $nickname #cyber-world]} {
  newchanban "#cyber-world" "$nickname!*@*" "eggdrop" "Offensive nick, !nickchange"
 }
}
To create the timer, use something like this:

Code: Select all

utimer 60 [list checkkick $user]
This is done to encapsulate the data, and protect your eggdrop from remote code execution.
NML_375
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

the utimer thing worked for me. Thanks for the help about the list and string problem. It worked fine, but tomorrow or so I'll try and fix it by using the split command. You see, I'm a beginner, so I need some help with these scripts, and those tips are good to improve my skills :P

Once again, thanks
See ya
Post Reply