aide dans les anti-caps TCL
#1
Je voulais modifier le tcl en ajoutant un chemin au code où, par exemple, il ignore l'utilisation de : or ;

tcl
# caps.tcl

# set bot user flags to ignore text
set vCapsFlagsAllow fo

# set text length (excluding spaces) to allow without checking
set vCapsLengthAllow 8

# set maximum percentage caps allowed (calculation excludes spaces in text)
# greater than 0, less than or equal to 100
set vCapsPercentAllow 90

# set number of warnings before punishing
# integer value equal to or greater than 1
set vCapsWarnings 3

# set here the mode of punishment
# 1 == kick only (after warnings)
# 2 == kickban (after warnings)
set vCapsPunishMode 1

# time in minutes within which a warning remains valid
# even after the user is punished, passed offences remain valid for this time period
# hence a user could be punished twice for two consecutive offences
set vCapsSinTime 20

# if punishment mode 2, set here the time in minutes the ban lasts
set vCapsBanTime 10

# Set this to 1 to ignore nicks in lines
set vIgnoreNick 1
 
proc ldiff {list1 list2 {option -exact}} {
   if {$option ne "-nocase"} { set option -exact }
   return [lmap x $list1 {expr {[lsearch $option $list2 $x] < 0 ? $x : [continue]}}]
}
 
proc ctcp_capslock {nick uhost hand chan keyword arg} {
   pCapsDetect $nick $uhost $hand $chan $arg
}
 
bind PUBM - * pCapsDetect
 
proc pCapsDetect {nick uhost hand chan text} {
   global vCapsBanTime vCapsFlagsAllow vCapsLengthAllow vCapsPercentAllow
   global vCapsPunishMode vCapsSinBin vCapsSinTime vCapsWarnings
 
   if {[isbotnick $chan] || [string match -nocase "*:*" $text] || [string match -nocase "*;*" $text]} { return 0 }
   if {[botisop $chan]} {
      if {![matchattr [nick2hand $nick] $vCapsFlagsAllow $chan]} {
         if {$::vIgnoreNick == 1} {
            set nicks [split [chanlist $chan]]
            set text [join [ldiff [split $text] $nicks]]
         }
         set caps [regexp -all -- {[A-Z]} $text]
         set total [string length [regsub -all -- {[\s]} $text {}]]
         if {$total > $vCapsLengthAllow} {
            set percent [expr {$caps * 100.0 / $total}]
            if {$percent > $vCapsPercentAllow} {
               set now [unixtime]
               set max [expr {$now - ($vCapsSinTime * 60)}]
               lappend vCapsSinBin(${nick},$chan) $now
               foreach sin $vCapsSinBin(${nick},$chan) {
                  if {$sin >= $max} {lappend newlist $sin}
               }
               set vCapsSinBin(${nick},$chan) $newlist
               if {[llength $vCapsSinBin(${nick},$chan)] > $vCapsWarnings} {
                  switch -- $vCapsPunishMode {
                     1 {}
                     2 {
                        pushmode $chan +b ${nick}!$uhost
                        flushmode $chan
                        timer $vCapsBanTime [list pushmode $chan -b ${nick}!$uhost]
                     }
                     default {return 0}
                  }
                  putkick $chan $nick "excess caps, you were warned"
               } else {
                  set output "*** [llength $vCapsSinBin(${nick},$chan)] WARNING(S) *** within the last $vCapsSinTime minutes for excess caps"
                  putserv "PRIVMSG $chan :$nick $output"
               }
            }
         }
      }
   }
   return 0
}

# eof



Modération: merci de ne pas copier/coller d'un site mettant de la coloration syntaxique
Répondre Avertir
#2
Tu veux rajouter un chemin à quoi ?
Je ne suis pas sûr de comprendre la demande
Répondre
#3
@dino, il serait sympa que tu répondes lorsqu'on te pose des questions pour essayer de t'aider.
J'aurais pu croire que tu n'avais pas vu la réponse (et la question qu'elle contient) or tu as à nouveau posté, donc logiquement lu ma participation.

Merci d'avance.

P.S.: ceci vaut aussi pour ton autre demande.
Répondre


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté