| View previous topic :: View next topic |
| Author |
Message |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Fri Jan 13, 2006 4:05 pm Post subject: RandomKick help. |
|
|
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: | 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. |
|
| Back to top |
|
 |
Ehlanna Voice
Joined: 21 Jul 2005 Posts: 15
|
Posted: Fri Jan 13, 2006 8:20 pm Post subject: |
|
|
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)! |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Sat Jan 14, 2006 3:56 am Post subject: |
|
|
| Thank you for your advice. |
|
| Back to top |
|
 |
|