This is a DALnet specific script designed to be run on two eggdrops.
An OP'd bot, a DeOP'd bot.
The OP bot monitors messages from the deop bot, should anyone spam it.
The settings are currently set for the DeOP'd bot to cycle every 5mins.
Both spamcheck and docycle are easily enabled/disabled.
Check scripts for syntax.
# Load this TCL to your @/OPd Channel Bot.
# You need to add a custom flag to recognise the deop/relay bot.
# Firstly, add the bot to your @/OPd bot - dcc/ctcp/partyline - .+user relay *!*bots@host.mask
# Secondly, you need to add the flag - .chattr relay -|A #channel <- this will then allow the bot access to the below command.
bind msg - spam spam:ban
proc spam:ban {nick uhost hand arg} {
set bchan [strlwr [lindex [split $arg] 0]]
if {![botisop $bchan]} {return}
if {[matchattr $hand -|A $bchan]} {
set spamnick [join [lindex [split $arg] 1]]
set bmask *!*@[lindex [split [getchanhost $spamnick $bchan] @] 1]
set breason "Spamming/Advertising in a channel you \002DONT\002 have access to is against this Networks AUP (\002\037A\037\002cceptable \002\037U\037\002se \002\037P\037\002olicy)"
set bnotice "For more information about the \037DALNet AUP\037 (\002\037A\037\002cceptable \002\037U\037\002se \002\037P\037\002olicy) please visit: http://www.dal.net/aup/"
putquick "MODE $bchan +b $bmask"
putquick "KICK $bchan $spamnick :$breason"
putserv "PRIVMSG $spamnick :$bnotice"
}
}
putlog "LOADED: OP Relay - .:Spam:Checker:."
# -----------BREAK--------------
# Load this TCL to your deOPd channel bot.
# Spam List: Edit this with whatever strings you want to match/ban.
set spamwords {
"*http://*"
"*www.*"
"*.com*"
"*.net*"
"*.org*"
"*.biz*"
"*.info*"
"*.name*"
"*decode*"
"*#*"
"*irc.*"
}
# Public Trigger (feel free to change to whatever you like).
set pubtrig "!"
# Cycle Time: measured in minutes.
set cycletime "5"
# Obviously the nickname of the @/OPd bot.
set oppedbot "opbotnick"
setudef flag spamcheck
setudef flag docycle
bind pub - ${pubtrig}spamcheck spam:pub
bind msg - spamcheck spam:msg
bind pub - ${pubtrig}chancycle cycle:pub
bind msg - chancycle cycle:msg
# Trigger set to !
# Public Command
# Syntax: !spamcheck on/off
proc spam:pub {nick uhost hand chan text} {
global botnick
if {[matchattr $hand o|m $chan]} {
if {[lindex [split $text] 0] == ""} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !spamcheck on/off"; return}
if {[lindex [split $text] 0] == "on"} {
if {[channel get $chan spamcheck]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +spamcheck
puthelp "PRIVMSG $chan :Enabled Relay Spam Protection for $chan"
}
if {[lindex [split $text] 0] == "off"} {
if {![channel get $chan spamcheck]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -spamcheck
puthelp "PRIVMSG $chan :Disabled Relay Spam Protection for $chan"
}
}
}
# Private Command
# Syntax: /msg botnick spamcheck #channelname on/off
proc spam:msg {nick uhost hand arg} {
global botnick
set chan [strlwr [lindex [split $arg] 0]]
if {[matchattr $hand o|m $chan]} {
if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick spamcheck #channel on/off"; return}
if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick spamcheck $chan on/off"; return}
if {[lindex [split $arg] 1] == "on"} {
if {[channel get $chan spamcheck]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +spamcheck
putquick "NOTICE $nick :Enabled Relay Spam Protection for $chan"
}
if {[lindex [split $arg] 1] == "off"} {
if {![channel get $chan spamcheck]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -spamcheck
putquick "NOTICE $nick :Disabled Relay Spam Protection for $chan"
}
}
}
# Trigger set to !
# Public Command
# Syntax: !chancycle on/off
proc cycle:pub {nick uhost hand chan text} {
global botnick
if {[matchattr $hand o|m $chan]} {
if {[lindex [split $text] 0] == ""} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !chancycle on/off"; return}
if {[lindex [split $text] 0] == "on"} {
if {[channel get $chan docycle]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +docycle
puthelp "PRIVMSG $chan :Enabled Channel Cycle for $chan"
}
if {[lindex [split $text] 0] == "off"} {
if {![channel get $chan docycle]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -docycle
puthelp "PRIVMSG $chan :Disabled Channel Cycle for $chan"
}
}
}
# Private Command
# Syntax: /msg botnick chancycle #channelname on/off
proc cycle:msg {nick uhost hand arg} {
global botnick
set chan [strlwr [lindex $arg 0]]
if {[matchattr $hand o|m $chan]} {
if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick chancycle #channel on/off"; return}
if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick chancycle $chan on/off"; return}
if {[lindex [split $arg] 1] == "on"} {
if {[channel get $chan docycle]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +docycle
putquick "NOTICE $nick :Enabled Channel Cycle for $chan"
}
if {[lindex [split $arg] 1] == "off"} {
if {![channel get $chan docycle]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -docycle
putquick "NOTICE $nick :Disabled Channel Cycle for $chan"
}
}
}
timer $cycletime cycle
proc cycle {} {
global cycletime
foreach c [channels] {
if {[channel get $c docycle]} {
putserv "PART $c"; timer $cycletime cycle
}
}
}
bind pubm - * pub:spam:check
proc pub:spam:check {nick uhost hand chan text} {
global spamwords oppedbot
if {[channel get $chan spamcheck]} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
if {(![validuser $hand]) && (![isop $nick $chan]) && (![isvoice $nick $chan])} {
putquick "PRIVMSG $oppedbot :spam $chan $nick"
}
}
}
}
return 0
}
bind msgm - * msg:spam:check
proc msg:spam:check {nick uhost hand text} {
global spamwords oppedbot
foreach nospamchan [channels] {
if {[channel get $nospamchan spamcheck]} {
if {![isbotnick $nick]} {
if {([onchan $nick $nospamchan]) && (![validuser $hand]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
putquick "PRIVMSG $oppedbot :spam $nospamchan $nick"
}
}
}
}
}
}
return 0
}
bind CTCP - ACTION spam:check
proc spam:check {nick uhost hand dest key text} {
global spamwords oppedbot
foreach nospamchan [channels] {
if {[channel get $nospamchan spamcheck]} {
if {![isbotnick $nick]} {
if {![validuser $hand]} {
if {([onchan $nick $nospamchan]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
putquick "PRIVMSG $oppedbot :spam $nospamchan $nick"
}
}
}
}
}
}
}
return 0
}
putlog "LOADED: DeOP Relay - .:Spam:Checker:."
The relay bot don't need to be an operator to continue the process. But the oppedbot yes.
Then, I completed the code with "if {([botonchan $nospamchan]) && ([onchan $oppedbot $nospamchan]) && (![isbotnick $nick])} { }".
I forgot to edit the pubm...
bind pubm - * pub:spam:check
proc pub:spam:check {nick uhost hand chan text} {
global spamwords oppedbot
if {[channel get $chan spamcheck]} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
if {([botonchan $nospamchan]) && ([onchan $oppedbot $nospamchan]) && (![isbotnick $nick])} {
if {(![validuser $hand]) && (![isop $nick $chan]) && (![isvoice $nick $chan])} {
putquick "PRIVMSG $oppedbot :spam $chan $nick"
}
}
}
}
}
return 0
}
fixed 1:
bind msgm - * msg:spam:check
proc msg:spam:check {nick uhost hand text} {
global spamwords oppedbot
foreach nospamchan [channels] {
if {[channel get $nospamchan spamcheck]} {
if {([botonchan $nospamchan]) && ([onchan $oppedbot $nospamchan]) && (![isbotnick $nick])} {
if {([onchan $nick $nospamchan]) && (![validuser $hand]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
putquick "PRIVMSG $oppedbot :spam $nospamchan $nick"
}
}
}
}
}
}
return 0
}
fixed 2:
bind CTCP - ACTION spam:check
proc spam:check {nick uhost hand dest key text} {
global botnick spamwords oppedbot
foreach nospamchan [channels] {
if {[channel get $nospamchan spamcheck]} {
if {([botonchan $nospamchan]) && ([onchan $oppedbot $nospamchan]) && (![isbotnick $nick])} {
if {![validuser $hand]} {
if {([onchan $nick $nospamchan]) && (![isop $nick $nospamchan]) && (![isvoice $nick $nospamchan])} {
foreach pattern $spamwords {
if {[string match -nocase $pattern $text]} {
putquick "PRIVMSG $oppedbot :spam $nospamchan $nick"
}
}
}
}
}
}
}
return 0
}