hello i need help creating a rather simple(i think) tcl
i want it to detect url spams and (give me the option to choose) warn kick or kickban the user.but please i want it to ignore any youtube links.
can someone help?
Code: Select all
# spam.tcl
# kicks or kickbans users for spam words/phrases
# functions for channel text, channel actions, channel notices and channel onotices
### --------------------------------------------------------------------------------- ###
### ---------- installation --------------------------------------------------------- ###
# install and source the tcl as normal
# to function in #channelname requires in the partyline .chanset #channelname +spam
### --------------------------------------------------------------------------------- ###
### ---------- configuration -------------------------------------------------------- ###
# set here the list of words/phrases that a user may be punished for
# upper/lower case or mixed doesn't matter
set vSpamPunish {
"http://"
"www."
}
# set here the list of words/phrases that a user will not be punished for
# upper/lower case or mixed doesn't matter
set vSpamExempt {
"youtube"
"google"
"myspace"
"twitter"
}
# set here the punishment mode
# 1 == always kick only
# 2 == kick first time, kickban second
# 3 == always kickban
set vSpamPunishMode 2
# if punishment mode 2 above, set here the time (minutes) to cancel first offence
set vSpamSinTime 2
# set here who on the channel is protected
# 1 == channel ops and voices not protected
# 2 == protect channel ops but not channel voices
# 3 == protect channel ops and voices
set vSpamProtectMode 2
# set here the ban time in minutes
# a setting of 0 means permanent
set vSpamBanTime 2
### --------------------------------------------------------------------------------- ###
### ---------- code ----------------------------------------------------------------- ###
setudef flag spam
bind CTCP - ACTION pSpamCtcp
bind NOTC - * pSpamNotc
bind PUBM - * pSpamPubm
proc pSpamBan {nick chan phrase} {
global vSpamBanTime
if {[onchan $nick $chan]} {
if {[string is integer -strict $vSpamBanTime]} {
set host [maskhost [getchanhost $nick $chan]]
pushmode $chan +b $host
flushmode $chan
utimer 3 [list pSpamKick $nick $chan $phrase]
if {$vSpamBanTime > 0} {
timer $vSpamBanTime [list pSpamUnban $chan $host]
}
}
}
return 0
}
proc pSpamCheck {nick chan text} {
global vSpamExempt vSpamProtectMode vSpamPunish
switch -- $vSpamProtectMode {
1 {}
2 {if {[isop $nick $chan]} {return 0}}
3 {if {([isop $nick $chan]) || ([isvoice $nick $chan])} {return 0}}
default {return 0}
}
set punish 0
if {[llength $vSpamPunish] != 0} {
foreach bad $vSpamPunish {
if {[string match -nocase *${bad}* $text]} {
set punish 1
set phrase $bad
break
}
}
if {[llength $vSpamExempt] != 0} {
foreach good $vSpamExempt {
if {[string match -nocase *${good}* $text]} {
set punish 0
break
}
}
}
}
if {$punish} {pSpamPunish $nick $chan $phrase}
return 0
}
proc pSpamCtcp {nick uhost hand dest keyword text} {
if {[channel get $dest spam]} {
if {![isbotnick $nick]} {
if {[botisop $dest]} {
pSpamCheck $nick $dest $text
}
}
}
return 0
}
proc pSpamKick {nick chan phrase {warning ""}} {
if {[onchan $nick $chan]} {
switch -- [string length $warning] {
0 {putkick $chan $nick "spam detected *${phrase}*"}
default {putkick $chan $nick "spam detected *${phrase}* $warning"}
}
}
return 0
}
proc pSpamNotc {nick uhost hand text dest} {
set chan [string trimleft $dest @]
if {[regexp -- {^#} $chan]} {
if {[channel get $chan spam]} {
if {![isbotnick $nick]} {
if {[botisop $chan]} {
pSpamCheck $nick $chan $text
}
}
}
}
return 0
}
proc pSpamPubm {nick uhost hand chan text} {
if {[channel get $chan spam]} {
if {![isbotnick $nick]} {
if {[botisop $chan]} {
pSpamCheck $nick $chan $text
}
}
}
return 0
}
proc pSpamPunish {nick chan phrase} {
global vSpamPunishMode vSpamSinBin vSpamSinTime
switch -- $vSpamPunishMode {
1 {pSpamKick $nick $chan $phrase}
2 {
switch -- [info exists vSpamSinBin($nick,$chan)] {
0 {
pSpamKick $nick $chan $phrase "first warning"
set vSpamSinBin($nick,$chan) 1
timer $vSpamSinTime [list pSpamUnsetSin $nick $chan]
}
1 {
pSpamBan $nick $chan $phrase
pSpamUnsetSin $nick $chan
}
default {}
}
}
3 {pSpamBan $nick $chan $phrase}
default {return 0}
}
return 0
}
proc pSpamUnban {chan host} {
pushmode $chan -b $host
flushmode $chan
return 0
}
proc pSpamUnsetSin {nick chan} {
global vSpamSinBin
if {[info exists vSpamSinBin($nick,$chan)]} {unset vSpamSinBin($nick,$chan)}
return 0
}
# eof