Tout est dans le titre :x
Je sais qu'il y en a deja pas mal, mais je pense que celui-ci mérite d'être publié :)
Possibilitée "infinie" de choix
Stats de fin :
- meilleurs scores (il marque les égalités)
- plus bas (égalités également)
- ne marque pas les autres, pour ne pas flood, mais pourrait le faire si vous me demandez de changer le code
Si vous voulez en rajouter, contactez moi ...
Source / Exemple :
alias sondage {
var %t = 0
if ($hget(Sondage,Total)) var %t = $hget(Sondage,Total)
inc %t
if (!$hget(Sondage)) hmake Sondage 10
hmake Sondage $+ %t 10
if (!$hget(Sondage,Total)) hadd Sondage Total 0
hinc Sondage Total
hadd Sondage Actuel %t
hadd $+(Sondage,$hget(Sondage,Actuel)) Question $?="Quelle est la question du sondage ?"
if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Question)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd $+(Sondage,$hget(Sondage,Actuel)) Temps $?="Temps pour voter, en secondes ? Supérieur à 10sec"
if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) !isnum) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) < 10) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
var %t = $?="Combien de choix ?"
if ((%t <= 0) || (%t !isnum)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd $+(Sondage,$hget(Sondage,Actuel)) Choix %t
hadd $+(Sondage,$hget(Sondage,Actuel)) Chan $?="Sur quel salon faire le sondage ?"
if ($left($hget($+(Sondage,$hget(Sondage,Actuel)),Chan),1) != $chr(35)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($hget(Sondage,$hget($+(Sondage,$hget(Sondage,Actuel)),Chan))) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il y a déjà un sondage sur ce salon ! 12] | hdec Sondage Total | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd Sondage $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) $hget(Sondage,Actuel)
if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($me !ison $hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il faut être sur le chan ! 12] | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
var %t = 1
while %t <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
while (!$hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%t))) {
hadd $+(Sondage,$hget(Sondage,Actuel)) $+(Question,%t) $?="Choix %t ?"
}
inc %t
}
if ($?!="Voulez-répondre vous même au sondage ?") {
var %t = $?="Entre le numéro correspondant à votre choix ?"
if (%t isnum $+(1-,$hget($+(Sondage,$hget(Sondage,Actuel)),Choix))) {
hinc $+(Sondage,$hget(Sondage,Actuel)) %t
}
}
msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Un nouveau sondage est lancé ! La question est : $hget($+(Sondage,$hget(Sondage,Actuel)),Question) 12]
var %o = 1
var %t = 0
while %o <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
inc %t 4.5
if ($hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1)))) { .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12::0 Choix $+($calc(%o +1),) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1))) 12] | inc %o }
else .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12]
inc %o
}
inc %t 4
.timersondage.annonce -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Vous pouvez voter ! Vous avez $duration($hget($+(Sondage,$hget(Sondage,Actuel)),Temps)) pour répondre ! Tapez !sondage "X" 12]
.timersondage.activer -o 1 %t hadd $+(Sondage,$hget(Sondage,Actuel)) Status ON
.timersondage.lancer -o 1 %t .timersondage.fin $+ $hget(Sondage,Actuel) -o 1 $hget($+(Sondage,$hget(Sondage,Actuel)),Temps) sondage.fin $hget(Sondage,Actuel)
}
ON *:TEXT:!sondage *:#:{
if (!$hget(Sondage,$chan)) return
if ($hget($+(Sondage,$hget(Sondage,$chan)),Status) != ON) return
if ($2 !isnum) return
if ($hmatch($+(Sondage,$hget(Sondage,$chan)),$address($nick,2))) return
if (!$hget($+(Sondage,$hget(Sondage,$chan)),$+(Question,$2))) return
if (!$hget($+(Sondage,$hget(Sondage,$chan)),Total)) hadd Sondage $+(Sondage,$hget(Sondage,$chan)) 0
if (!$hget($+(Sondage,$hget(Sondage,$chan)),$2)) hadd $+(Sondage,$hget(Sondage,$chan)) $2 0
hinc $+(Sondage,$hget(Sondage,$chan)) $2
hinc $+(Sondage,$hget(Sondage,$chan)) Total
hadd $+(Sondage,$hget(Sondage,$chan)) $address($nick,2) 1
echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Le vote a compté ! La proposition $2 a désormais $hget($+(Sondage,$hget(Sondage,$chan)),$2) voix 12]
}
alias sondage.fin {
if (!$1) return
hadd $+(Sondage,$1) Status OFF
msg $hget($+(Sondage,$1),Chan) 12,1[ 0Le vote est fini ! Il y a eu $iif($hget($+(Sondage,$1),Total),$ifmatch,0) $+(votes,$iif($hget($+(Sondage,$1),Total),$+($chr(44),$chr(32),merci) à tous,$+($chr(44),$chr(32),pas) terrible ...)) 12]
if (!$hget($+(Sondage,$1),Total)) return
unset %l %l2
var %t = 1
var %o = 0
while %t <= $hget($+(Sondage,$1),Choix) {
var %l = %l $+(%t,-,$iif($hget($+(Sondage,$1),%t),$ifmatch,0))
var %l2 = %l2 $+($iif($hget($+(Sondage,$1),%t),$ifmatch,0),-,%t)
inc %t
}
if (%l) {
var %l2 = $sorttok(%l2,32)
var %l = $sorttok(%l,32)
var %m = $gettok($gettok(%l2,-1,32),1,45)
var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
unset %q
var %k = 1
while %k <= %s {
var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
inc %k
}
.timerresultat1 -o 1 1 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) qui $+(l'emporte,$iif(%s > 1,ent)) avec %m voix : $right(%q,-1) 12]
var %m = $gettok($gettok(%l2,1,32),1,45)
var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
unset %q
var %k = 1
while %k <= %s {
var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
inc %k
}
.timerresultat2 -o 1 2 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) ayant receuilli le moins de voix $+($chr(40),%m,$chr(41)) : $right(%q,-1) 12]
}
hdel Sondage $hget($+(Sondage,$1),Chan)
hfree $+(Sondage,$1)
}
Conclusion :
Copier ce code dans votre remote, et taper /sondage
pour voter, taper !sondage "X", possible dès l'annonce du début du vote.
Bonne année en retard :p
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.