Communauté Eggdrop
Optimiser - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Scripts TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=4)
+--- Sujet : Optimiser (/showthread.php?tid=952)



Optimiser - fedora - 12/05/2011

bonjour,

je souhaiterais savoir si il est possible que vous m'aidiez à optimisé mon code.
le code fonctionne mais je sais pas pourquoi j'ai quelque doute sur la manière que je l'ai codé,est m'en remet a vous pour l'amélioré svp.

TCL
namespace eval OpbOt {
    variable version  3.0
       variable Nom  DnS			   
          variable pass  "PASS" 
            variable chekbOt 10
    }
 
proc OpbOt::Join {nick host hand chan args} {
	if {[channel get $chan SalonOp]} { 
	    putlog "\002\00303\[Ok\]\002\00314 Je me Op sur $chan"
		utimer $OpbOt::chekbOt [list OpbOt::JoinMess $nick $chan]
		} else {
		    if {![channel get $chan SalonOp]} { 
			    putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
        return 0
       }
	}
}



Cordialement


RE: Optimiser - MenzAgitat - 12/05/2011

Tu t'es compliqué la vie au niveau de la condition dans la proc Join et ton indentation est un peu aléatoire. De plus, si le return 0 a une quelconque utilité pour vérifier le résultat d'exécution de la proc Join, peut-être un return 1 serait-il utile aussi.
TCL
namespace eval OpbOt {
	variable version 3.0
	variable Nom "DnS"
	variable pass "PASS"
	variable chekbOt 10
}
 
proc OpbOt::Join {nick host hand chan args} {
	if { [channel get $chan SalonOp] } {
		putlog "\002\00303\[Ok\]\002\00314 Je me Op sur $chan"
		utimer $OpbOt::chekbOt [list OpbOt::JoinMess $nick $chan]
		return 1
	} else {
		putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
		return 0
	}
}





RE: Optimiser - fedora - 12/05/2011

Ha d'accord Smile merci MenzAgitat pour cette explication.

j'aurais une autre réponse,en fait je refait une autre version de auto op Niubot est je voudrais savoir ce qui est le plus rapide pour la détection du bot "Niubot' j'avais pensé au départ a une regex:

