No.Spam

By Get_A_Fix on Jan 24, 2008

Basic detection of public/private channel spam, DALNet specific.

I checked if any antispam snippets had been added and found none under tcl, all the others were in the mIRC Scripting language, so I thought I should add this.

##
# No.Spam v1.beta - Get_A_Fix/istok (DALnet/IRCSpeed)
##

# $Id: No.Spam.tcl,v1 25/01/2008 10:47:30am GMT +12 (NZST) getafix Exp $

# - Script Info: 
# - DALNet Specific TCL
# - This script will send an onjoin message to whomever joins the channel where this script is enabled.
#   It will send 3 lines of text (as most spam/drones usually require 3 or more lines to trigger).
#   It will also cycle all valid channel(s). (edit cycletime for duration)

# - NOTE: 'spglobflags' and 'spchanflags' are the flags required to be exempt from pub/msg antispam checks.
#         'ojglobflags' and 'ojchanflags' are the flags required to be exempt from the onjoin channel message.

# - Current Settings exempt: +n (Global Owner)       +n (Channel owner)
#                            +m (Global Master)      +m (Channel Master)
#                            +o (Global Operator)    +o (Channel Operator)
#                            +b (Global Bot)         +f (Channel Friend)
#                            +f (Global Friend)

# - Current Trigger set to '!' 
# - You can edit/modify 'pubtrig' to whatever Trigger you would like.
# - You can edit/modify the 'spamwords' variable to match whatever text you would like.
# - Public Command Syntax Only.

# - Syntax:

# - Onjoin Message:   <trigger>onjoin on/off            (ie: !onjoin on OR !onjoin off <-)
# - No.Spam ON/OFF:   <trigger>antispam on/off       (ie: !antispam on OR !antispam off <-)
# - This enables or disables Antispam. Antispam works for both public AND message.

# Set public trigger here
set pubtrig "!"

# Set cycle time set in minutes
set cycletime "5"

#### DONT EDIT BELOW ####
proc getTrigger {} {
  global pubtrig
  return $pubtrig
}

set exemptwords {
  "*dal.net*"
  "#mychannel"
  "#anotherchan"
}

set spamwords {  
  "*http://*" 
  "*www.*"
  "*.com*"
  "*.net*"
  "*.org*"
  "*.biz*"
  "*.info*"
  "*.name*"
  "*decode*"
  "*#*"
  "*irc.*"
}

setudef flag antispam
setudef flag ojcheck

set spglobflags mnobf
set spchanflags mnof
set ojglobflags mnobf
set ojchanflags mnof

bind MSGM - * spamword:msg
bind PUBM - * spamword:pub
bind JOIN - * onjoin:notice
bind CTCP - ACTION spamword:act
bind PUB - ${pubtrig}antispam antispam:pub
bind PUB - ${pubtrig}onjoin ojcheck:pub
bind MSG - antispam antispam:msg
bind MSG - onjoin ojcheck:msg

