| View previous topic :: View next topic |
| Author |
Message |
mcdarby Halfop

Joined: 16 Jul 2002 Posts: 69 Location: Bangor, Pennsylvania
|
Posted: Fri Sep 29, 2006 4:29 am Post subject: Help with this bad command kick script |
|
|
Hey there, I was trying to write a TCL script for my bot to kick on any of the listed commands being entered by anyone in any of the two channels I was trying to set it up in. This is what I have for a script, and when I tested it, the bot doesn't do anything in response.
| Code: | set bancomm(chans) "#Fuzzy #ForestHaven"
set bancomm(comms) "!find @find !list @list !packs @packs !search @search !warezlist @warezlist !xdcclist @xdcclist"
set bancomm(chans) [string tolower $bancomm(chans)]
set bancomm(comms) [string tolower $bancomm(comms)]
foreach chan $bancomm(chans) {bind pubm -|- "$chan $bancomm(comms)" pub:bancomms}
proc pub:bancomms {nick host hand chan arg} {
putserv "KICK $chan $nick The command you just entered is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
} |
Any idea what I may have done wrong?[/code] |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Sep 29, 2006 6:45 am Post subject: |
|
|
Try:
| Code: | set bancomm(chans) "#Fuzzy #ForestHaven"
set bancomm(comms) "!find @find !list @list !packs @packs !search @search !warezlist @warezlist !xdcclist @xdcclist"
bind pubm -|- {*} pub:bancomms
proc pun:bancomms {nickname hostname handle channel text} {
if {[lsearch -exact [string tolower $bancomm(chans)] [string tolower $channel] == -1} { return }
set command [lindex [split $text] 0]
if {[lsearch -exact [string tolower $bancomm(comms)] [string tolower $command]] == -1} { return }
putserv "KICK $channel $nickname :The command you just entered '$command' is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
} |
Not Tested. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
Azeem Voice
Joined: 26 Sep 2006 Posts: 14
|
Posted: Fri Sep 29, 2006 7:30 am Post subject: |
|
|
| Code: |
#Number of channels..
set channels "#Channel1 #channel2"
#Command to ban..
set bancommands {
"!find"
"@find"
"!list"
"@list"
"!packs"
"@packs"
"!search"
"@search"
"!warezlist"
"@warezlist"
"!xdcclist"
"@xdcclist"
}
bind pubm -|- * pub:bancomms
proc pub:bancomms {nick host hand chan arg} {
global bancommands channels
set command [string tolower [lindex $arg 0]]
foreach badcom [string tolower $bancommands] {
if {([string match -nocase *$badcom* $command]) && ([lsearch -exact [string tolower $channels] [string tolower $chan] ] != -1)} {
putserv "KICK $chan $nick :The command you just entered is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
}
}
}
|
Try it tested working.. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Sep 29, 2006 11:25 am Post subject: |
|
|
@Azeem:
Unfortunately, that code is flawed, as you are using list commands on strings. What makes matters worse is that you use them on unchecked strings supplied by random users. Should any user in your channel write something containing characters such as (but not limited to) "{[]}", that code will start behaving very badly. Also, lsearch would generally be faster than iterating through the whole list of "badwords", especially if you keep it sorted.
@Tosser^^:
Nice code, you should however use something like this when building the channel and badwords lists:
| Code: | set bancomm(chans) [list #Fuzzy #ForestHaven]
set bancomm(comms) [list !find @find .....] |
Also a suggestion, change the mask of the binding from "*" to "% !*" and "% @*" to enhance performance slightly _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
mcdarby Halfop

Joined: 16 Jul 2002 Posts: 69 Location: Bangor, Pennsylvania
|
Posted: Fri Sep 29, 2006 3:51 pm Post subject: |
|
|
@nml375:
You mean change that bind from
| Code: | | bind pubm -|- {*} pub:bancomms |
to
| Code: | | bind pubm -|- {% !* and % @*} pub:bancomms |
?
Well, I would think that
| Code: | | bind pubm -|- {% *} pub:bancomms |
might be better there. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Sep 29, 2006 3:54 pm Post subject: |
|
|
@mcdarby:
Nope, if it was'nt clear enough; this is what I intended:
| Code: | bind pubm -|- "% !*" pub:bancomms
bind pubm -|- "% @*" pub:bancomms |
Replacing "*" with "% *" would be quite pointless... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
mcdarby Halfop

Joined: 16 Jul 2002 Posts: 69 Location: Bangor, Pennsylvania
|
Posted: Fri Sep 29, 2006 8:37 pm Post subject: |
|
|
Okay, I just tested Tosser's script, where I have this
| Code: | set badcomm(chans) "#Fuzzy #ForestHaven"
set badcomm(comms) "!find @find !list @list !packs @packs !search @search !warezlist @warezlist !xdcclist @xdcclist"
bind pubm -|- "% !*" pub:badcommands
bind pubm -|- "% @*" pub:badcommands
proc pub:badcommands {nickname hostname handle channel text} {
if {[lsearch -exact [string tolower $badcomm(chans)] [string tolower $channel]] == -1} { return }
set command [lindex [split $text] 0]
if {[lsearch -exact [string tolower $badcomm(comms)] [string tolower $command]] == -1} { return }
putserv "KICK $channel $nickname :The command you just entered '$command' is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
} |
And I was getting a TCL error that is the following:
| Code: | | <BOT> [20:25] Tcl error [pub:badcommands]: can't read "badcomm(chans)": no such variable |
And .set errInfo shows that following:
| Code: | <BOT> [20:25] #McDarby# set errorInfo
<BOT> Currently: can't read "badcomm(chans)": no such variable
<BOT> Currently: while executing
<BOT> Currently: "string tolower $badcomm(chans)"
<BOT> Currently: (procedure "pub:badcommands" line 2)
<BOT> Currently: invoked from within
<BOT> Currently: "pub:badcommands $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5" |
Which I can't seem to find what is wrong now |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Sep 29, 2006 9:03 pm Post subject: |
|
|
Use:
| Code: | set badcomm(chans) "[list #Fuzzy #ForestHaven]"
set badcomm(comms) "[list !find @find !list @list !packs @packs !search @search !warezlist @warezlist !xdcclist @xdcclist]"
bind pubm -|- "% !*" pub:badcommands
bind pubm -|- "% @*" pub:badcommands
proc pub:badcommands {nickname hostname handle channel text} {
global badcomm
if {[lsearch -exact [string tolower $badcomm(chans)] [string tolower $channel]] == -1} { return }
set command [lindex [split $text] 0]
if {[lsearch -exact [string tolower $badcomm(comms)] [string tolower $command]] == -1} { return }
putserv "KICK $channel $nickname :The command you just entered '$command' is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
} |
_________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Sat Sep 30, 2006 2:01 am Post subject: |
|
|
Why would you use " " around [list]?
You need to start writing cleaner code tosser.
| Code: | set badcomm(chans) [list #Fuzzy #ForestHaven]
set badcomm(comms) [list !find @find !list @list !packs @packs !search @search !warezlist @warezlist !xdcclist @xdcclist]
bind pubm -|- "% !*" pub:badcommands
bind pubm -|- "% @*" pub:badcommands
proc pub:badcommands {nickname hostname handle channel text} {
global badcomm
if {[lsearch -exact [string tolower $badcomm(chans)] [string tolower $channel]] >= 0} {
set command [lindex [split $text] 0]
if {[lsearch -exact [string tolower $badcomm(comms)] [string tolower $command]] >= 0} {
putserv "KICK $channel $nickname :The command you just entered '$command' is not allowed here due to it being commonly used by art and software pirates to find out whether or not a server hosts file archieves. Continuing to enter it will result in you being banned from the channel. You have been warned."
}
}
} |
|
|
| Back to top |
|
 |
Azeem Voice
Joined: 26 Sep 2006 Posts: 14
|
Posted: Sat Sep 30, 2006 11:11 am Post subject: |
|
|
Ohk..thanks for highlighting b/w do u know any solution to it..am a n00b in tcl ..  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Sep 30, 2006 12:00 pm Post subject: |
|
|
@Azeem:
If you're referring to the use of list-commands; Make sure it's a list and not a string. If nessecary, convert the string to a list.
You'll probably want to read up on these commands:
list, split, join, lappend, lindex, lrange (and a few other list-commands) _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Azeem Voice
Joined: 26 Sep 2006 Posts: 14
|
Posted: Sat Sep 30, 2006 1:01 pm Post subject: |
|
|
Thanks for Helping  |
|
| Back to top |
|
 |
|