Unban Niubot..
#1
Bonjour,

Suite à un privé d'une personne pour une aide je post.
Cette personne ma demander s'il était possible d'interdire des bans sur un salon.

Oui c'est possible..
Ensuite cette personne désire interdire aussi bien les bans via un autre bot et avec la commande /mode....

Donc Voici ce que sa donne le code que j'avais fait ya un moment déjà.
Bon c'est mal optimiser et sa demande certaines choses beaucoup plus appliquer..
Mais le principe reste pas mal.

Voici le code :

TCL
namespace eval ::niuban {
 
    variable niubotchan "#salon"
    bind MODE - "* +b" [namespace current]::unban_niubot
    proc unban_niubot { nick uhost hand chan mc target } {
        variable niubotchan
        if (![isbotnick $nick]) {
            if {[string match -nocase niubot?? $nick]} {
                if {[isban $target $chan]} { return 0 }
                    putquick "PRIVMSG $niubotchan :unban $target $chan"
                    } else {
                       putquick "mode $chan -ob $nick $target"
                       puthelp "privmsg $niubotchan :\037\0034Seuls les bans via $::botnick sont autorisés !\037\0034"
                    }
        }
    }



Remplacer la variable : variable niubotchan "#salon"
Par votre nom de salon.
PS : si votre eggdrop ban il ne sera par retiré le ban.
Seul les ban via Niubot ou avec /mode... de votre client seront retiré.
Répondre Avertir
#2
Il y a une légère optimisation que je ferais: contrôler que la victime est bannie avant le reste.
D'autant plus qu'il me semble voir une erreur: si un autre utilisateur que Niubot pose un ban, tu débannis (et deop le poseur) sans vérifier si la victime doit être bannie.
Voici comment j'agencerais ton code:
TCL
namespace eval ::niuban {
   variable niubotchan "#salon"
   bind MODE - "* +b" [namespace current]::unban_niubot
   proc unban_niubot { nick uhost hand chan mc target } {
      variable niubotchan
      if {[isbotnick $nick]} { return 0 }
      if {[isban $target $chan]} { return 0 }
 
      if {[string match -nocase niubot?? $nick]} {
         putquick "PRIVMSG $niubotchan :unban $target $chan"
      } else {
         putquick "mode $chan -ob $nick $target"
         puthelp "privmsg $niubotchan :\037\0034Seuls les bans via $::botnick sont autorisés !\037\0034"
      }
   }
}


Répondre
#3
Oui en effet y avait bien une erreur.
De plus je pense que je devrais même y inclure un setudef ce qui sera mieux.
Répondre Avertir
#4
Ah oui tiens, il y a encore un bug: tu ne vérifies pas que le bind réagit sur le bon canal.
Il manque un:
TCL
if { [string tolower $chan] == [string tolower $::niuban::niubotchan] } { return 0 }


Répondre
#5
En faite l'idée serait de le faire sur setudef.
Donc ce qui donnerais :

TCL
namespace eval ::niuban {
 
    setudef flag NB
   bind MODE - "* +b" [namespace current]::unban_niubot
   proc unban_niubot { nick uhost hand chan mc target } {
      variable niubotchan
      if {[isbotnick $nick]} { return 0 }
      if {[isban $target $chan]} { return 0 }
        if {[channel get $chan NB]} {
      if {[string match -nocase niubot?? $nick]} {
         putquick "PRIVMSG $niubotchan :unban $target $chan"
      } else {
         putquick "mode $chan -ob $nick $target"
         puthelp "privmsg $niubotchan :\037\0034Seuls les bans via $::botnick sont autorisés !\037\0034"
      }
    }
   }
}



Plus ou moins si je ne me trompe pas.. Je testerai dans la journée voir mais je pense que sa serait l'idée
Répondre Avertir


Atteindre :


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