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 

[SOLVED] badword TCL

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


Joined: 09 Aug 2010
Posts: 45

PostPosted: Mon May 21, 2012 12:38 am    Post subject: [SOLVED] badword TCL Reply with quote

I got this badword TCL somewhere else, and it suits to my need:

Code:
set bwRun 1
set bwArray() ""
set bwNumber 0
set bwFilename "filename.txt"
set bwChan "#chan"

# SURVEYpub proc
bind pubm - * bwSurveypub
proc bwSurveypub {nick uhost hand channel args} {
   global bwChan bwArray bwNumber bwRun passLogo
   set channel [string tolower $channel]
   if { $bwChan != $channel } {
      return 0
   }
   if { ([isop $nick $bwChan])||([matchattr $nick o|o $bwChan])||([isvoice $nick $bwChan]) } {
      return 0
   }
   
   set args [join $args]
   set args [string tolower $args]

   for {set i 0} {$i < $bwNumber} {incr i} {
      if { $bwArray($i) != "" } {
         set badw [join $bwArray($i)]
         set dummy ""
         if { [regsub -all "$badw" $args "" dummy] } {
            putserv "MODE $channel +b $uhost"
            putserv "KICK $bwChan $nick :Badword detected from '$badw' get out!"
         }
      }
   }
   return 0
}


The problem i got here is that it just working only in one channel. I try to put several channel like

Code:
set bwChan "#chan1 #chan2"


But its only recognize the first channel which is #chan1

What i need is it should work on every channel that i put on set bwChan and also will work in all channel when i leave the set bwChan to """"

Please help me on this thing. Thank you very much.
_________________
Learning Knows No Boundaries!!


Last edited by gasak on Mon May 21, 2012 10:04 am; edited 1 time in total
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon May 21, 2012 7:26 am    Post subject: Reply with quote

There are at least two ways to make this work. First method would be to replace:
Code:

   if { $bwChan != $channel } {
      return 0
   }

with:
Code:

   if {[lsearch -nocase $bwChan $channel] == -1} {
      return 0
   }

Con: You would have to edit the tcl file every time you wish to add/remove a channel from the list.

The second method involves the removal of the same line like mentioned above and replacing it with:
Code:

   if {![channel get $channel badword]} {
      return 0
   }

and replacing:
Code:

set bwChan "#chan"

with:
Code:

setudef flag badword

Then, to enable/disable it on a channel it's a simple command on DCC chat or telnet with the bot: .chanset #channel +/-badword

if you decide to stick with the first method and want this work on all channels when the bwChan is set to "" then replace we change that line with:
Code:

if {[llength $bwChan]} {
   if {![channel get $channel badword]} {
      return 0
   }
}

As for the second case, you just need to .chanset * +/-badword
_________________
Once the game is over, the king and the pawn go back in the same box.
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