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.

RandomKick help.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

RandomKick help.

Post by username »

Hi I need some modification help with my script. I want it to count kicks and remember last kicked person and put it to kick reason near phrase that it tooks from file. This is what I do myself:

Code: Select all

set authors "username"
set ver "1.0"

set reasonfolder "scripts"

bind pub - !рк pub:rk
bind pub - !rk pub:rk

proc pub:rk { nick uhost hand chan text } {
global reasonfolder

set victimuser [lindex [chanlist $chan] [rand [llength [chanlist $chan]]]]
set random_reason [rk:load $reasonfolder/kickreason.txt]

putkick $chan $victimuser [lindex $random_reason [rand [llength $random_reason]]]}

putlog "$nick randomly kicked"

putlog "RandomKick ver$ver by $authors loaded"

proc rk:load {file} {
set fd [open $file r]
while {![eof $fd]} {
 gets $fd dline
 lappend var $dline
 }
close $fd
return $var
}
Thank you.
E
Ehlanna
Voice
Posts: 15
Joined: Thu Jul 21, 2005 12:08 pm

Post by Ehlanna »

I am not even going to ask why you want to do this, but ... just some comments:

I would assign the chanlist nlist to a variable as it is possible (I am assuming) that as it has to be evaulated twice you could get a mismatch between the random number and the list of nicks. You do not seem to be avoiding kicking the nick of the bot itself.

Depending on what you wish to have more of - memory or I/O overhead - either load up the test file of reasons just once and access it as a global or (do as you are doing) read it each time.

Please bear in mind that tcl is not my long suit! - others may have better ideas to improve.

Oh, before I forget - do not forget to check the file exists (and is readable by the bot)!
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Thank you for your advice.
Post Reply