![]() |
Autosajoin en fonction des pseudos et vhost. - Version imprimable +- Communauté francophone sur les Eggdrops (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 : Autosajoin en fonction des pseudos et vhost. (/showthread.php?tid=486) Pages :
1
2
|
Autosajoin en fonction des pseudos et vhost. - BlackNight - 18/08/2009 Je vous explique brièvment le tcl. !addsaj pseudo #salon -> Ajoute un sajoin à pseudo sur #salon !delsaj pseudo #salon -> retire le sajoin de #salon à pseudo. !flushsaj pseudo -> retire tout les saj de pseudo !showsaj pseudo -> montres tout les saj de pseudo. Voila pour l'application. J'ai trouvé un tcl qui semble être fait pour ça. Mais le souci c'est qu'il ne fonctionne absolument pas et me donne des erreurs à tout bout de champ. [tcl] set vhostniv0 { *@NetAdmin.Best-Friend-Chat.fr *@ChanAdmin.Best-Friend-Chat.fr *@ChanOp.Best-Friend-Chat.fr *@Op.Best-Friend-Chat.fr *@AnimPlus.Best-Friend-Chat.fr *@StaffPlus.Best-Friend-Chat.fr *@TechAdmin.Best-Friend-Chat.fr *@IrcOp.Best-Friend-Chat.fr *@global.Best-Friend-Chat.fr *@anim.Best-Friend-Chat.fr } set vhostplus { *@NetAdmin.Best-Friend-Chat.fr *@ChanAdmin.Best-Friend-Chat.fr *@ChanOp.Best-Friend-Chat.fr *@StaffPlus.Best-Friend-Chat.fr *@TechAdmin.Best-Friend-Chat.fr *@IrcOp.Best-Friend-Chat.fr *@global.Best-Friend-Chat.fr } set salonstaff { "#Spam" "#casino" "#WyLo-Le-pReCiEuX" "#AER354sdfgERFG574gGD" "#KamiLLia" "#1000bornes" "#quizz" "#Welcome" "#Uno" "#sexe" "#scrabble" "#Radio" "#maghreb" "#Aide" "#Staff+" "#plaintes" "#bureau" "#Services" "#staff" "#accueil" } bind pub *|* !showsaj show_saj bind pub *|* !delsajall flush_saj bind pub *|* !addsaj add_saj bind join * * autosaj_pseudo proc autosaj_pseudo { nick host chan text } { global vhostniv0 npct foreach vhost $vhostniv0 { if {[string match -nocase $vhost $host]} { set npct [lindex $text 0] set ynick $nick set thereis [file exists [file join ./ saj_$ynick.txt]] if {$thereis == 0} { return 1 } set nbrsaj [lindex [exec wc -l saj_$ynick.txt] 0] set newsfile [open "| tail -n $npct saj_$ynick.txt" "r+"] if {[eof $newsfile]} { close $newsfile } else { set yes 0 set nbrsaj [lindex [exec wc -l saj_$ynick.txt] 0] if {[llength $text] == 0 } { set numsaj 0 } else { set numsaj [expr {$nbrsaj - $npct}] } while {[eof $newsfile] == 0} { set line [gets $newsfile] incr numsaj set delimn [string last "(+++" $line] set delimt [string last "(+-+" $line] set msg [string range $line 2 [expr {$delimn} - 2]] set stlen [string length $line] set adder [string range $line [expr {$delimn} + 4] [expr {$delimt} - 3]] set adtim [string range $line [expr {$delimt} + 4] [expr {$stlen} - 2]] if { $msg != "" } { putquick "SAJOIN $ynick $msg" } set yes 1 } close $newsfile unset numsaj } } } } proc flush_saj { nick uhost hand chan text } { global salonstaff vhostplus npct set ynick [lindex $text 0] foreach salonst $salonstaff { if {[string match -nocase $salonst $chan]} { foreach vhost $vhostplus { if {[string match -nocase $vhost $uhost]} { putserv "NOTICE $nick :Suppression de tous les saj de $ynick" eval "exec rm -f ./saj_$ynick.txt" return 1 } } } } } proc add_saj { nick uhost hand chan text } { global salonstaff vhostplus npct foreach salonst $salonstaff { if {[string match -nocase $salonst $chan]} { foreach vhost $vhostplus { if {[string match -nocase $vhost $uhost]} { if {$text == ""} { putserv "NOTICE $nick :\00312- Syntax !addsaj pseudo #salon -" return 0 } set ynick [lindex $text 0] set msg [lindex $text 1] set thereis [file exists [file join ./ saj_$ynick.txt]] set cmp [expr {$thereis} == 1] if {$cmp} { set newsfile [open [file join ./ saj_$ynick.txt] "a+"] } else { set newsfile [open [file join ./ saj_$ynick.txt] "w+"] } puts $newsfile "+ $msg (+++) (+-+[strftime "%H:%M %d.%m.%Y"])" putserv "NOTICE $nick :\00312- Le saj à été ajouté -" close $newsfile set newstamp [strftime "%Y%m%d%H%M"] return 1 } } } } } proc show_saj { nick uhost hand chan text } { global salonstaff vhostplus npct foreach nickok $vhostplus { if {[string match -nocase $nickok $uhost]} { foreach salonst $salonstaff { if {[string match -nocase $salonst $chan]} { if {[lindex $text 0]!=""} { set npct [lindex $text 0] set ynick [lindex $text 0] set thereis [file exists [file join ./ saj_$ynick.txt]] if {$thereis == 0} { putserv "NOTICE $nick ![]() return 1 } set nbrsaj [lindex [exec wc -l saj_$ynick.txt] 0] set newsfile [open "| tail -n $npct saj_$ynick.txt" "r+"] if {[eof $newsfile]} { putserv "NOTICE $nick ![]() close $newsfile } else { set yes 0 set nbrsaj [lindex [exec wc -l saj_$ynick.txt] 0] if {[llength $text] == 0 } { set numsaj 0 } else { set numsaj [expr {$nbrsaj - $npct}] } while {[eof $newsfile] == 0} { set line [gets $newsfile] incr numsaj set delimn [string last "(+++" $line] set delimt [string last "(+-+" $line] set msg [string range $line 2 [expr {$delimn} - 2]] set stlen [string length $line] set adder [string range $line [expr {$delimn} + 4] [expr {$delimt} - 3]] set adtim [string range $line [expr {$delimt} + 4] [expr {$stlen} - 2]] if { $msg != "" } { putquick "NOTICE $nick :-\00305 $numsaj\003 - (\0033 $adtim \017): \00312$msg (\0034$adder\017)" } set yes 1 } if { $yes==0 } { putserv "NOTICE $nick ![]() } close $newsfile unset numsaj } } } } } } } [/tcl] Voici le genre d'erreur que je rencontre: Code : <Atlantis> [15:29] Tcl error [show_saj]: can't use non-numeric string as operand of "-" Code : <Atlantis> [15:31] Tcl error [show_saj]: syntax error in expression "$nbrsaj $npct": extra tokens at end of expression j'ai essayé de remplacer par un + Code : <Atlantis> [15:33] Tcl error [show_saj]: can't use non-numeric string as operand of "+" j'ai ensuite rencontré un autre souci: Code : <Atlantis> [15:41] Tcl error [autosaj_pseudo]: can't read "npct": no such variable j'ai donc essayer d'apporter certaines modifications, ayant vu "npct" set vers la fin du code, en le mettant dans le global ... Bref, ce tcl est sensé faire ce que je voulais, mais au final il ne fonctionne pas du tout. J'ai eu l'envie de le recoder, mais ca n'est pas de mon niveau malheureusement. Pourriez vous m'aider s'il vous plait ? RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 18/08/2009 Heretoc, je vais essayer de faire ça à partir d'un de tes scripts si cela ne te derange pas. juste si tu pouvais me dire à quoi corresponde les binds, j'ai que ce bout de tcl moi. script supprimé par un modérateur, vous ne devez pas publier de code source ne vous appartenant pas sans autorisation de l'auteur, sauf si la license d'utilisation fournie avec inclut cette autorisation ps: merci à Alsyx pour son aide in irc. RE: Autosajoin en fonction des pseudos et vhost. - heretoc - 19/08/2009 Oui sa me derange je tes pas donner sa ... et je voit pas pourquoi tu l'ajoute comme sa ... RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 19/08/2009 Désolé encore, je comptait l'enlever des que j'ai eu tes messages, mais on s'en est deja occupé. Toutes mes excuses. RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 22/08/2009 bon, je me lance dans le recodage d'une chose qu'on m'a transmise. Je vous en ferai part si je m'en sort. A moins que l'un d'entre vous en connaisse un qui FONCTIONNE, de ces système d'autosaj sur les pseudos. enfin voila ... J'aurai surement fini dans 2 ans ... RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 23/08/2009 Bon, après des heures de casse tête, et de travail, et surtout quelques poignées de cheveux en moins, j'ai réussi a faire ça: [tcl]################################################# ######### AUTOSAJ TCL PAR BLACKNIGHT ############ ################################################# # Les binds bind pub - !addsaj add_saj bind pub - !delsaj del_saj bind pub - !listsaj list_saj bind join - "*" auto_saj # configuration NE PAS EDITER set sajdb "sajoin.db" set sajuse "" # Les Procs proc add_saj {nick host hand chan text} { global vhostkill sajdb sajuse foreach vhostaddautosaj $vhostkill { if [string match -nocase $vhostaddautosaj $host] { set 3 [lindex $text 0] set 4 [lindex $text 1] set sajt [del_sajuse $nick] set sajuse "[lrange $sajuse 0 end] $3@$4" set f [open "$sajdb" "a"] puts $f "$sajuse" close $f putquick "PRIVMSG $chan : \002\00303OK.\002\00312 AutoJoin vers $4 ajouté pour $3.\003" } } } proc del_saj {nick host hand chan text} { global vhostkill sajdb sajuse foreach vhostdelautosaj $vhostkill { if [string match -nocase $vhostdelautosaj $host] { set sajuse [del_sajuse [lindex $text 0]] set f [open "$sajdb" "a"] puts $f "$sajuse" close $f putquick "PRIVMSG $chan : \002\00303OK.\002\00312 [lindex $text 0] n'a plus d'AutoJoin.\003" } } } proc list_saj {nick host hand chan text} { global vhostkill sajdb sajuse foreach vhostshowautosaj $vhostkill { if [string match -nocase $vhostshowautosaj $host] { set saju [llength $sajuse] set listsaj "" set i "0" putquick "PRIVMSG $chan :\002\00306L\002\00312iste \002D\002es \002\00304A\002uto-\002J\002oin \:" while { $i <= $saju } { set saj [lindex $sajuse $i] set saj [split $saj "@"] set sajn [lindex $saj 0] set sajc [lindex $saj 1] if { $sajn != "" } { set listsaj "[lrange $listsaj 0 end] \00304$sajn \00312(\00303$sajc\00312), " } if { [llength $listsaj] >= "6" } { putquick "PRIVMSG $chan :$listsaj" set listsaj "" } incr i } if { $listsaj != "" } { putquick "PRIVMSG $chan :$listsaj" set listsaj "" } putquick "PRIVMSG $chan :\002\00306F\002\00312in \002D\002e \002L\002a \002L\002iste." return } } } proc del_sajuse { nick } { global sajuse set saju [llength $sajuse] set listsaj "" set sajx "0" set i "0" while { $i <= $saju } { set sajc [lindex $sajuse $i] set sajt [split $sajc "@"] set sajy [lindex $sajt 0] if {![string match -nocase $nick $sajy]} { set listsaj "[lrange $listsaj 0 end] $sajc" } else { set sajx 1 } incr i } return $listsaj } proc auto_saj {nick host hand chan} { global sajuse set saju [llength $sajuse] set listsaj "" set i "0" while { $i <= $saju } { set saj [lindex $sajuse $i] set saj [split $saj "@"] set sajn [lindex $saj 0] set sajc [lindex $saj 1] if {[string match -nocase $nick $sajn]} { set ::timernick $nick set ::timerchan $sajc utimer 5 { putquick "SAJOIN $::timernick $::timerchan" set ::timernick "" set ::timerchan "" } } incr i } return }[/tcl] a savoir "sajoin.db" doit être créer a la racine de l'eggdrop. donc une fois le tcl chargé, tout fonctionne impeccable. Mon Salon Irc a écrit :-12:59:29- ‹~BlackNight14› !addsaj BlackNight #salon1,#salon2,#salon3 le seul souci, c'est que si j'ai le malheur de redémarrer l'eggdrop ou de le rehash, il ne prends plus en compte les sajoin, il ne saj plus, il ne les liste plus non plus, enfin, plus rien ne va. Vous auriez une solution s'il vous plait ? là je sèche totalement. RE: Autosajoin en fonction des pseudos et vhost. - Marc - 23/08/2009 Alors pour un débutant, je trouve que tu code bien BlackNight ! Mes félicitations. ![]() RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 23/08/2009 bah pour ça là, j'ai eu âs mal d'aide, j'ai récupérer des morceaux de codes qui faisaient les choses que j'avais besoin, et j'ai essayer de les modifier a ma sauce pour comprendre un peu. Mais je ne l'ai pas codé entièrement moi même c'est vrai. (ps: j'ai l'autorisation de l'auteur pour les quelques lignes sur lesquelles je me suis basé) RE: Autosajoin en fonction des pseudos et vhost. - BlackNight - 23/08/2009 Bon, j'ai fini par trouver la solution en faisant une initialisation des variables. C'est un code que je vous donnerai sur demande si vous le désirez. Je laisse celui posté plus haut public, il est fonctionel, avec des bugs certes. RE: Autosajoin en fonction des pseudos et vhost. - MenzAgitat - 23/08/2009 Tu devrais envisager d'écrire tes listes dans un fichier à chaque modification, et de relire ce fichier au démarrage du script pour les recharger. RE: Autosajoin en fonction des pseudos et vhost. - Smilx3 - 18/12/2009 TON CODE MARCHE PAS. RE: Autosajoin en fonction des pseudos et vhost. - fedora - 18/12/2009 Smilx3 a écrit :TON CODE MARCHE PAS. peut tu nous indiquer si tu as des erreurs en party line ect .. ? cordialement RE: Autosajoin en fonction des pseudos et vhost. - Smilx3 - 19/12/2009 Y'en a pas :/ RE: Autosajoin en fonction des pseudos et vhost. - heretoc - 19/12/2009 Ton bot est ircop avec possibilité de sajoin les gens ? RE: Autosajoin en fonction des pseudos et vhost. - dimoala - 10/01/2010 Bonjour, Comment mettre le eggdrop en ircop comme le dit " heteroc " s'il vous plait ? merci |