29/11/2007, 11:36 (Modification du message : 29/11/2007, 13:19 par CrazyCat.)
tcl
set commande(choix)"!"
bind pub - $commande(choix)grrr pub:grrr
proc pub:grrr {nick host hand chan arg}{global commande botnick
if{[isop $nickdubot$chan]}{set who [lindex$arg0]if{$who == ""}{
putserv "notice $nick :Non mais, met un pseudo espece de boulet !!"}else{if{![matchattr $hand o]}{
putserv "notice $nick :Non mais,tu y croyais toi!!Faut pas rêver!!"return0}else{set usermask [lindex[split[getchanhost $who$chan]"@"]0]set ipmask [lindex[split[maskhost $who![getchanhost $who$chan]]"@"]1]set nickidenthostermask $who![getchanhost $who$chan]set identhostmask [lindex[split$nickidenthostermask"!"]1]set hostmask [lindex[split$identhostmask"@"]1]
putserv "privmsg $chan :Hello $who"
putserv "privmsg $chan :Je suis le bot de ce chan"
putserv "privmsg $chan :On m a dit de m'occuper de toi"
putserv "MODE $chan -qaohv $who $who $who $who $who"
putserv "privmsg $chan :Alors, comme je suis obéissant"
putserv "privmsg $chan :Alors, pour débuter, je pose deux bans"
putserv "MODE $chan +bb $who *!*$usermask*@*"
putserv "privmsg $chan :Oh et puis soyons fou, un troisieme "
putserv "MODE $chan +b *!*@$hostmask"
putserv "privmsg $chan :Et maintenant, je te kick"
putserv "KICK $chan $who On m a demandé de t attaquer alors au revoir !!!!!!!"}}}else{
putserv "notice $nick :desolé $nick, je ne suis pas actuellement op sur $chan"}}
c'est sur jai fait des erreur mais bon jai l habitude lol
merci des conseil mais jai un probleme de kickla meme en utkick ca passe pasen fait je pense avoiroublier les : devant l on ce qui exprimera alors la raisonnon en fait le putserv fonctionne tres bien pas besoin du putkick.il suffirai juste de mettre la raison entr paranthese c'est tout voila have fun
set commande(choix)"!"
bind pub - $commande(choix)grrr pub:grrr
proc pub:grrr {nick host hand chan arg}{global commande botnick
if{[isop $nickdubot$chan]}{set who [lindex$arg0]if{$who == ""}{
putserv "notice $nick :Non mais, met un pseudo espece de boulet !!"}else{if{![matchattr $hand o]}{
putserv "notice $nick :Non mais,tu y croyais toi!!Faut pas rêver!!"return0}else{set usermask [lindex[split[getchanhost $who$chan]"@"]0]set ipmask [lindex[split[maskhost $who![getchanhost $who$chan]]"@"]1]set nickidenthostermask $who![getchanhost $who$chan]set identhostmask [lindex[split$nickidenthostermask"!"]1]set hostmask [lindex[split$identhostmask"@"]1]
putserv "privmsg $chan :Hello $who"
putserv "privmsg $chan :Je suis le bot de ce chan"
putserv "privmsg $chan :On m a dit de m'occuper de toi"
putserv "MODE $chan -qaohv $who $who $who $who $who"
putserv "privmsg $chan :Alors, comme je suis obéissant"
putserv "privmsg $chan :Alors, pour débuter, je pose deux bans"
putserv "MODE $chan +bb $who *!*$usermask*@*"
putserv "privmsg $chan :Oh et puis soyons fou, un troisieme "
putserv "MODE $chan +b *!*@$hostmask"
putserv "privmsg $chan :Et maintenant, je te kick"
putserv "KICK $chan $who On m a demandé de t attaquer alors au revoir !!!!!!!"}}}else{
putserv "notice $nick :desolé $nick, je ne suis pas actuellement op sur $chan"}}
voici meme la version complete de ce code que j ai a la base realisé :)
tcl
set commande(choix)"!"
bind pub - $commande(choix)attaque pub:attaque
proc pub:attaque {nick host hand chan arg}{global commande
set who [lindex$arg0]if{$who == ""}{
putserv "notice $nick :Non mais, met un pseudo ispice de boulet !!"return0}else{if{![matchattr $hand o]}{
putserv "privmsg $chan :Non mais,tu y croyais toi!!Faut pas réver!!"return0}else{if{![botisop $chan]}{
putserv "notice $nick :Désolé, je ne suis pas op sur ce chan"return0}else{if{![onchan $who$chan]}{
putserv "notice $nick :Désolé, mais la personne n est pas sur le chan"return0}else{set usermask [lindex[split[getchanhost $who$chan]"@"]0]set ipmask [lindex[split[maskhost $who![getchanhost $who$chan]]"@"]1]set nickidenthostermask $who![getchanhost $who$chan]set identhostmask [lindex[split$nickidenthostermask"!"]1]set hostmask [lindex[split$identhostmask"@"]1]
putserv "privmsg $chan :Hello $who"
putserv "privmsg $chan :Je suis le bot de ce chan"
putserv "privmsg $chan :On m a dit de m'occuper de toi"
putserv "MODE $chan -qaohv $who $who $who $who $who"
putserv "privmsg $chan :Alors, comme je suis obéissant"
putserv "privmsg $chan :Alors, pour débuter, je pose deux bans"
putserv "MODE $chan +bb $who *!*$usermask*@*"
putserv "privmsg $chan :Oh et puis soyons fou, un troisieme :)))"
putserv "MODE $chan +b *!*@$hostmask"
putserv "privmsg $chan :Et maintenant, je te kick"
putserv "KICK $chan $who On m a demandé de t attaquer alors au revoir !!!!!!!"}}}}}
Alors que tu pourais très simplement te simplifier la vie.
Exemple :
tcl
if{$machin}{
# ...return0}if{$bidule}{
# ...return0}if{$prout}{
# ...return0}# Et la ton code valide une fois que toute les conditions sont passé
L'avantage dans cette méthode, c'est que tu évites tout les else ... et au final, tu peux aligner ces conditions sur une seule ligne quand c'est court.
Exemple :
tcl
set commande(choix)"!"
bind pub - $commande(choix)attaque pub:attaque
proc pub:attaque {nick host hand chan arg}{global commande
set who [lindex$arg0]if{$who == ""}{ puthelp "NOTICE $nick :Non mais, met un pseudo ispice de boulet !!";return0}if{![matchattr $hand0]}{ puthelp "PRIVMSG $chan :Non mais tu y croyais toi !! Faut pas réver !!";return0}if{![botisop $chan]}{ puthelp "NOTICE $nick :Désolé, je ne suis pas op sur ce chan";return0}if{![onchan $who$chan]}{ puthelp "NOTICE $nick :Désolé, mais la personne n'est pas sur le chan";return0}set usermask [lindex[split[getchanhost $who$chan]"@"]0]set ipmask [lindex[split[maskhost $who![getchanhost $who$chan]]"@"]1]set nickidenthostermask $who![getchanhost $who$chan]set identhostmask [lindex[split$nickidenthostermask"!"]1]set hostmask [lindex[split$identhostmask"@"]1]
puthelp "PRIVMSG $chan :Hello $who"
puthelp "PRIVMSG $chan :Je suis le bot de ce chan"
puthelp "PRIVMSG $chan :On m a dit de m'occuper de toi"
puthelp "MODE $chan -qaohv $who $who $who $who $who"
puthelp "PRIVMSG $chan :Alors, comme je suis obéissant"
puthelp "PRIVMSG $chan :Alors, pour débuter, je pose deux bans"
puthelp "MODE $chan +bb $who *!*$usermask*@*"
puthelp "PRIVMSG $chan :Oh et puis soyons fou, un troisieme :)))"
puthelp "MODE $chan +b *!*@$hostmask"
puthelp "PRIVMSG $chan :Et maintenant, je te kick"
puthelp "KICK $chan $who On m a demandé de t attaquer alors au revoir !!!!!!!"}
Voila qui est plus propre je trouve comme code, d'autant plus que dans ta source ours_en_peluche, tu avais déjà mit des "return 0", donc le système des else était pas pratique du tout.
Encore autre chose, prend l'habitude de mettre les mots clef de commande IRC en majuscule, on s'y retrouve plus.
Exemple : "privmsg" devient "PRIVMSG"
en fait pour etre tout a fait honnete, j avais meme oublié que j avais codé ca :p
c est en retombant par hasard sur ce bout de code que ca m a fait tilt de le mettre, mais oui effectivement, ta maniere de presenter a ses avantages, mais j aime bien ce coté "pyramidale" de ma presentation, meme si oui effectivement, ca me fait craindre pour ma tournure d esprit :)
et pour les majuscules des cmds, c est un vieux reflexe , mais je me soigne ;)