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 

RandomKick help.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Fri Jan 13, 2006 4:05 pm    Post subject: RandomKick help. Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Ehlanna
Voice


Joined: 21 Jul 2005
Posts: 15

PostPosted: Fri Jan 13, 2006 8:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Sat Jan 14, 2006 3:56 am    Post subject: Reply with quote

Thank you for your advice.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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