un welcome.
#1
Bonjour,

Voila sur mon server quelqu'un m'avait demandé de lui faire un welcome en tcl.

Bon jusque la pas de soucis mais que le welcome dise un message différent à chaque join.

Donc en gros il prend au hasard une phrase mise dans le tcl.
J'ai fait ceci par un set ... et voila.
Le code et activable sur salon donc pour activé : !won pour désactivé : !woff.

Voici le code :

tcl
setudef flag WS
 
set ::phrases {
  "Bonjour bienvenue sur le salon !"
  "Hello tu es le bienvenue pose toi tranquil"
  "salut tu es sur le salon alors soit la bienvenue à toi !"
}
 
bind join - "*" wj
proc wj {nick uhost handle chan} {
  if {[channel get $chan WS]==0} { return; }
    if {$nick == $::botnick } { return 0 }
  set ::phrase [lindex $::phrases [rand [llength $::phrases]]]
  putserv "PRIVMSG $chan :\0034 $::phrase\0031"
}
 
bind pub o "!won" won
proc won { nick host hand chan arg } {
		set arg [gbfilter $arg]
if {[channel get $chan WS] == 0} {
  channel set $chan +WS
  putquick "PRIVMSG $chan :Welcome Activé sur $chan !" 
} else {
putquick "PRIVMSG $chan :Welcome déjà Activé sur $chan !"
   }
}
 
bind pub o "!woff" woff
proc woff { nick host hand chan arg } {
		set arg [gbfilter $arg]
if {[channel get $chan WS] != 0} {
  channel set $chan -WS
  putquick "PRIVMSG $chan :Welcome Désactivé sur $chan !" 
} else {
putquick "PRIVMSG $chan :Welcome déjà Désactivé sur $chan !"
   }
}
 
proc gbfilter {x {y ""} } {
	for {set i 0} {$i < [string length $x]} {incr i} {
		switch -- [string index $x $i] {
			"\"" {append y "\\\""}
			"\\" {append y "\\\\"}
			"\[" {append y "\\\["}
			"\]" {append y "\\\]"}
			"\} " {append y "\\\} "}
			"\{" {append y "\\\{"}
			default {append y [string index $x $i]}
		}
	}
	return $y
}


Répondre Avertir


Messages dans ce sujet
un welcome. - par aliasangelius - 23/06/2011, 17:51
RE: un welcome. - par djkenny - 23/06/2011, 18:29
RE: un welcome. - par aliasangelius - 23/06/2011, 19:19
RE: un welcome. - par fedora - 23/06/2011, 19:23
RE: un welcome. - par aliasangelius - 23/06/2011, 19:50
RE: un welcome. - par djkenny - 23/06/2011, 20:33
RE: un welcome. - par aliasangelius - 23/06/2011, 20:38
RE: un welcome. - par CrazyCat - 23/06/2011, 22:13

Atteindre :


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