proc antispam:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|m $chan]} {putquick "NOTICE $nick :\037ERROR\037: You do not have access to this command."; return}
  if {([lindex [split $arg] 0] == "") && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]antispam on/off"; return}
  if {([lindex [split $arg] 0] == "") && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]antispam on/off"; return}

  if {[lindex [split $arg] 0] == "on"} {
    if {[channel get $chan antispam] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
    if {[channel get $chan antispam] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
    channel set $chan +antispam
    puthelp "PRIVMSG $chan :Enabled AntiSpam Protections for $chan"
  }

  if {[lindex [split $arg] 0] == "off"} {
    if {![channel get $chan antispam] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
    if {![channel get $chan antispam] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
    channel set $chan -antispam
    puthelp "PRIVMSG $chan :Disabled AntiSpam Protections for $chan"
  }
}

proc antispam:msg {nick uhost hand arg} {
  global botnick
  set chan [strlwr [lindex $arg 0]]
  if {![matchattr [nick2hand $nick] o|m $chan]} {putquick "NOTICE $nick :\037ERROR\037: You do not have access to this command."; return}
  if {([lindex [split $arg] 0] == "") && (![string match "*#*" $arg])} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick antispam #channel on/off"; return}
  if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick antispam #channel on/off"; return}
  if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick antispam $chan on/off"; return}

  if {[lindex [split $arg] 1] == "on"} {
    if {[channel get $chan antispam]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
    channel set $chan +antispam
    putquick "NOTICE $nick :Enabled AntiSpam Protections for $chan"
  }

  if {[lindex [split $arg] 1] == "off"} {
    if {![channel get $chan antispam]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
    channel set $chan -antispam
    putquick "NOTICE $nick :Disabled AntiSpam Protections for $chan"
  }
}

proc ojcheck:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|m $chan]} {putquick "NOTICE $nick :\037ERROR\037: You do not have access to this command."; return}
  if {([lindex [split $arg] 0] == "") && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]onjoin on/off"; return}
  if {([lindex [split $arg] 0] == "") && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]onjoin on/off"; return}

  if {[lindex [split $arg] 0] == "on"} {
    if {[channel get $chan ojcheck] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
    if {[channel get $chan ojcheck] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
    channel set $chan +ojcheck
    puthelp "PRIVMSG $chan :Enabled Onjoin Message Checking for $chan"
  }

  if {[lindex [split $arg] 0] == "off"} {
    if {![channel get $chan ojcheck] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
    if {![channel get $chan ojcheck] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
    channel set $chan -ojcheck
    puthelp "PRIVMSG $chan :Disabled Onjoin Message Checking for $chan"
  }
}

proc ojcheck:msg {nick uhost hand arg} {
  global botnick
  set chan [strlwr [lindex $arg 0]]
  if {![matchattr [nick2hand $nick] o|m $chan]} {putquick "NOTICE $nick :\037ERROR\037: You do not have access to this command."; return}
  if {([lindex [split $arg] 0] == "") && (![string match "*#*" $arg])} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick onjoin #channel on/off"; return}
  if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick onjoin #channel on/off"; return}
  if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick onjoin $chan on/off"; return}

  if {[lindex [split $arg] 1] == "on"} {
    if {[channel get $chan ojcheck]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
    channel set $chan +ojcheck
    putquick "NOTICE $nick :Enabled Onjoin Message Checking for $chan"
  }

  if {[lindex [split $arg] 1] == "off"} {
    if {![channel get $chan ojcheck]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
    channel set $chan -ojcheck
    putquick "NOTICE $nick :Disabled Onjoin Message Checking for $chan"
  }
}

proc spamword:msg {nick uhost hand text} { 
  global spamwords exemptwords spglobflags spchanflags
  foreach nospamchan [channels] {
    if {[channel get $nospamchan antispam]} {
      if {([botisop $nospamchan]) && (![isbotnick $nick])} { 
        if {![matchattr $hand $spglobflags|$spchanflags $nospamchan]} {
          if {([onchan $nick $nospamchan]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
            foreach pattern $exemptwords {
              if {[string match -nocase $pattern $text]} {return}
            }
            foreach pattern $spamwords {
              if {[string match -nocase $pattern $text]} {
                putquick "MODE $nospamchan +b *!*@[lindex [split $uhost @] 1]" 
                putquick "KICK $nospamchan $nick :(\002MSGSPAM\002) - You are \002NOT\002 Permitted to Advertise in $nospamchan - Matching: $pattern"
                putquick "PRIVMSG $nick :Spamming/Advertising on a Channel where you \002DONT\002 have access is a breach of this Networks AUP (Acceptable Use Policy) - Read: http://www.dal.net/aup/"
                break
              }
            }
          }
        }
      } 
    } 
  }
  return 0
}

proc spamword:pub {nick uhost hand chan text} { 
  global spamwords exemptwords spglobflags spchanflags
  foreach nospamchan [channels] {
    if {[channel get $nospamchan antispam]} {
      if {([botisop $nospamchan]) && (![isbotnick $nick])} {
        if {![matchattr $hand $spglobflags|$spchanflags $nospamchan]} {
          if {([onchan $nick $nospamchan]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
            foreach pattern $exemptwords {
              if {[string match -nocase $pattern $text]} {return}
            }
            foreach pattern $spamwords {
              if {[string match -nocase $pattern $text]} { 
                putquick "MODE $chan +b *!*@[lindex [split $uhost @] 1]" 
                putquick "KICK $nospamchan $nick :(\002PUBSPAM\002) - You are \002NOT\002 Permitted to Advertise in $nospamchan - Matching: $pattern"
                putquick "PRIVMSG $nick :Spamming/Advertising on a Channel where you \002DONT\002 have access is a breach of this Networks AUP (Acceptable Use Policy) - Read: http://www.dal.net/aup/"
                break
              }
            }
          }
        }
      } 
    } 
  }
  return 0
}

proc spamword:act {nick uhost hand dest key text} {
  global botnick spamwords exemptwords spglobflags spchanflags
  if {![string match "*#*" $dest]} {return}
  set chan $dest
  foreach nospamchan [channels] {
    if {[channel get $nospamchan antispam]} {
      if {([botisop $nospamchan]) && (![isbotnick $nick])} {
        if {![matchattr $hand $spglobflags|$spchanflags $nospamchan]} {
          if {([onchan $nick $nospamchan]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
            foreach pattern $exemptwords {
              if {[string match -nocase $pattern $text]} {return}
            }
            foreach pattern $spamwords {
              if {[string match -nocase $pattern $text]} { 
                putquick "MODE $chan +b *!*@[lindex [split $uhost @] 1]" 
                putquick "KICK $nospamchan $nick :(\002PUBSPAM\002) - You are \002NOT\002 Permitted to Advertise in $nospamchan - Matching: $pattern"
                putquick "PRIVMSG $nick :Spamming/Advertising on a Channel where you \002DONT\002 have access is a breach of this Networks AUP (Acceptable Use Policy) - Read: http://www.dal.net/aup/"
                break
              }
            }
          }
        }
      } 
    } 
  }
  return 0
}

proc onjoin:notice {nick uhost hand chan} {
  global ojglobflags ojchanflags
  if {[channel get $chan ojcheck]} {
    if {![isbotnick $nick]} {
      if {![matchattr $hand $ojglobflags|$ojchanflags $chan]} {
        putserv "PRIVMSG $nick :Hello $nick"
        putserv "PRIVMSG $nick :I am checking for Infected/SPAM clients/bots!"
        putserv "PRIVMSG $nick :Please do \002NOT\002 Reply to this Message."
      }
    }
  }
  return 0
}

timer $cycletime cycle
proc cycle {} {
  global cycletime
  foreach c [channels] {
    putserv "PART $c :AutoMated Cycle..."; timer $cycletime cycle
  }
}

putlog "No.Spam v1 Spam:Check - .:Loaded:."

Comments

Sign in to comment.
youngblood   -  Aug 23, 2008

this would of been better off making it easier for the others by making a dialog for it this looks a litte complicated

 Respond  
mentalglitch   -  May 13, 2008

lol agreed. tis all the script holders syntax, never blame the bot/script :P

 Respond  
Get_A_Fix   -  Jan 28, 2008

heh, I guess that would depend on the user/channel and what they would like to match/kick/ban. Easily edited.

if {[string match -nocase \"*hawkee*\" $text]} { return }
 Respond  
F*U*R*B*Y*   -  Jan 26, 2008

does anyone have any info on hawkee.com??

^^ Would get you kicked......

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.