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.

url kick

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
W
WisH-GR
Voice
Posts: 9
Joined: Mon Aug 17, 2009 4:43 am

url kick

Post by WisH-GR »

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?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I've done a limited amount of testing on the following script and it seems OK. Make sure you use .chanset #channelname +spam in the partyline for each bot channel you want it activated in.

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
I must have had nothing to do
W
WisH-GR
Voice
Posts: 9
Joined: Mon Aug 17, 2009 4:43 am

Post by WisH-GR »

thx i will try it and tell u
Post Reply