- Home»
- Cod sursa: moderator.tcl
moderator.tcl
moderator.tcl
Ce script comprend un anti badword, un anti repetition, un anti caps et un anti long mot. Il agit sur les msgs/notices/actions/sounds.
| Postat de | Copyright | Categorie | Review user | Vizualizari | Data |
|---|---|---|---|---|---|
| btc | nix | protections | Cod netestat | 343 | 2023-12-25 10:26:16 |
# Moderator-02.tcl by nix@valium.org
###########################
# CONFIG BADWORD
###########################
# prevenir 1 fois avant kick pour les badword? 1/0
set Mod(Warn) 1
# si on previent kel est le message a envoyer?
set Mod(WarnMsg) "4Attention! surveillez votre langage! La prochaine fois vous serez expulsé!"
# bannir pour badword? 1/0
set Mod(Ban) 1
# bannir combien de temps? (en minute)
set Mod(BanTime) 10
# kicker pour badword? 1/0
set Mod(Kick) 1
# kel raison pour le kick?
set Mod(KickReason) "Exclu 10 minutes !"
###########################
# CONFIG REPEAT
###########################
# combien de repetion maxi?
set Mod(RptMax) 2
# raisons de kick random pour les repetions
set Mod(Reason) {
"pas besoin de répéter"
"on ne répÄte pas"
"tu nous dérange en répétant"
}
# bannir pour repetition? 1/0
set Mod(BanRep) 0
# combien de temps? (en minute)
set Mod(BanRepTime) 10
###########################
# CONFIG CAPS
###########################
# Max de Caps ?
set Mod(MaxCaps) 20
# prevenir la personne en notice ? 1/0
set Mod(CapsWarn) 1
# quel message?
set Mod(CapsWarnMsg) "4Attention! Merci de ne pas ecrire en MAJUSCULE"
# kicker les CAPS ? 1/0
set Mod(KCaps) 0
# quel raison pour le kick?
set Mod(KCapsReason) "pas de MAJUSCULE"
###########################
# CONFIG LONG MOT
###########################
# kicker les longs mots? 1/0
set Mod(MaxMot) 1
# taille maxi d'un mot? 1/0
set Mod(MaxMotSize) 80
# raison du kick ?
set Mod(MaxMotReason) "Flood"
###########################
proc KReason {} {
global Mod
return [lindex $Mod(Reason) [rand [llength $Mod(Reason)]]]
}
#on set les listes au demarrage en lisant les fichiers
set BWC ""
foreach c [channels] {
if {[file exists "Moderator.[string tolower $c].list"]} {
set f [open Moderator.[string tolower $c].list r]
set BWL([string tolower $c]) "[string tolower [gets $f]]"
close $f
lappend BWC [string tolower $c]
}
}
#proc pour checker si le channel est a surveiller
proc ChkWbBwVar {cha} {
global BWC
foreach c $BWC {
if {$c == "$cha"} {return 1; break}
}
return 0
}
#check les NOTICE PRIVMSG ACTION SOUND
bind raw - NOTICE PubChkNOT
proc PubChkNOT {from keyword arg} {
set from [split $from !]
PubChk [lindex $from 0] [lindex $from 1] * [lindex $arg 0] [lrange $arg 1 end]
}
bind ctcp - ACTION PubChkACTSND
bind ctcp - SOUND PubChkACTSND
proc PubChkACTSND {nick uhost hand dest keyword text} {
if {[string match &* $dest] || [string match #* $dest]} {
PubChk $nick $uhost $hand $dest $text
}
}
bind pubm - * PubChk
proc PubChk {nick userhost handle channel text} {
global BWN BWL BWC RPT Mod
# anti bad word
if {[ChkWbBwVar [string tolower $channel]]} {
set hostban [lindex [split $userhost @] 1]
set templist [join [split [string tolower $text] "!&\"'(-_)=~\{\[|`\\^@\]\}\$%µ?,;:/§"]]
foreach wdt $BWL([string tolower $channel]) {
if {[lsearch -exact "$templist" $wdt] != -1} {
if {$Mod(Warn)} {
if {![info exists BWN([string tolower $userhost])]} {
putserv "NOTICE $nick :$Mod(WarnMsg)"
set BWN([string tolower $userhost]) [expr [clock seconds] + 1800]
} else {
if {$Mod(Ban)} {newchanban $channel *!*@$hostban Moderator "$Mod(KickReason)" $Mod(BanTime)}
if {$Mod(Kick)} {putserv "KICK $channel $nick :$Mod(KickReason)"}
}
return 1
} else {
if {$Mod(Ban)} {newchanban $channel *!*@$hostban Moderator "$Mod(KickReason)" $Mod(BanTime)}
if {$Mod(Kick)} {putserv "KICK $channel $nick :$Mod(KickReason)"}
return 1
}
}
}
# anti repetitions
regsub -all {\\} $text {\\\\} text
regsub -all {\{} $text {\{} text
regsub -all {\}} $text {\}} text
regsub -all {\]} $text {\]} text
regsub -all {\[} $text {\[} text
regsub -all {\"} $text {\"} text
if {[info exists RPT($nick)]} {
if {[lrange $RPT($nick) 2 end] == "$text"} {
set cnt [lindex $RPT($nick) 1]; incr cnt
set RPT($nick) "[lindex $RPT($nick) 0] $cnt [lrange $RPT($nick) 2 end]"
if {[lindex $RPT($nick) 1] > $Mod(RptMax)} {
putserv "KICK $channel $nick :[KReason]"
if {$Mod(BanRep)} {newchanban $channel *!*@$hostban Moderator "Repeat" 10}
unset RPT($nick)
}
} else {set RPT($nick) "[expr [clock seconds] + 10] 1 $text"}
} else {set RPT($nick) "[expr [clock seconds] + 10] 1 $text"}
# anti majuscule / longue chaine
set upper 0
set space 0
foreach i [split $text {}] {
if [string match \[A-Z\] $i] {incr upper}
if {$i == " "} {incr space}
}
if {$upper > $Mod(MaxCaps)} {
if {$Mod(CapsWarn)} {putserv "NOTICE $nick :$Mod(CapsWarnMsg)"}
if {$Mod(KCaps)} {putserv "KICK $channel $nick :$Mod(KCapsReason)"}
}
if {$space == 0 && [string length $text] > $Mod(MaxMotSize) && $Mod(MaxMot)} {
putserv "KICK $channel $nick :$Mod(MaxMotReason)"
}
}
}
proc UnsetRepeat {} {
global RPT
foreach nick [array names RPT] {
if {[lindex $RPT($nick) 0] < [clock seconds]} {unset RPT($nick)}
}
utimer 5 UnsetRepeat
}
foreach t [utimers] {
if {[lindex $t 1] == "UnsetRepeat"} {killutimer [lindex $t 2]}
}
UnsetRepeat
#toute les minute on check pour unseter les var des nick qui sont en avertissement
bind time - "* * * * *" UnsetTmpVar
proc UnsetTmpVar {min hour day month year} {
global BWN RPT
foreach nt [array names BWN] {
if {$BWN($nt) < [clock seconds]} {unset BWN($nt)}
}
}
#procs pour ajouter, enlever, lister les mots a bannir
bind dcc o|o addword AddBadWord
proc AddBadWord {hand idx args} {
global BWL
set chan [string tolower [lindex [console $idx] 0]]
if {![validchan $chan]} {putdcc $idx "Console invalide ($chan)"; return 0}
if {![matchattr [idx2hand $idx] o|o $chan]} {putdcc $idx "Acces refusé pour $chan"; return 0}
set word [string tolower [lindex $args 0]]
if {$word == ""} {putdcc $idx ".addword <mot> (ajoute un mot)"; return 0}
if {![info exists BWL($chan)]} {set BWL($chan) ""}
if {[lsearch -exact "x $BWL($chan)" "$word"] == -1} {
lappend BWL($chan) $word
set f [open Moderator.$chan.list w]
puts $f "$BWL($chan)"
close $f
putdcc $idx "$word ajouté."
return 1
} else {putdcc $idx "$word est deja dans la liste! (taper .listword pour voir la liste)"; return 0}
}
bind dcc o|o delword DelBadWord
proc DelBadWord {hand idx args} {
global BWL
set chan [string tolower [lindex [console $idx] 0]]
if {![validchan $chan]} {putdcc $idx "Console invalide ($chan)"; return 0}
if {![matchattr [idx2hand $idx] o|o $chan]} {putdcc $idx "Acces refusé pour $chan"; return 0}
if {![info exists BWL($chan)]} {putdcc $idx "Aucun mot pour $chan"; return 0}
set word [string tolower [lindex $args 0]]
if {$word == ""} {putdcc $idx ".delword <mot> (efface un mot)"; return 0}
if {[lsearch -exact "$BWL($chan)" "$word"] != -1} {
set f [open Moderator.$chan.list r]
gets $f tmpl
close $f
set newlist ""
foreach t $tmpl {
if {$t != "$word"} {lappend newlist $t}
}
set f [open Moderator.$chan.list w]
puts $f "$newlist"
set BWL($chan) $newlist
close $f
putdcc $idx "$word éffacé."
return 1
} else {putdcc $idx "$word est pas dans la liste! (taper .listword pour voir la liste)"; return 0}
}
bind dcc o|o listword ListBadWord
proc ListBadWord {hand idx args} {
global BWL
set chan [string tolower [lindex [console $idx] 0]]
if {![validchan $chan]} {putdcc $idx "Console invalide ($chan)"; return 0}
if {![matchattr [idx2hand $idx] o|o $chan]} {putdcc $idx "Acces refusé pour $chan"; return 0}
if {![info exists BWL($chan)]} {putdcc $idx "Aucun mot pour $chan"; return 0}
putdcc $idx "Liste des Badwords: $BWL($chan)"
return 1
}
#procs pour ajouter enlever lister les chans a checker
bind dcc o|o +modchan AddChan
proc AddChan {hand idx args} {
global BWC BWL
set tchan [string tolower [lindex $args 0]]
if {$tchan == ""} {putdcc $idx ".+modchan <#channel> (ajoute un canal a surveiller)"; return 0}
if {![validchan $tchan]} {putdcc $idx "Channel invalide ($tchan)"; return 0}
if {![matchattr [idx2hand $idx] o|o $tchan]} {putdcc $idx "Acces refusé pour $tchan"; return 0}
if {[lsearch -exact "x $BWC" "$tchan"] == -1} {
set f [open Moderator.$tchan.list w]
close $f
set BWL($tchan) ""
set f [open Moderator.chan w]
puts $f [lappend BWC $tchan]
close $f
putdcc $idx "$tchan ajouté."
return 1
} else {putdcc $idx "$tchan est deja dans la liste! (taper .modchan pour voir la liste)";return 0}
}
bind dcc o|o -modchan DelChan
proc DelChan {hand idx args} {
global BWC
set tchan [string tolower [lindex $args 0]]
if {$tchan == ""} {putdcc $idx ".-modchan <#channel> (efface un canal surveillé)"; return 0}
if {![validchan $tchan]} {putdcc $idx "Channel invalide ($tchan)"; return 0}
if {![matchattr [idx2hand $idx] o|o $tchan]} {putdcc $idx "Acces refusé pour $tchan"; return 0}
if {[lsearch -exact "x $BWC" "$tchan"] != -1} {
set f [open Moderator.chan r]
set tmpl [gets $f]
close $f
set newlist ""
foreach t $tmpl {
if {$t != "$tchan"} {lappend newlist $t}
}
set f [open Moderator.chan w]
puts $f "$newlist"
close $f
set BWC $newlist
putdcc $idx "$tchan éffacé."
return 1
} else {putdcc $idx "$tchan est pas dans la liste! (taper .modchan pour voir la liste)";return 0}
}
bind dcc - modchan ListChan
proc ListChan {hand idx args} {
global BWC
putdcc $idx "Liste des canaux: $BWC"
return 1
}
bind dcc - Moderator Moderator
proc Moderator {hand idx args} {
global Mod
putdcc $idx " Moderator2.tcl "
putdcc $idx ""
putdcc $idx "ce script comprend un anti badword, un anti"
putdcc $idx "repetition, un anti caps et un anti long mot."
putdcc $idx "il agit sur les msgs/notices/actions/sounds"
putdcc $idx ""
putdcc $idx "commandes pour les Badword"
putdcc $idx "addword <mot> 14(ajoute un mot)"
putdcc $idx "delword <mot> 14(efface un mot)"
putdcc $idx "listword 14(liste les mots)"
putdcc $idx ""
putdcc $idx "commandes pour les canaux"
putdcc $idx "+modchan 14<#channel> (ajoute un canal a surveiller)"
putdcc $idx "-modchan 14<#channel> (efface un canal surveillé)"
putdcc $idx "modchan 14(liste les canaux)"
putdcc $idx ""
return 1
}
putlog "Moderator-02.tcl - (.Moderator for help)"
IRC Snippets