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 

Working with timers...

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


Joined: 18 Jan 2009
Posts: 80

PostPosted: Thu Feb 12, 2009 1:29 pm    Post subject: Working with timers... Reply with quote

Hi again Laughing

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:

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
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Feb 12, 2009 3:29 pm    Post subject: Reply with quote

First off, don't do this:
Code:
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:
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:
utimer 60 [list checkkick $user]

This is done to encapsulate the data, and protect your eggdrop from remote code execution.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Thu Feb 12, 2009 6:38 pm    Post subject: Reply with quote

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 Razz

Once again, thanks
See ya
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