Jump to content

Archived

This topic is now archived and is closed to further replies.

coders-irc_Bot

Module de ban à vue

Recommended Posts

  • Administrators

KiPWMp8m-44678.png

 

Ce module est utile (certains vont grincer des dents) pour les salons officiels du server voila/orange. En effet les robots unban systématiquement au bout de 10 ou 20 minutes.
Ce code permet de gérer une blacklist:
- Il peut reposer les bans de la blacklist dès qu'ils sont retirés
- Il pose les bans dès qu'on est opé
- Il kb les masks blacklistés dès le join

C'est configurable, on peut cocher l'option pour que les bans soient tjrs présents dans la banlist, ou bien se servir du module comme simple system de blacklist. Il y a une option pour les personnes ayant un accès IRCop (pour ne pas prendre en compte le fait qu'il soit @ sur un salon ou pas).
Enfin je vous laisse voir et surtout.. critiquer pour voir les ameliorations possibles.
Oui oui nsh j'utilise un peu de regexp 🐵
Akira]

alias bav dialog -m bav bav
dialog BAV {
  title "Module de Bàv"
  size -1 -1 197 113
  option dbu
  combo 2, 95 35 45 61, size drop
  combo 1, 95 20 45 43, size drop
  button "Add", 3, 145 20 22 12
  button "Del", 4, 170 20 22 12
  button "Add", 5, 145 35 22 12
  button "Del", 6, 170 35 22 12
  check "On", 7, 80 4 19 10
  check "Off", 8, 100 4 24 10
  text "Salons ou le module bàv est actif:", 9, 5 20 85 8, center
  text "Activation du module bàv:", 10, 5 5 67 8, center
  text "Liste des masks à bàv:", 11, 5 35 59 8, center
  text "Module inactif si le pseudo qui unban fait partie de la liste:", 12, 5 50 76 14, center
  combo 13, 95 50 45 61, size drop
  button "Add", 14, 145 50 22 12
  button "Del", 15, 170 50 22 12
  text "Oper:", 16, 5 70 18 8, center
  check "Oui", 17, 30 69 21 10
  check "Non", 18, 52 69 24 10
  button "Close", 19, 151 70 37 12, ok
  text "Mise à jour de la banlist auto:", 20, 5 85 76 8, center
  check "Oui", 21, 89 84 21 10
  check "Non", 22, 111 84 22 10
  text "Message de kick on join:", 23, 5 100 62 8, center
  edit "", 24, 75 100 118 10
}

on *:start: {
  if !$hget(bav) { hmake bav 100 } | if !$hget(pseudos) { hmake pseudos 100 } | if !$hget(masks) { hmake masks 100 }
  if $isfile(system/bav.ini) { hload bav system/bav.ini }
  if $isfile(system/masks.ini) { hload masks system/masks.ini }
  if $isfile(system/pseudos.ini) { hload pseudos system/pseudos.ini }
}
on *:dialog:BAV:*:*: {
  if $devent == init {
    if !$hget(bav) { hmake bav 100 } | if !$hget(pseudos) { hmake pseudos 100 } | if !$hget(masks) { hmake masks 100 }
    if $isfile(system/bav.ini) { hload bav system/bav.ini }
    if $isfile(system/masks.ini) { hload masks system/masks.ini }
    if $isfile(system/pseudos.ini) { hload pseudos system/pseudos.ini }
    if !$hget(bav,state) { hadd -m bav state 0 | did -c $dname 8 }
    elseif $hget(bav,state) { did -c $dname 7 }
    if !$hget(oper,state) { hadd -m oper state 0 | did -c $dname 18 }
    elseif $hget(oper,state) { did -c $dname 17 }
    if $hget(bav,maj) { did -c $dname 21 }
    elseif !$hget(bav,maj) { hadd -m bav maj 0 | did -c $dname 22 }
    if $hget(bav,msg) { did -a $dname 24 $v1 }
    if $hget(bav,salon) { didtok $dname 1 59 $hget(bav,salon) | did -c $dname 1 1 }
    if $hget(masks,$gettok($hget(bav,salon),1,59)) { didtok $dname 2 59 $hget(masks,$gettok($hget(bav,salon),1,59)) | did -c $dname 2 1 }
    if $hget(pseudos,$gettok($hget(bav,salon),1,59)) { didtok $dname 13 59 $hget(pseudos,$gettok($hget(bav,salon),1,59)) | did -c $dname 13 1 }
  }
  elseif $devent == sclick {
    if $did == 3 {
      hadd -m bav salon $addtok($hget(bav,salon),$?="Salons de détection:",59) | did -r $dname 1 | didtok $dname 1 59 $hget(bav,salon) | did -c $dname 1 1
    }
    elseif $did == 4 {
      hdel masks $did(1)
      hdel pseudos $did(1)
      hadd -m bav salon $remtok($hget(bav,salon),$did(1),59) | did -r $dname 1 | didtok $dname 1 59 $hget(bav,salon) | did -c $dname 1 1
    }
    elseif $did == 5 {
      hadd -m masks $did(1) $addtok($hget(masks,$did(1)),$?="Liste des masks bàv ex: coollavie*!*@* *ciji*!guest@*",59) | did -r $dname 2 | didtok $dname 2 59 $hget(masks,$did($dname,1))
      did -c $dname 2 1
    }
    elseif $did == 6 {
      hadd -m masks $did(1) $remtok($hget(masks,$did(1)),$did(2),59) | did -r $dname 2 | didtok $dname 2 59 $hget(masks,$did($dname,1))
      did -c $dname 2 1
    }
    elseif $did == 7 {
      did -u $dname 8 | hadd -m bav state 1
    }
    elseif $did == 8 {
      did -u $dname 7 | hadd -m bav state 0
    }
    elseif $did == 14 {
      hadd -m pseudos $did(1) $addtok($hget(pseudos,$did(1)),$?="Liste des pseudos autorisés à unban ex: unreal Platine",59) | did -r $dname 13 | didtok $dname 13 59 $hget(pseudos,$did($dname,1))
      did -c $dname 13 1
    }
    elseif $did == 15 {
      hadd -m pseudos $did(1) $remtok($hget(pseudos,$did(1)),$did(13),59) | did -r $dname 13 | didtok $dname 13 59 $hget(pseudos,$did($dname,1))
      did -c $dname 13 1
    }
    elseif $did == 17 {
      hadd -m oper state 1 | did -u $dname 18
    }
    elseif $did == 18 {
      hadd -m oper state 0 | did -u $dname 17
    }
    elseif $did == 21 {
      did -u $dname 22
      hadd -m bav maj 1
    }
    elseif $did == 22 {
      did -u $dname 21
      hadd -m bav maj 0
    }
    elseif $did == 1 {
      did -r $dname 2,13
      if $hget(masks,$did(1)) { didtok $dname 2 59 $hget(masks,$did(1)) | did -c $dname 2 1 }
      if $hget(pseudos,$did(1)) { didtok $dname 13 59 $hget(pseudos,$did(1)) | did -c $dname 13 1 }
    }
    if !$isdir(system) { mkdir system }
    hsave bav system/bav.ini
    hsave masks system/masks.ini
    hsave pseudos system/pseudos.ini
  }
  elseif $devent == edit && $did == 24 { hadd -m bav msg $did(24) }
  elseif $devent == close {
    if $hget(bav,state) && $status != disconnected && $hget(bav,maj) {
      var %a = 1 
      while $gettok($hget(bav,salon),%a,59) {
        ban_a_vue $v1
        inc %a
      }
    }
  }
}

