Scripting
Bonjour / Bonsoir,

Bienvenue sur ce forum.

Merci, de vous connectez si vous ne l'êtes pas.

Merci, de vous enregistrez si vous ne l'êtes pas. Ceci prend même pas une minute.

Cordialement,

Dylan

Rejoignez le forum, c’est rapide et facile

Scripting
Bonjour / Bonsoir,

Bienvenue sur ce forum.

Merci, de vous connectez si vous ne l'êtes pas.

Merci, de vous enregistrez si vous ne l'êtes pas. Ceci prend même pas une minute.

Cordialement,

Dylan
Scripting
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment : -50%
Ampli Home Cinema Denon AVR-X1700H à 399€
Voir le deal
399 €

Système de blackliste

Aller en bas

Système de blackliste Empty Système de blackliste

Message  Dylan Ven 12 Fév - 12:02

Code:
#bl on
;-Partie détection:
on !@*:join:#:{
  if ( $readini(configuration.ini,blackliste,status) == on && $ini(configuration.ini,bliste,0) ) {
    var %k = 1
    while ( %k <= $ini(configuration.ini,bliste,0) ) {
      if ( $ini(configuration.ini,bliste,%k) iswm $address($nick,5) ) {
        var %chansbl = $wildtok($readini(configuration.ini,bliste,$$ini(configuration.ini,bliste,%k)),[*],1,32)
        if ( $+([,$chr(35),]) isin %chansbl || ( $+(-,$chan) !isin %chansbl && $+([,-) isin %chansbl ) || ( $chan isin %chansbl && $+(-,$chan) !isin %chansbl ) ) {
          kick # $nick $gettok($readini(configuration.ini,bliste,$$ini(configuration.ini,bliste,%k)),1,91)
          mode # -e+b $$ini(configuration.ini,bliste,%k) $$ini(configuration.ini,bliste,%k)
        }
      }
      inc %k
    }
  }
}
;-Partie gestion de la liste:
on *:input:*: {
  if ( $1 == !bl ) { haltdef | bl $2 | if ( !$isfile(configuration.ini) ) { clearbl } }
  elseif ( $1 == !listbl ) { haltdef | listbl $2- }
  elseif ( $1 == !clearbl ) { haltdef | set %noticebl on | clearbl }
  elseif ( $1 == !setbl ) { haltdef | set %noticebl on | setbl $2 }
  elseif ( $1 == !addbl ) { haltdef | set %noticebl on | addbl $2- }
  elseif ( $1 == !delbl ) { haltdef | set %noticebl on | delbl $2- }
}
alias setbl {
  if ( !$istok(on off echo pv,$1,32) ) { .notice $me Syntaxe erronée, taper !bl }
  elseif ( $1 == $readini(configuration.ini,blackliste,status) || $1 == $readini(configuration.ini,blackliste,mode) ) { if ( %noticebl == on ) { .notice $me C'est déjà le cas! } }
  elseif ( $istok(on off,$1,32) ) { writeini configuration.ini blackliste status $1 | if ( %noticebl == on ) { .notice $me blacklist $replace($readini(configuration.ini,blackliste,status),on,activée!,off,désactivée) } }
  else { writeini configuration.ini blackliste mode $1 | if ( %noticebl == on ) { .notice $me blacklist $replace($readini(configuration.ini,blackliste,mode),pv,avec liste en pv,echo,avec liste en echo) } }
  unset %noticebl
}
alias clearbl {
  .remini configuration.ini blackliste
  .remini configuration.ini bliste
  .fopen -on configuration configuration.ini
  .fwrite -n configuration [blackliste]
  .fwrite -n configuration status=on
  .fwrite -n configuration masks=
  .fwrite -n configuration mode=pv
  .fwrite -n configuration [bliste]
  .fclose configuration
  if ( %noticebl == on ) { .notice $me Blacklist effacée (et sur "activée", liste en "pv"), fichier réinitialisé. }
  unset %noticebl
}
alias addbl {
  if ( !$2 || $chr(35) isin $2 ) { if ( %noticebl == on ) { .notice $me il faut au moins un mask et une raison (taper !bl pour revoir la syntaxe) } }
  else {
    var %mask = $1 , %raison = $2-
    if ( !$wildtok(%raison,[*],1,32) ) { var %raison = $+(%raison,$chr(32),[,$chr(35),]) }
    if ( $chr(33) !isin %mask && $chr(64) !isin %mask ) { var %mask = $+(%mask,!*@*) }
    if ( !$istok($readini(configuration.ini,blackliste,masks),%mask,32) ) { writeini configuration.ini blackliste masks $+($readini(configuration.ini,blackliste,masks),$chr(32),%mask) | if ( %noticebl == on ) { .notice $me Mask %mask ajouté avec succès } }
    elseif ( %noticebl == on ) { .notice $me ban modifié avec succès }
    writeini configuration.ini bliste %mask %raison $asctime(HH:nn-dd/mm/yy)
  }
  unset %noticebl
}
alias delbl {
  var %black = 1
  while ( %black <= $numtok($1-,32) ) {
    if ( $istok($readini(configuration.ini,blackliste,masks),$gettok($1-,%black,32),32) ) { var %blackyes = $+(%blackyes,$chr(32),$gettok($1-,%black,32)), %while = on }
    elseif ( $istok($readini(configuration.ini,blackliste,masks),$+($gettok($1-,%black,32),!*@*),32) ) { var %blackyes = $+(%blackyes,$chr(32),$+($gettok($1-,%black,32),!*@*)), %while = on }
    elseif ( $gettok($1-,%black,32) isnum $+(1-,$ini(configuration.ini,bliste,0)) ) { var %blackyes = $+(%blackyes,$chr(32),$ini(configuration.ini,bliste,$gettok($1-,%black,32))), %while = on }
    elseif ( $chr(45) isin $1 ) {
      var %inf = $gettok($gettok($1-,%black,32),1,45)
      var %sup = $gettok($gettok($1-,%black,32),2,45)
      if ( %inf isnum $+(1-,$ini(configuration.ini,bliste,0)) && %sup isnum $+(1-,$ini(configuration.ini,bliste,0)) && %inf < %sup ) {
        var %i = %inf
        while ( %i <= %sup ) {
          var %blackyes = $+(%blackyes,$chr(32),$ini(configuration.ini,bliste,%i))
          inc %i
        }
        var %j = 1
        var %while = on
      }
    }
    else { var %blackno = $+(%blackno,$chr(32),$gettok($1-,%black,32)) }

    inc %black
  }
  if ( %while = on ) {
    var %j = 1
    while ( %j <= $numtok(%blackyes,32) ) {
      remini configuration.ini bliste $gettok(%blackyes,%j,32)
      if ( $remtok($readini(configuration.ini,blackliste,masks),$gettok(%blackyes,%j,32),1,32) ) { writeini configuration.ini blackliste masks $remtok($readini(configuration.ini,blackliste,masks),$gettok(%blackyes,%j,32),1,32) }
      else { write -wmasks=* configuration.ini masks= }
      inc %j
    }
  }
  if ( %blackno ) { var %blackno = $+(Mask(s) absent(s) de la liste:,$chr(32),%blackno) }
  if ( %blackyes ) { var %blackyes = $+(Entrée(s) supprimée(s):,$chr(32),%blackyes) }
  if ( !%blackyes && !%blackno && %noticebl == on ) { .notice $me syntaxe error / mask absent, taper !bl }
  elseif ( %noticebl == on ) { .notice $me %blackno . %blackyes }
  unset %noticebl
}
alias -l listbl {
  var %inf = $gettok($1-,1,45), %sup = $gettok($1-,2,45)
  if ( !$1 || ( ( $chr(45) isin $1 ) && ( %inf isnum $+(1-,$ini(configuration.ini,bliste,0)) && %sup isnum $+(1-,$ini(configuration.ini,bliste,0)) && %inf < %sup ) ) ) {
    if ( !%inf || !%sup ) { var %inf = 1 | var %sup = $ini(configuration.ini,bliste,0) }
    var %i = %inf
    if ( $readini(configuration.ini,blackliste,mode) == pv ) {
      .notice $me $+(12,$calc( %sup - %inf + 1 ),$chr(32),entrées (en pv))
      .msg $me Blacklist: $replace($readini(configuration.ini,blackliste,status),on,10activée,off,4désactivée) avec $+(12,$calc( %sup - %inf + 1 ),$chr(32),entrées sur,$chr(32),$ini(configuration.ini,bliste,0),,:) $+([,%inf,-,%sup,])
      while ( %i <= %sup ) {
        .msg $me $+(%i,$str($chr(160),$calc( 3 - $len(%i) )),$chr(3),12,$$ini(configuration.ini,bliste,%i),$chr(160),$chr(160),$chr(3),03,$readini(configuration.ini,bliste,$$ini(configuration.ini,bliste,%i)))
        inc %i
      }
    }
    else {
      echo -a > Blacklist: $replace($readini(configuration.ini,blackliste,status),on,10activée,off,4désactivée) avec $+(12,$calc( %sup - %inf + 1 ),$chr(32),entrées sur,$chr(32),$ini(configuration.ini,bliste,0),,:) $+([,%inf,-,%sup,])
      while ( %i <= %sup ) {
        echo -a $+(%i,$str($chr(160),$calc( 3 - $len(%i) )),$chr(3),12,$$ini(configuration.ini,bliste,%i),$chr(160),$chr(160),$chr(3),03,$readini(configuration.ini,bliste,$$ini(configuration.ini,bliste,%i)))
        inc %i
      }
    }
  }
  elseif ( $istok($readini(configuration.ini,blackliste,masks),$1,32) ) { .notice $me $1 : $readini(configuration.ini,bliste,$1) }
  elseif ( $istok($readini(configuration.ini,blackliste,masks),$+($1,!*@*),32) ) { .notice $me $+($1,!*@*) : $readini(configuration.ini,bliste,$+($1,!*@*)) }
  elseif ( $1 == quick ) { .notice $me $+(12,$ini(configuration.ini,bliste,0),) entrée(s) - $readini(configuration.ini,blackliste,masks) }
  else { .notice $me syntaxe error / mask absent, taper !bl }
}
alias -l bl {
  if ( !$1 ) { .notice $me 12,00Blacklist par UtopiK $replace($readini(configuration.ini,blackliste,status),on,10activée!,off,05désactivée) $replace($readini(configuration.ini,blackliste,mode),pv,avec liste en 12pv,echo,avec liste en 12echo) | .notice $me Liste des commandes: 6!addbl !delbl 6!listbl !clearbl 6!setbl $chr(124) Pour plus d'aide: !bl commande Ex: !bl addbl (et non: !bl !addbl) $chr(124) Pour désactiver taper: 06!setbl off $chr(124) En cas de bug, faire: !clearbl }
  elseif ( $1 == addbl ) { .notice $me Commande pour ajouter/modifier une entrée dans la blacklist: 6!addbl *bob* malpoli ! $chr(124) Autre exemple, avec une exception de chan (marchera sur les chans #chan1 et #chan2 uniquement): 6!addbl *!*@*blabla.net pas de proxy merci [#chan1,#chan2] $chr(124) Un dernier (blacklist sur tous les chans, sauf #chan1 et #chan2): 6!addbl *!grosboulet@* persona non grata [-#chan1,-#chan2] $chr(124) Eviter les crochets [] dans le motif }
  elseif ( $1 == delbl ) { .notice $me Commande pour supprimer des entrées dans la blacklist: 6!delbl *bob* $chr(124) 6!delbl *bob* *!*@*blabla.net $chr(124) Vous pouvez utiliser des numéros: 6!delbl 1 (supr la 1ère entrée de la liste) ou 6!delbl 1 14 32 ou même des plages: 6!delbl 2-12 }
  elseif ( $1 == listbl ) { .notice $me Commande pour lister les entrées dans la blacklist: 6!listbl ou pour en avoir juste une partie: 6!listbl 6-10 ou une version en une ligne sans détails: 6!listbl quick $chr(124) Pour voir si un mask est dans la blacklist: 6!listbl *bob* }
  elseif ( $1 == clearbl ) { .notice $me Commande pour effacer la blacklist et réparer le fichier de la liste en cas de bug: 6!clearbl }
  elseif ( $1 == setbl ) { .notice $me Commande pour configurer la blacklist. Activer/désactiver: 6!setbl on ou 6!setbl off (elle n'est pas effacée) $chr(124) Liste en écho ou par pv: 6!setbl pv ou 6!setbl echo }
  else { .notice $me Commande inconnue / Mauvaise syntaxe - rééssayer !bl }
}
#bl end

Déjà tester marche très bien Wink
Dylan
Dylan
Administrateur

Messages : 221
Date d'inscription : 23/11/2009
Age : 29
Localisation : Chez moi ...

https://scripting.forumactif.com

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum