Antispam pour chans et pv configurable

Soyez le premier à donner votre avis sur cette source.

Snippet vu 6 747 fois - Téléchargée 33 fois

Contenu du snippet

Un antispam que je trouve particulièrement complet, configurable via un dialog.
Il n'utilise aucune variable permanente, tout est stocké dans un fichier spam.ini
Vous devez le lancer au moins une fois pour que ce fichier soit créé et que l'antispam fonctionne ^^

Source / Exemple :


on *:LOAD:spam
alias spam dialog -m spam spam
menu channel { 
  Antispam
  .Configuration:spam
  . $+ $iif($replace($chan,$chr(35),[d]) !isin $readini(spam.ini,channel,excludes),Add $chan to excluded chans):writeini spam.ini Channel Excludes $readini(spam.ini,channel,excludes) $replace($chan,$chr(35),[d])
  . $+ $iif($replace($chan,$chr(35),[d]) isin $readini(spam.ini,channel,excludes),Remove $chan from excluded chans):$iif($readini(spam.ini,channel,excludes) == $chan,remini spam.ini Channel excludes,writeini spam.ini Channel Excludes $remove($readini(spam.ini,channel,excludes),$replace($chan,$chr(35),[d])))

  .Add a new badword:writeini spam.ini Channel Badwords $readini(spam.ini,channek,badwords) $replace($$?="New badword ?",$chr(35),[d])
}

menu query {
  Antispam
  .Configuration:spam
  . $+ $iif($1 !isin $readini(spam.ini,pv,excludes),Add $1 to excluded nicks):writeini spam.ini PV Excludes $readini(spam.ini,pv,excludes) $1
  . $+ $iif($1 isin $readini(spam.ini,pv,excludes),Remove $1 from excluded nicks):$iif($readini(spam.ini,pv,excludes) == $1,remini spam.ini PV excludes,writeini spam.ini PV Excludes $remove($readini(spam.ini,pv,excludes),$1))
  .Add a new badword:writeini spam.ini PV Badwords $readini(spam.ini,pv,badwords) $replace($$?="New badword ?",$chr(35),[d])
}
menu nicklist {
  Antispam
  .Configuration:spam
  . $+ $iif($1 !isin $readini(spam.ini,pv,excludes),Add $1 to excluded nicks):writeini spam.ini PV Excludes $readini(spam.ini,pv,excludes) $1
  . $+ $iif($1 isin $readini(spam.ini,pv,excludes),Remove $1 from excluded nicks):$iif($readini(spam.ini,pv,excludes) == $1,remini spam.ini PV excludes,writeini spam.ini PV Excludes $remove($readini(spam.ini,pv,excludes),$1))
}

