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 

Help with this bad command kick script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
mcdarby
Halfop


Joined: 16 Jul 2002
Posts: 69
Location: Bangor, Pennsylvania

PostPosted: Fri Sep 29, 2006 4:29 am    Post subject: Help with this bad command kick script Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri Sep 29, 2006 6:45 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Azeem
Voice


Joined: 26 Sep 2006
Posts: 14

PostPosted: Fri Sep 29, 2006 7:30 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Sep 29, 2006 11:25 am    Post subject: Reply with quote

@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
View user's profile Send private message
mcdarby
Halfop


Joined: 16 Jul 2002
Posts: 69
Location: Bangor, Pennsylvania

PostPosted: Fri Sep 29, 2006 3:51 pm    Post subject: Reply with quote

@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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Sep 29, 2006 3:54 pm    Post subject: Reply with quote

@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
View user's profile Send private message
mcdarby
Halfop


Joined: 16 Jul 2002
Posts: 69
Location: Bangor, Pennsylvania

PostPosted: Fri Sep 29, 2006 8:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri Sep 29, 2006 9:03 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Sat Sep 30, 2006 2:01 am    Post subject: Reply with quote

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


Joined: 26 Sep 2006
Posts: 14

PostPosted: Sat Sep 30, 2006 11:11 am    Post subject: Reply with quote

Ohk..thanks for highlighting b/w do u know any solution to it..am a n00b in tcl .. Smile
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Sep 30, 2006 12:00 pm    Post subject: Reply with quote

@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
View user's profile Send private message
Azeem
Voice


Joined: 26 Sep 2006
Posts: 14

PostPosted: Sat Sep 30, 2006 1:01 pm    Post subject: Reply with quote

Thanks for Helping Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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