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.

My badword script stop working if I put many words

Help for those learning Tcl or writing their own scripts.
Post Reply
M
Moti
Voice
Posts: 15
Joined: Fri Sep 20, 2013 12:36 pm

My badword script stop working if I put many words

Post by Moti »

Hi,

I found a badwords script at google.
It's work perfect, but if I put many words its stop to work.

Somebody know what can I do to use this script with list of 800 words?

This is my script:

Code: Select all

# Default trigger set to "!"

# SYNTAX:
# -------

# PUBLIC: !noswear on
# PUBLIC: !noswear off

# MSG: /msg yourbot noswear #channelname on
# MSG: /msg yourbot noswear #channelname off

# NOTE: Currently set to Global OP (o) and above, Channel Master (m) and above. 
# --------------------------------------------------------------------------

# Set global trigger here
set trigger "!"

# Set access flags for command here (example: o|m <- globalop|channelmaster)
set accessflags "o|m"

# Set how long to leave devoiced (set in minutes)
set devoicetime "1"

# Set your swearword pattern below
set swearwords {
"*anus*"
"*arse*"
"*arsehole*"
"*ass*"
"*asshat*"
}

# -----DONT EDIT BELOW-----
bind pub - ${trigger}noswear noswear:pub
bind msg - noswear noswear:msg
bind pubm - * noswear:text
bind ctcp - ACTION noswear:act

setudef flag noswear

proc getTrigger {} {
  global trigger
  return $trigger
}

proc noswear:pub {nick uhost hand chan text} {
  global accessflags
  if {![matchattr [nick2hand $nick] $accessflags $chan]} {return}
  if {[lindex [split $text] 0] == ""} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]noswear on/off"; return}
 
  if {[lindex [split $text] 0] == "on"} {
    if {[channel get $chan noswear]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
    channel set $chan +noswear
    puthelp "PRIVMSG $chan :Enabled Swearing Protection for $chan"
  }
 
  if {[lindex [split $text] 0] == "off"} {
    if {![channel get $chan noswear]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
    channel set $chan -noswear
    puthelp "PRIVMSG $chan :Disabled Swearing Protection for $chan"
  }
}
 
proc noswear:msg {nick uhost hand arg} {
  global botnick accessflags
  set chan [strlwr [lindex $arg 0]]
  if {![matchattr [nick2hand $nick] $accessflags $chan]} {return}
  if {![string match "*#*" $arg]} {return}
  if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick noswear #channel on/off"; return}
  if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick noswear $chan on/off"; return}
 
  if {[lindex [split $arg] 1] == "on"} {
    if {[channel get $chan noswear]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
    channel set $chan +noswear
    putquick "NOTICE $nick :Enabled Swearing Protection for $chan"
  }
 
  if {[lindex [split $arg] 1] == "off"} {
    if {![channel get $chan noswear]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
    channel set $chan -noswear
    putquick "NOTICE $nick :Disabled Swearing Protection for $chan"
  }
}
 
proc noswear:text {nick uhost hand chan arg} {
  global botnick swearwords devoicetime
  if {[channel get $chan noswear]} {
    foreach pattern $swearwords {
      if {[string match -nocase $pattern $arg]} {
        if {![validuser $hand] && ![isop $nick $chan]} {
          set mask *!*@[lindex [split [getchanhost $nick $chan] @] 1]
          putquick "mode $chan -v $nick"
          putserv "privmsg $nick :\00307WARNING:\00300 Violation of Chat Rules: Abusive Language."
          putserv "privmsg $nick :\00303STATUS:\00300 Muted (60 seconds)."
          putserv "privmsg $nick :\00312MESSAGE:\00300 Dear $nick, you have been muted. This means for the next 60 seconds, you will not be able to send messages to the chat. In order to prevent this from happening again, please do not use abusive language in the chat."
          newignore $mask $botnick "Swear Devoice Ignore" 0
          timer $devoicetime [list putquick "mode $chan +v $nick"]
          timer $devoicetime [list killignore $mask]
          utimer 65 "putserv \"privmsg $nick :\00303STATUS:\00300\ In good standing.\""
          utimer 65 "putserv \"privmsg $nick :\00312MESSAGE:\00300 Good news $nick, your 60 second mute has expired and you are now able to send messages. Please remember to respect our chat rules!\""
        }
      }
    }
  }
}
 
proc noswear:act {nick uhost hand dest key text} {
  global botnick swearwords devoicetime
  if {![string match "*#*" $dest]} {return}
  set chan $dest
  if {[channel get $chan noswear]} {
    foreach pattern $swearwords {
      if {[string match -nocase $pattern $text]} {
        if {[botisop $chan] && ![isbotnick $nick]} {
          if {[onchan $nick $chan] && ![validuser $hand] && ![isop $nick $chan]} {
            set mask *!*@[lindex [split [getchanhost $nick $chan] @] 1]
            putquick "mode $chan -v $nick"
            putserv "privmsg $nick :\00307WARNING:\00300 Violation of Chat Rules: Abusive Language."
            putserv "privmsg $nick :\00303STATUS:\00300 Muted (60 seconds)."
            putserv "privmsg $nick :\00312MESSAGE:\00300 Dear $nick, you have been muted. This means for the next 60 seconds, you will not be able to send messages to the chat. In order to prevent this from happening again, please do not use abusive language in the chat."
            newignore $mask $botnick "Swear Devoice Ignore" 0
            timer $devoicetime [list putquick "mode $chan +v $nick"]
            timer $devoicetime [list killignore $mask]
            utimer 65 "putserv \"privmsg $nick :\00303STATUS:\00300\ In good standing.\""
            utimer 65 "putserv \"privmsg $nick :\00312MESSAGE:\00300 Good news $nick, your 60 second mute has expired and you are now able to send messages. Please remember to respect our chat rules!\""
          }
        }
      }
    }
  }
}
 
putlog "Loaded: NoSwear Module."
Thank you !
Post Reply