dialog spam {
  title "Anti-spam -_- Simcamb"
  size -1 -1 179 233
  option dbu
  box "Anti-spam Channel", 1, 6 6 168 111
  box "Anti-spam Pv", 2, 6 124 168 90
  list 3, 10 24 50 35, size
  button "Add", 4, 11 61 21 12
  button "Del", 5, 38 61 21 12
  text "Badwords list", 6, 11 15 48 8
  button "Add", 7, 65 61 21 12
  button "Del", 8, 92 61 21 12
  list 9, 64 24 50 35, size
  text "Excluded channels", 10, 65 15 48 8
  edit "Badword detected (<bad>) !", 50, 11 84 102 10, autohs
  button "Save / Close", 15, 137 218 37 12, ok
  edit "Badword detected by <nick> (<bad>) !", 16, 11 201 102 10, autohs
  button "Add", 18, 10 178 21 12
  button "Del", 19, 38 178 21 12
  button "Add", 20, 65 178 21 12
  button "Del", 21, 92 178 21 12
  list 22, 10 141 50 35, size
  list 23, 64 141 50 35, size
  text "Badwords list", 24, 11 133 48 8
  text "Excluded nicks", 25, 65 133 48 8
  edit "Pub detected on <chan> (<nick>)", 33, 10 104 102 10, autohs
  check "Warning", 37, 116 23 50 10
  check "Pub reply", 38, 116 32 50 10
  check "Kick", 39, 116 41 50 10
  check "Ban", 40, 116 50 50 10
  text "Warning message :", 41, 12 76 49 8
  text "Pub reply :", 42, 12 96 49 8
  text "Warning message :", 43, 12 193 49 8
  check "Warning", 44, 116 141 50 10
  check "Close", 45, 116 149 50 10
  check "Ignore", 46, 116 158 50 10
  edit "", 48, 125 60 18 10, disable
  text "mins", 49, 144 61 16 8
  text "mins", 51, 144 169 16 8
  edit "", 52, 125 168 18 10, disable
  check "Affects ops", 53, 116 74 50 10
  check "Affects voices", 54, 116 84 50 10
  check "Disable spam protection", 55, 6 218 69 10
}
on 1:DIALOG:spam:*:*:{
  if ($devent == INIT) {
    spamlists
    if ($readini(spam.ini,channel,warning) == 1) did -c spam 37
    if ($readini(spam.ini,channel,reply) == 1) did -c spam 38
    if ($readini(spam.ini,channel,kick) == 1) did -c spam 39
    if ($readini(spam.ini,channel,ban) == 1) did -c spam 40

    if ($readini(spam.ini,pv,warning) == 1) did -c spam 44
    if ($readini(spam.ini,pv,close) == 1) did -c spam 45
    if ($readini(spam.ini,pv,ignore) == 1) did -c spam 46

    if ($readini(spam.ini,channel,wmess)) { did -r spam 50 | did -a spam 50 $readini(spam.ini,channel,wmess) }
    if ($readini(spam.ini,channel,pmess)) { did -r spam 33 | did -a spam 33 $readini(spam.ini,channel,pmess) }
    if ($readini(spam.ini,pv,wmess)) { did -r spam 16 | did -a spam 16 $readini(spam.ini,pv,wmess) }

    if ($readini(spam.ini,channel,bantime)) { did -a spam 48 $readini(spam.ini,channel,bantime) }
    if ($readini(spam.ini,pv,ignoretime)) { did -a spam 52 $readini(spam.ini,channel,ignoretime) }

    did $iif($did(spam,40).state == 1,-e,-b) spam 48
    did $iif($did(spam,46).state == 1,-e,-b) spam 52

    if ($readini(spam.ini,channel,banops) == 1) did -c spam 53
    if ($readini(spam.ini,channel,banvoices) == 1) did -c spam 54

    if ($readini(spam.ini,infos,disable) == 1) did -c spam 55

  }
  if ($devent == SCLICK) {
    ;________________
    ;DEBUT DES LISTES|
    ;________________|

    if ($did == 4) { writeini spam.ini Channel Badwords $readini(spam.ini,channel,badwords) $replace($$?="New badword ?",$chr(35),[d]) | spamlists }
    if ($did == 5) {
      if ($did(spam,3).lines > 1) writeini spam.ini Channel Badwords $remove($readini(spam.ini,channel,badwords),$replace($did(spam,3).seltext,$chr(35),[d])) 
      if ($did(spam,3).lines == 1) remini spam.ini Channel Badwords
      spamlists
    }

    if ($did == 7) { writeini spam.ini Channel Excludes $readini(spam.ini,channel,excludes) $replace($$?="Chan to exclude ?",$chr(35),[d]) | spamlists }
    if ($did == 8) {
      if ($did(spam,9).lines > 1) writeini spam.ini Channel Excludes $remove($readini(spam.ini,channel,excludes),$replace($did(spam,9).seltext,$chr(35),[d])) 
      if ($did(spam,9).lines == 1) remini spam.ini Channel Excludes
      spamlists
    }

    if ($did == 18) { writeini spam.ini PV Badwords $readini(spam.ini,pv,badwords) $replace($$?="New badword ?",$chr(35),[d]) | spamlists }
    if ($did == 19) {
      if ($did(spam,22).lines > 1) writeini spam.ini PV Badwords $remove($readini(spam.ini,pv,badwords),$replace($did(spam,22).seltext,$chr(35),[d])) 
      if ($did(spam,22).lines == 1) remini spam.ini PV Badwords
      spamlists
    }

    if ($did == 20) { writeini spam.ini PV Excludes $readini(spam.ini,pv,excludes) $replace($$?="Nick to exclude ?",$chr(35),[d]) | spamlists }
    if ($did == 21) {
      if ($did(spam,23).lines > 1) writeini spam.ini PV Excludes $remove($readini(spam.ini,pv,excludes),$replace($did(spam,9).seltext,$chr(35),[d])) 
      if ($did(spam,23).lines == 1) remini spam.ini PV Excludes
      spamlists
    }

    ;________________
    ; FIN DES LISTES |
    ;________________|

    if ($did == 40) { did $iif($did(spam,40).state == 1,-e,-b) spam 48 }
    if ($did == 46) { did $iif($did(spam,46).state == 1,-e,-b) spam 52 }

    if ($did == 15) {
      writeini spam.ini Channel Wmess $did(50)
      writeini spam.ini Channel Pmess $did(33)
      writeini spam.ini PV Wmess $did(16)
      if ($did(48)) writeini spam.ini Channel Bantime $did(48) 
      if ($did(52)) writeini spam.ini PV Ignoretime $did(52) 
      if (!$did(48)) remini spam.ini Channel Bantime 
      if (!$did(52)) remini spam.ini PV Ignoretime 

      writeini spam.ini Channel Warning $did(37).state 
      writeini spam.ini Channel Reply $did(38).state 
      writeini spam.ini Channel Kick $did(39).state 
      writeini spam.ini Channel Ban $did(40).state

      writeini spam.ini PV Warning $did(44).state 
      writeini spam.ini PV Close $did(45).state 
      writeini spam.ini PV Ignore $did(46).state

      writeini spam.ini Channel Banops $did(53).state 
      writeini spam.ini Channel Banvoices $did(54).state 

      writeini spam.ini Infos Disable $did(55).state

    }

  }
}

