Autosajoin en fonction des pseudos et vhost.
#1
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 :Pas de saj pour $ynick en ce moment."
        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 :Pas de saj presents."
        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 :Pas de saj."
       }
       close $newsfile
        unset numsaj
   }
          }
        }
      }
    }
  }
}



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 "-"
ici j'ai modifié le expr en enlevant le - , et j'ai eu cette erreur
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 ?
Répondre Avertir


Messages dans ce sujet
Autosajoin en fonction des pseudos et vhost. - par BlackNight - 18/08/2009, 20:56
RE: Autosajoin en fonction des pseudos et vhost. - par heretoc - 19/08/2009, 12:48
RE: Autosajoin en fonction des pseudos et vhost. - par Smilx3 - 18/12/2009, 17:47
RE: Autosajoin en fonction des pseudos et vhost. - par Smilx3 - 19/12/2009, 12:51
RE: Autosajoin en fonction des pseudos et vhost. - par heretoc - 19/12/2009, 18:01
RE: Autosajoin en fonction des pseudos et vhost. - par heretoc - 04/03/2010, 23:59
RE: Autosajoin en fonction des pseudos et vhost. - par heretoc - 07/04/2010, 23:26

Atteindre :


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