Citation :[regexp -- {^[Niubot]\[\\d]\{2\}\$" $nick]}

mais apres quelque conseil on ma dit de faire comme ceci

TCL
set Pseudo [chanlist $chan]
    set X [lsearch -nocase $Pseudo Niubot*]
        set robot [string tolower [lindex $Pseudo $X]]





RE: Optimiser - CrazyCat - 12/05/2011

Plus rapide:
TCL
set Pseudo [chanlist $chan]
set robot [string tolower [lsearch -nocase -inline $Pseudo Niubot*]]





RE: Optimiser - fedora - 12/05/2011

Merci CrazyCat Smile


RE: Optimiser - CrazyCat - 12/05/2011

Par contre, je pense qu'il faut ajouter un petit test (qui n'était pas présent dans ton code précédent):
TCL
if { $robot eq "" } { return 0; }





RE: Optimiser - fedora - 12/05/2011

voici mon code qui je pense est terminé.donc si vous avais des conseils et améliorations a me faire je suis preneur. merci de votre aide.

TCL
#
# Pour Activer l'auto Op Niubot Tapez ".chanset #salon +SalonOp" en P.L
#
namespace eval OpbOt {
    variable version  3.0
       variable auteur  DnS	
    	#Ici Mettre le Mot de passe    
          variable Npass  "MDP" 
            variable chekbOt 10
        }
 
        proc OpbOt::Join {nick host hand chan args} {
           if { [channel get $chan SalonOp] } {
                putlog "\002\00303\[Ok\]\002\00314 Je me Op sur $chan"
                    utimer $OpbOt::chekbOt [list OpbOt::JoinMess $nick $chan]
        } else {
                putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
                return 0
            }
        }	
 
		proc OpbOt::JoinMess {nick chan} {
           variable pass
               set nicks [chanlist $chan]
                   set bot [string tolower [lsearch -nocase -inline $nicks Niubot*]]
                    putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"
                return 0
        }
 
		proc OpbOt::ReOp {nick host hand chan args} {
           variable pass
               set nicks [chanlist $chan]
                   set bot [string tolower [lsearch -nocase -inline $nicks Niubot*]]
				   if {[channel get $chan SalonOp]} {
				    putlog "\002\00303\[Ok\]\002\00314 Je me ReOp sur $chan"
                    putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"
        } else {
                putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
                return 0
            }
        }
 
 
		proc OpbOt::VervifbOt {min hour args} {
           variable pass
                 foreach chan [channels] {
                   set nicks [chanlist $chan]
                         set bot [string tolower [lsearch -nocase -inline $nicks Niubot*]]
                                if {[channel get $chan SalonOp]} {
								 putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"
								 return 0
                            }
						  }
					}	
 
bind join - * OpbOt::Join
bind mode - *-o* OpbOt::ReOp
bind time -|- {* * * * *} OpbOt::VervifbOt
setudef flag SalonOp
 
putlog "\002$OpbOt::version by $OpbOt::auteur Chargé.\002"





RE: Optimiser - CrazyCat - 12/05/2011

Pour ma part, j'aurais fait une petite proc whoisNiubot pour faire plus propre:
TCL
#
# Pour activer l'auto Op Niubot Tapez ".chanset #salon +SalonOp" en P.L
#
namespace eval OpbOt {
	variable version "3.0"
	variable auteur "DnS"
	#Ici Mettre le Mot de passe    
    variable Npass "MDP"
	variable chekbOt 10
}
 
proc OpbOt::Join {nick host hand chan args} {
	if { [channel get $chan SalonOp] } {
		putlog "\002\00303\[Ok\]\002\00314 Je me Op sur $chan"
		utimer $OpbOt::chekbOt [list OpbOt::JoinMess $nick $chan]
	} else {
		putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
		return 0
	}
}   
 
proc OpbOt::JoinMess {nick chan} {
	variable pass
	set bot ::OpbOt::whoisNiubot $chan
	if {$bot ne "" } { putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"; }
	return 0
}
 
proc OpbOt::ReOp {nick host hand chan args} {
	variable pass
	set bot ::OpbOt::whoisNiubot $chan
	if {($bot ne "") && [channel get $chan SalonOp]} {
		putlog "\002\00303\[Ok\]\002\00314 Je me ReOp sur $chan"
		putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"
	} else {
		putlog "\002\00304\[Refuser\]\002\00314 Je ne suis pas activé sur $chan"
		return 0
	}
}
 
proc OpbOt::VervifbOt {min hour args} {
	variable pass
	foreach chan [channels] {
		if {[channel get $chan SalonOp]} {
			set bot ::OpbOt::whoisNiubot $chan
			if {(bot ne ""} {
				putquick "PRIVMSG $bot :op $OpbOt::Npass $chan"
				return 0
			}
		}
	}
}   
 
proc OpbOt:whoisNiubot {chan} {
	set nicks [chanlist $chan]
	return [string tolower [lsearch -nocase -inline $nicks Niubot*]]
}
 
bind join - * OpbOt::Join
bind mode - *-o* OpbOt::ReOp
bind time -|- {* * * * *} OpbOt::VervifbOt
setudef flag SalonOp
 
putlog "\002$OpbOt::version by $OpbOt::auteur Chargé.\002"


En plus, j'ai un peu modifié OpbOt::VervifbOt pour ne pas faire appeler OpbOt:whoisNiubot si le canal n'a pas le flag SalonOp


RE: Optimiser - fedora - 12/05/2011

Ha oui c'est vrai que cela est beaucoup plus propre Smile merci


RE: Optimiser - CrazyCat - 12/05/2011

fedora a écrit :whois niubot pour vérifié si le bot est bien ircop ?
Non.
Par contre, si Niubot a le @ sur les canaux, tu dois pouvoir optimiser en ne listant que les users qui ont ce statut.


RE: Optimiser - fedora - 12/05/2011

j'ai tester te version CrazyCat sa me retourne une erreur au niveau de la proc OpbOt::VervifbOt

TCL
wrong # args: should be "set varName ?newValue?"
Tcl error [OpbOt::VervifbOt]: wrong # args: should be "set varName ?newValue?"



TCL
LOL: .set errorInfo
LOL: [17:23:22] #LOL# set errorInfo
Currently: wrong # args: should be "set varName ?newValue?"
Currently: while executing
 "set bot ::OpbOt::whoisNiubot $chan"
Currently: (procedure "OpbOt::VervifbOt" line 5)
Currently: invoked from within
Currently: "OpbOt::VervifbOt $_time1 $_time2 $_time3 $_time4 $_time5"



j'ai corrigé aussi
TCL
if {(bot ne ""} {


par
TCL
if {$bot ne ""} {





RE: Optimiser - CrazyCat - 12/05/2011

Oui, j'ai loupé un truc (à travailler trop vite et pas tester):
TCL
set bot ::OpbOt::whoisNiubot $chan


doit devenir:
TCL
set bot [::OpbOt::whoisNiubot $chan]





RE: Optimiser - fedora - 12/05/2011

toujours la même erreur après le restart
TCL
Tcl error in script for 'timer22':
invalid command name "::OpbOt::whoisNiubot"
Tcl error [OpbOt::VervifbOt]: invalid command name "::OpbOt::whoisNiubot"



TCL
#LOL# set errorInfo
Currently: invalid command name "::OpbOt::whoisNiubot"
Currently: while executing
Currently: "::OpbOt::whoisNiubot $chan"
Currently: (procedure "OpbOt::VervifbOt" line 5)
Currently: invoked from within
Currently: "OpbOt::VervifbOt $_time1 $_time2 $_time3 $_time4 $_time5"
Tcl error [OpbOt::VervifbOt]: invalid command name "::OpbOt::whoisNiubot"





RE: Optimiser - fedora - 12/05/2011

autant pour moi CrazyCat
j'ai corrigé la procédure

TCL
proc OpbOt:whoisNiubot {chan} {


par
TCL
proc OpbOt::whoisNiubot {chan} {



merci de ton aide Smile reste a tout mettre au propre et le UP pour le téléchargement