alias spamlists {
  did -r spam 3 | did -r spam 9 | did -r spam 22 | did -r spam 23
  var %i = 1
  while ($gettok($readini(spam.ini,channel,badwords),%i,32)) { did -a spam 3 $replace($gettok($readini(spam.ini,channel,badwords),%i,32),[d],$chr(35)) | inc %i }

  var %i = 1
  while ($gettok($readini(spam.ini,channel,excludes),%i,32)) { did -a spam 9 $replace($gettok($readini(spam.ini,channel,excludes),%i,32),[d],$chr(35)) | inc %i }

  var %i = 1
  while ($gettok($readini(spam.ini,pv,badwords),%i,32)) { did -a spam 22 $replace($gettok($readini(spam.ini,pv,badwords),%i,32),[d],$chr(35)) | inc %i }

  var %i = 1
  while ($gettok($readini(spam.ini,pv,excludes),%i,32)) { did -a spam 23 $replace($gettok($readini(spam.ini,pv,excludes),%i,32),[d],$chr(35)) | inc %i }
}
;
on *:TEXT:*:#:{
  if (($nick isop $chan) && ($readini(spam.ini,channel,banops) == 1)) || (($nick isvoice $chan) && ($readini(spam.ini,channel,banvoices) == 1)) || ($nick isreg $chan) && ($me isop $chan) && ($readini(spam.ini,infos,disable) == 0) {
    if ($chan !isin $replace($readini(spam.ini,channel,excludes),[d],$chr(35))) {
      var %bad $replace($readini(spam.ini,channel,badwords),[d],$chr(35))
      var %i = 1
      while ($gettok(%bad,%i,32)) {

        if ($gettok(%bad,%i,32) isin $strip($remove($1-,$chr(32)))) {
          if ($readini(spam.ini,channel,warning) == 1) msg $chan $replace($readini(spam.ini,channel,wmess),<nick>,$nick,<bad>,$gettok(%bad,%i,32))
          if ($readini(spam.ini,channel,reply) == 1) && ($chr(35) isin $1-) && ($me !isin $wildtok($1-,#*,1,32)) { join $wildtok($1-,#*,1,32) | msg $wildtok($1-,#*,1,32) $replace($readini(spam.ini,channel,pmess),<nick>,$nick,<bad>,$gettok(%bad,%i,32),<chan>,$chan) | part $wildtok($1-,#*,1,32) }
          if ($readini(spam.ini,channel,ban) == 1) { mode $chan +b $address($nick,2) }
          if ($readini(spam.ini,channel,bantime)) { .timer 1 $calc($readini(spam.ini,channel,bantime)*60) mode $chan -b $address($nick,2) }
          if ($readini(spam.ini,channel,kick) == 1) { kick $chan $nick $replace($readini(spam.ini,channel,wmess),<nick>,$nick,<bad>,$gettok(%bad,%i,32))
            return
          }
        }
        inc %i
      }
    }
  }
  else return
}
on *:OPEN:?:*:{
  if ($nick !isin $read(spam.ini,pv,excludes)) && ($readini(spam.ini,infos,disable) == 0) {
    var %bad $replace($readini(spam.ini,pv,badwords),[d],$chr(35))
    var %i = 1
    while ($gettok(%bad,%i,32)) {
      if ($gettok(%bad,%i,32) isin $strip($remove($1-,$chr(32)))) {
        if ($readini(spam.ini,pv,warning) == 1) msg $nick $replace($readini(spam.ini,pv,wmess),<nick>,$nick,<bad>,$gettok(%bad,%i,32))
        if ($readini(spam.ini,pv,close) == 1) close -m $nick
        if ($readini(spam.ini,pv,ignore) == 1) ignore -p $nick
        if ($readini(spam.ini,pv,ignoretime)) .timer 1 $calc($readini(spam.ini,pv,ignoretime)*60) ignore -r $nick
        return
      }
      inc %i
    }
  }
}

Conclusion :


Je l'ai mis en débutant, le code n'est pas particulierement complexe pour peu qu'on aie des notions de base et qu'on sache se servir de l'aide ^^

MAJ 2 (13/10/04) : Ajout d'une case pour désactiver la protection.

MAJ 1 (11/10/04) : Meilleure detection du spam, ajout d'un menu channel, query et nicklist, pour acceder au dialog, ajouter/retirer un pseudo/chan dans la liste excluded, et ajouter des badwords

A voir également

Ajouter un commentaire Commentaires
Messages postés
28
Date d'inscription
jeudi 30 janvier 2003
Statut
Membre
Dernière intervention
26 janvier 2005

The @ prefix
You can limit events to being executed only when you have Ops on a channel by using the @ prefix.

Ha oui... personnellement j'ai jamais utilisé les levels ou les prefixes :x
Messages postés
28
Date d'inscription
jeudi 30 janvier 2003
Statut
Membre
Dernière intervention
26 janvier 2005

Heu coolman...


var %a http # www | if $istok(%a,$1-,32) { }

C'est strictement la même chose que

$istok(http # www,http://www.truc.com,32)

Sauf que je remplace les var et identifieurs pour leur valeur..

Et le @ devant sert à quoi ?
Messages postés
969
Date d'inscription
lundi 16 juin 2003
Statut
Membre
Dernière intervention
1 juillet 2012
1
et aussi:
on *:TEXT:*:#:{
devient
on @*:TEXT:*:#:{
Messages postés
969
Date d'inscription
lundi 16 juin 2003
Statut
Membre
Dernière intervention
1 juillet 2012
1
$istok(http # www,http://www.truc.com,32)

-> $false

Vraiment désolé, mais j'arrive vraiment pas :/

tofu a dit:

var %a http # www | if $istok(%a,$1-,32) { }
Messages postés
23
Date d'inscription
vendredi 26 mars 2004
Statut
Membre
Dernière intervention
24 avril 2005

Quand je penses que c'est moi qui ai doné l'idée et qui l'ai emerder pour qu'il le fasse :D
Je suis vraiment un connard !
Mais un connard heureu qui trouve que Simcamb merite sa place dans le top15 des scripteurs qui aident le plus les autres !

MMMMMMMMMMMMMEEEEEEEEEEEERRRRRRRRRCCCCCCCCCIIIIIIIIIIIIIII !!!!!!!!!!!!!!!!!!!

et à bas le spawm !!!!

b3n
Afficher les 16 commentaires

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.