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.

[SOLVED] badword TCL

Help for those learning Tcl or writing their own scripts.
Post Reply
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

[SOLVED] badword TCL

Post by gasak »

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

Code: Select all

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: Select all

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.
Last edited by gasak on Mon May 21, 2012 10:04 am, edited 1 time in total.
Learning Knows No Boundaries!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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

Code: Select all

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

Code: Select all

   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: Select all

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

Code: Select all

set bwChan "#chan"
with:

Code: Select all

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: Select all

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.
Post Reply