All pastes #562604 Raw Edit

Something

public text v1 · immutable
·published 2007-06-12 21:02 UTC
rendered paste body
; ==============================================================================
; - Versos.lug - Permite realizar votaciones para versos
; -----------------------––––––––––––-----––––––––––––––––––––––––––––––––––––––
;  Autor  : Archville
;  Email  : archville@gmail.com
;  URL    : archville.gulo.org
; -----------------------––––––––––––-----––––––––––––––––––––––––––––––––––––––

on 1000:text:!votacion*:#: { 
  if (!$2) { .msg $chan Debes especificar que poema votar. | halt }
  if ( $read(system\txt\versos.txt, w, * $+ $2 ) != $null ) { .msg $chan Ya se ha votado antes ese poema o hay uno con un nombre demasiado similar. | halt }
  else { 
    set %versos1 $2- 
    set %versos2 $chan 
    set %versos3 5 
    set %versos4 1
    .msg $chan Empieza la votación para: $2- 
    .msg $chan Recuerda que para votar basta con escribir un número del 5 al 8 en el canal.
    inicia.versos 
  }
}

on 1000:text:!stop:#: { detiene.versos }

on 1000:text:!recuento:#: {
  .msg $chan La lista de los poemas y sus resultados es la siguiente:
  var %a 1
  var %b 1
  while ( %a <= $lines(system\txt\versos.txt) ) {
    timer 1 %b .msg $chan %a - Título: $gettok($read(system\txt\versos.txt,%a),3-,32) - Puntos: $calc($gettok($read(system\txt\versos.txt,%a),1,32) / $gettok($read(system\txt\versos.txt,%a),2,32)) - Votos recibidos: $calc($gettok($read(system\txt\versos.txt,%a),2,32) - 1)
    inc %b 4
    inc %a
  }
  timer 1 %b .msg $chan Fin de la lista.
}

alias inicia.versos {
  enable #versos
  timerv1 1 60 detiene.versos
  timerv2 1 50 .msg %versos2 Quedan 10 segundos para concluír la votación
  timerv3 1 30 .msg %versos2 Quedan 30 segundos para concluír la votación
}

alias detiene.versos {
  disable #versos
  timerv1 off
  timerv2 off
  timerv3 off
  write system\txt\versos.txt %versos3 %versos4 %versos1
  .msg %versos2 Ha terminado la votación para: " $+ %versos1 $+ "
  .msg %versos2 El resultado obtenido es de: $calc( %versos3 / %versos4 ) tras $calc(%versos4 - 1) votos recibidos.
  .msg %versos2 Han votado: %versos5
  unset %versos1
  unset %versos2
  unset %versos3
  unset %versos4
  unset %versos5
  unset %whoisnick
}

#versos off


on 1:text:*:%versos2: {
  if ( $1 <= 8 ) && ( $1 > 4 ) {
    if ( $nick isin %whoisnick ) { notice $nick Lo siento $nick ya has votado. | halt }
    set %versos5 %versos5 $+ $chr(160) $+ $nick $+ $chr(160)
    inc %versos3 $1
    inc %versos4 1
    notice $nick Gracias por tu voto, $nick $+ .
    aline @consola < $+ $date $+ / $+ $time $+ > [VERSOS] Recibido voto de $nick
    set %whoisnick %whoisnick $+ $chr(160) $+ $nick
  }
}


#versos end


; ==============================================================================