alias ban_a_vue {
  var %a = 1, %h = $1
  if $me !isop %h && !$hget(oper,state) { return }
  while $ibl(%h,%a) {
    var %w = $addtok(%w,$v1,59)
    inc %a
  }
  var %a = 1
  while $gettok($hget(masks,%h),%a,59) {
    if !$istok(%w,$v1,59) { var %d = $addtok(%d,$gettok($hget(masks,%h),%a,59),32) }
    if $numtok(%d,32) == 3 {
      mode %h +bbb %d
      var %d = $null
    }
    inc %a
  }
  if %d {
    mode %h $+(+,$str(b,$numtok(%d,32))) %d
  }
}

on *:op:*: {
  if !$hget(oper,state) && $me !isop $chan || !$hget(bav,state) || !$hget(bav,maj) { return }
  if $istok($hget(bav,salon),$chan,59) {
    var %a = 1
    while $ibl($chan,%a) {
      var %w = $addtok(%w,$v1,59)
      inc %a
    }
    var %a = 1
    while $gettok($hget(masks,$chan),%a,59) {
      if !$istok(%w,$v1,59) { var %d = $addtok(%d,$gettok($hget(masks,$chan),%a,59),32) }
      if $numtok(%d,32) == 3 {
        mode $chan +bbb %d
        var %d = $null
      }
      inc %a
    }
    if %d {
      mode $chan $+(+,$str(b,$numtok(%d,32))) %d
    }
  }
}

on *:rawmode:*: {
  if !$hget(oper,state) && $me !isop $chan || !$hget(bav,state) || !$istok($hget(bav,salon),$chan,59) || !$hget(bav,maj) { return }
  if -b isin $1 && !$istok($hget(pseudos,$chan),$nick,59) {
    var %a = 1, %d = /
    while $gettok($hget(masks,$chan),%a,59) {
      var %d = $+(%d,$chr(40),$replace($v1,*,\*,|,\|,?,\?),$chr(41),$chr(124))
      inc %a
    }
    var %d = $+(%d,/ig)
    if $regex($1-,%d) {
      if $regml(1) { mode $chan $+(+,$iif($regml(3),bbb,$iif(regml(2),bb,b))) $regml(1) $regml(2) $regml(3) }
    }
  }
}

on *:join:#: {
  if !$hget(oper,state) && $me !isop $chan || !$hget(bav,state) { return }
  var %a = 1
  while $gettok($hget(masks,$chan),%a,59) {
    if $v1 iswm $+($nick,!,$address) { mode $chan +b $gettok($hget(masks,$chan),%a,59) | kick $chan $nick $hget(bav,msg) | break }
    inc %a
  }
}

 

Link to comment
Share on other sites



×
×
  • Create New...