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.

Kick Message TCL

Old posts that have not been replied to for several years.
Locked
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

Hi there,

Yesterday I have wrote kick message tcl as belows;

bind msg o|o kick msg:kick

proc msg:kick {nick host hand chan arg} {
global botnick
set pass [lindex $arg 0]
set chan [lindex $arg 1]
set knick [lindex $arg 2]
set kreason [lrange $arg 3 end]
if {[lindex $arg 0]==""} {
if {[lindex $arg 1]==""} {
if {[lindex $arg 2]==""} {
puthelp "NOTICE $nick :Syntax: /msg $botnick KICK <password> <channel> <nickname> <reason>"
return 0
}}}
if {[passwdok $hand]==0} {
puthelp "NOTICE $nick :Sorry, Invalid Password"
return 0
}
if {[matchattr $hand o|o $chan]==0} {
puthelp "NOTICE $nick :You don't have access to perform this command."
return 0
}
if {[validchan $chan]==0} {
puthelp "NOTICE $nick :Sorry, I'm not monitoring $chan"
return 0
}
if {[onchan $knick $chan]==0} {
puthelp "NOTICE $nick :Sorry, I don't see $knick in $chan"
return 0
}
if {[strlwr $knick == [strlwr $botnick]} {
puthelp "NOTICE $nick :Yeah right, u can't kick me :smile:"
return 0
}
if {[matchattr [nick2hand $knick $chan] b]==1} {
puthelp "NOTICE $nick :Sorry, u can't kick channel bot."
return 0
}
if {[botonchan $chan]==0} {
puthelp "NOTICE $nick :Sorry, i'm not op in $chan."
return 0
}
if {[matchattr $hand o|o $chan]==1} {
if {[passwdok $hand]==1} {
if {[validchan $chan]==1} {
if {[onchan $knick]==1} {
if {[botonchan $chan]==1} {
if {$kreason == ""} {set reason "requested by $nick}
putserv "KICK $chan $knick $kreason"
puthelp "NOTICE $nick :You have kicked out by $nick"
return 1
}}}}
}

putlog "Kick Message TCL by blood_x loaded"

Then, when I'm trying to run it this message appears 'TCL error [msg:kick]: missing close-bracket'. Can someone help me to figure out this script?

Thanks.
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
w
woffer

Post by woffer »

locate this line
if {[strlwr $knick == [strlwr $botnick]} {

it's missing a ] (closing-bracket)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Yes,
if {[strlwr $knick == [strlwr $botnick]} {
should be
if {[strlwr $knick] == [strlwr $botnick]} {

Note, this script is full fo bugs.

in the proc declaration
proc msg:kick {nick host hand chan arg} {
you have the "chan" var defined, when there is no channel is a message.

You use "lindex" all the time on strings, when you should only do "lindex" on lists. To convert a string to a list, use the "split" command. This means
set pass [lindex $arg 0]
should be
set pass [lindex [split $arg] 0]

Note your use of the "passwdok" command.
if {[passwdok $hand]==0} {
You are passing it a hand but no password, thus it is not actualy checking anything. Note, if checking passwords, you need to do 2 passwdok checks. One to check if the password is blank, and another to check if a password is OK. This will prevent backdoors to the script.

Note your use of
if {[matchattr $hand o|o $chan]==0} {
This is not needed, as eggdrop checks for the required flag in the "bind" command
bind msg o|o kick msg:kick
Thus, the message it is set to output will never display.

Code: Select all

if {[matchattr $hand o|o $chan]==1} { 
if {[passwdok $hand]==1} { 
if {[validchan $chan]==1} { 
if {[onchan $knick]==1} { 
if {[botonchan $chan]==1} { 
if {$kreason == ""} {set reason "requested by $nick} 
putserv "KICK $chan $knick $kreason" 
puthelp "NOTICE $nick :You have kicked out by $nick" 
return 1 
}}}} 
This block of code is just a waste of CPU time. You have done all these checks above, and thus all of these would pass, and is not required. Even this has bugs in.

You are using $kreason to for the kick reason, yet if it is blank, you try to set it to somthing. The name using in this somthing is "reason", which lookslike it's missing it's "k".

Second the command that sends a notice to a user saying he was kicked
puthelp "NOTICE $nick :You have kicked out by $nick"
This is actualy send a message to the person that told the bot to do the kick, and tell him he kicked himself.
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

Thanks PPSLIm for the advice.
Can you help me to alter this script to be more secured with less bugs..
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Just follow the advice pointed out in my previous post, and the script should work fine.
User avatar
blood_x
Halfop
Posts: 77
Joined: Tue Nov 20, 2001 8:00 pm
Location: KL, Malaysia
Contact:

Post by blood_x »

Dear PPSLIM,

I have made several changes in this script using your advice. The new script as belows;

bind msg o|o kick msg:kick

proc msg:kick {nick host hand chan arg} {
global botnick
set pass [lindex [split $arg] 0]
set chan [lindex [split $arg] 1]
set knick [lindex [split $arg] 2]
set kreason [lrange [split $arg] 3 end]
if {[lindex [split $arg] 0]==""} {
if {[lindex [split $arg] 1]==""} {
if {[lindex [split $arg] 0]==""} {
puthelp "NOTICE $nick :Syntax: /msg $botnick KICK <password> <channel> <nickname> <reason>"
return 0
}}}
if {[passwdok $hand]==""} {
puthelp "NOTICE $nick :Sorry, Invalid Password"
return 0
}
if {[validchan $chan]==0} {
puthelp "NOTICE $nick :Sorry, I'm not monitoring $chan"
return 0
}
if {[onchan $knick $chan]==0} {
puthelp "NOTICE $nick :Sorry, I don't see $knick in $chan"
return 0
}
if {[strlwr $knick] == [strlwr $botnick]} {
puthelp "NOTICE $nick :Yeah right, u can't kick me :)"
return 0
}
if {[matchattr [nick2hand $knick $chan] b]==1} {
puthelp "NOTICE $nick :Sorry, u can't kick channel bot."
return 0
}
if {[botonchan $chan]==0} {
puthelp "NOTICE $nick :Sorry, i'm not op in $chan."
return 0
}
else {
if {$kreason == ""} {set kreason "requested by $nick} {
putserv "KICK $chan $knick $kreason"
puthelp "NOTICE $nick :You have kicked out by $nick"
return 1
}}
}

putlog "Kick Message TCL by blood_x loaded"

Can u check it for me to finalize this script.

Thanks.
Thank you for your support and commitments.

Sincerely,
fzAy®
http://www.iNTRACyber.com
(We Chat, We Share & We Learn)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is a much better version, but there are 1 or 2 oversights

Code: Select all

if {[lindex [split $arg] 0]==""} { 
if {[lindex [split $arg] 1]==""} { 
if {[lindex [split $arg] 0]==""} { 
puthelp "NOTICE $nick :Syntax: /msg $botnick KICK <password> <channel> <nickname> <reason>" 
return 0 
}}} 
You do not need all these "if" statments, you should only need to do one if of

Code: Select all

if {$knick == ""} {
Your use of "passwdok" is still incorect. If you read through tcl-commands.doc, you will find that you need to tell it the password the user is trying to send (this is common sence to. How can it tell that the password is correct, if you didn't give it the password.

Somthing like

Code: Select all

if {(![passwdok $hand $pass]) || (![passwdok $hand ""])} {
This will check the users password is correct, and check if it is a blank password, if it's balnk password, you tell them it's wrong, else you could have trouble on your hands.

change

Code: Select all

if {[strlwr $knick] == [strlwr $botnick]} { 
with

Code: Select all

if {[isbotnick $knick]} { 
for speed, and it's simpler.

Code: Select all

if {[botonchan $chan]==0} { 
puthelp "NOTICE $nick :Sorry, i'm not op in $chan." 
return 0 
} 
Should actualy be

Code: Select all

if {[botisop $chan]==0} { 
puthelp "NOTICE $nick :Sorry, i'm not op in $chan." 
return 0 
} 
Hope this helps.
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

actually that last one should be

Code: Select all

if {![botisop $chan]} { 
puthelp "NOTICE $nick :Sorry, i'm not op in $chan." 
return 0 
} 
for slightly better cpu efficiency
Locked