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.

A "drawing by lots" bot?

Old posts that have not been replied to for several years.
Locked
e
eiSiQ

A "drawing by lots" bot?

Post by eiSiQ »

Hi There!

I want to code such a bot.

I need a thing before I can start:

How can i randomly pick one out of the Nicklist and give him 30 seconds of time to say anything?

How to do that?

Thanks for your help! :)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

well.... all u have to do is to use "foreach u [chanlist #channel]" to find all the nicks in the channel, then use "rand" to pick one of them. after that u just have to activate a utimer which will be canceled if the nick responds in time... 30 secs :)
Elen sila lúmenn' omentielvo
e
eiSiQ

Post by eiSiQ »

ah ok, thx!

can you give me a link to a documentation, where to read all those things?

thx! :)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

http://www.egghelp.org/enhance.htm#tclscripts

that's a good place to start :)
also read the tcl-commands.doc in your eggdrop's "doc-dir" it has alot of commands u might find useful
Elen sila lúmenn' omentielvo
e
eiSiQ

Post by eiSiQ »

thanks!

i'll have a look there! :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

set rnick [lindex [chanlist #channel] [expr [rand [llength [chanlist #channel]]] - 1]]
That will get you a random nickname.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Code: Select all

set rnick [lindex [chanlist #channel] [expr [rand [llength [chanlist #channel]]] - 1]]
He probably doesn't want to pick the bot's nick. Also you don't need the -1 since rand n returns 0 to n-1.

Code: Select all

set nicks [lrange [chanlist #chan] 1 end]
set len [llength $nicks]
set randnick [lindex $nicks [rand $len]]
This assumes that the bot's nick is the first in the list. I don't think that's a documented feature but it generally works out.

Now to do your second part, giving him 30 seconds to say something, you have to use a pubm bind and a utimer. Check tcl-commands.doc for more information. If you want t ocatch actions too (like /me says hi), then use a ctcp bind.
e
eiSiQ

Post by eiSiQ »

oh thx!

can you tell me more about that ctcp bind?

because I don't know much about tcl programming.

oh and btw. the nicklist is sorted in alphabetically order, so the bot nick isn't the first in the list, but thanks anyway! :)
Locked