sockets football

By coco on Dec 08, 2011

is a code to get information on the classification of marca.es, results next day ... if someone can check and see if it works I'd appreciate it PD: Pardon my English and used a translator xD

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;Addon Campionato_Liga 1.2
;;;;;;;;;;;;;Recibir informacion completa de la liga española en su canal
;;;;;;;;;;;;;version 1.2
;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;Para cagar:
;;;;;;;;;;;;;   1. Copiar el archivo CampionatoLiga_1.2.mrc en el directorio principal del  mirc
;;;;;;;;;;;;;   2. Escribir /load -rs CampionatoLiga_1.2.mrc
;;;;;;;;;;;;;   3. Si lo habeis hecho correctamente aparecera el mensaje de que esta cargado correctamente
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;Mensaje Cargado Correctamente
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on *:LOAD: {
  echo -a Addon CampionatoLiga.mrc 1.2 
  echo -a Ha cargado bien el archivo CampionatoLiga_1.2.mrc
  echo -a Comandos disponibles:
  echo -a !clasifica primera - Para recibir la clasificacion de la liga de primera
  echo -a !clasifica segunda - Para recibir la clasificacion de la liga de segunda
  echo -a !marcador primera - Para recibir el marcador de la liga de primera
  echo -a !marcador segunda - Para recibir el marcador de la liga de segunda
  echo -a !resultado primera - Para recibir los resultados de primera
  echo -a !resultado segunda - Para recibir los resultados de segunda
  echo -a !proxima_jornada primera - Para recibir la proxima jornada de primera
  echo -a !proxima_jornada segunda - Para recibir la proxima jornada de segunda
  echo -a Espero disfruten del addon by Amsterdam
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;code pulido socket
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias -l html {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;socket clasifica primera
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On *:Sockopen:clasifica:{
  if ($sockerr > 0) { errore_clasifica | return }
  sockwrite -n $sockname GET /estadisticas/futbol/primera/clasificacion.html=1 HTTP/1.1
  sockwrite -n $sockname Host: www.marca.com 80
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname $crlf
} 

on *:Sockread:clasifica: { 
  if ($sockerr > 0) { errore_clasifica | return }
  sockread %clasifica
  if (*<TABLE> width="500" border=0 align=center cellPadding=4* iswm %clasifica) { set %bool_clasifica 1 | msg %chan_clasifica 10Clasificacion Provisional  $upper(%clasifica.liga)  Liga BBVA - Primera Division - MARCA.com - Temporada 2011-12 -  CLASIFICACION  }
  elseif ((*</TABLE>* iswm %clasifica) && (%bool_clasifica == 1)) { set %bool_clasifica 0 | sockclose clasifica }
  if (%bool_clasifica == 1) {
    if (($len($remove($html(%clasifica),TOTALES,EN CASA,FUERA)) >= 3) && ($html(%clasifica) !isnum)) {
      set %clasifica_mensaje  $+ $remove($html(%clasifica),TOTALES,EN CASA,FUERA) $+ 
      set %bool_clasifica_punti 1
    }
    elseif (($len($html(%clasifica)) >= 1) && ($html(%clasifica) isnum) && ($len($html(%clasifica)) <= 3)) {
      if (%bool_clasifica_punti == 1) {
        msg %chan_clasifica %clasifica_mensaje 4 $+ $html(%clasifica) $+ 
        set %bool_clasifica_punti 0
      }
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;marcador
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On *:Sockopen:marcador:{
  if ($sockerr > 0) { errore_marcador | return }
  sockwrite -n $sockname GET  /Default.aspx?tabid=113&Controltype=res&idDivision=1 HTTP/1.1
  sockwrite -n $sockname Host:  http://www.marca.com 
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname $crlf
} 

on *:Sockread:marcador: { 
  if ($sockerr > 0) { errore_marcador | return }
  sockread %marcatori
  if (*Clasifica Marcador* iswm %marcador) { set %bool_marcador 1 | msg %chan_marcador 10Clasificacion Marcador $upper(%marcador.liga) }
  elseif ((*</TABLE>* iswm %marcador) && (%bool_marcador == 1)) { set %bool_marcador 0 | sockclose marcador }
  if (%bool_marcador == 1) {
    if (($html(%marcador) isnum) && ($len($html(%marcador)) <= 3)) {
      msg %chan_marcador 4 $+ $html(%marcador) Gol
      set %bool_marcador.2 1
    }
    elseif (($html(%marcador) !isnum) && (%bool_marcador.2 == 1) && ($len($html(%marcador)) >= 0)) {
      msg %chan_marcador $replace($html(%marcador),$chr(40),7 $+ $chr(40) $+ ,$chr(41),7 $+ $chr(41) $+ )
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;resultado & prox jornada
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On *:Sockopen:jornada:{
  if ($sockerr > 0) { errore_jornada | return }
  sockwrite -n $sockname GET  /Default.aspx?tabid=106&idDivision=1HTTP/1.1
  sockwrite -n $sockname Host: www.marca.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname
} 

on *:Sockread:jornada: { 
  if ($sockerr > 0) { errore_jornada | return }
  sockread %jornada
  if (*onmouseout="this.style.backgroundColor='#F291C2* iswm %jornada) { set %jornada.proxima $html(%turni) }
  elseif ((*onmouseout="this.style.backgroundColor='#D30167* iswm %jornada) && (!%cont.jornada) && (%prox.o.risul == 0)) { set %cont.jornada OFF | msg %chan_jornada 10Partidos $liga(%jornada.proxima +1) $+ ° jornada Liga $upper(%jornada.serie) }
  elseif ((*onmouseout="this.style.backgroundColor='#D30167* iswm %jornada) && (!%cont.jornada) && (%prox.o.risul == 1)) { set %cont.jornada OFF | msg %chan_jornada 10Resultados %jornada.proxima $+ ° jornada Liga $upper(%jornada.serie) }
  if (%prox.o.risul == 0) { 
    if (*<img src="images/testa_jornada.jpg"* iswm %jornada) { set %bool_turni 1 }
    elseif ((*</table>* iswm %jornada) && (%bool_jornada == 1)) { set %bool_jornada 0 | sockclose jornada }
    if ((%bool_jornada == 1) && ($len($html(%turni)) >= 1)) {
      msg %chan_jornada 4 $+ $chr(187) $+ $chr(187) $+  $replace($html(%jornada),-,7-)
    }
  }
  elseif (%prox.o.risul == 1) { 
    if (*<img src="images/testa_resultado_gio.jpg"* iswm %jornada) { set %bool_jornada 1 }
    elseif ((*</table>* iswm %jornada) && (%bool_jornada == 1)) { set %bool_jornada 0 | sockclose jornada }
    if ((%bool_jornada == 1) && ($len($html(%jornada)) >= 1)) {
      if ($left($html(%jornada),1) !isnum) { set %jornada.temp  4 $+ $chr(187) $+ $chr(187) $+  $replace($html(%jornada),-,7-) }
      else { msg %chan_jornada %jornada.temp 4 $+ $chr(171) $+  $html(%jornada) 4 $+ $chr(187) $+  }
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;activacion comandos
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on *:text:*:#: {
  if ($1 == !clasifica) {
    if ($2 == primera) {
      if (!$sock(clasifica)) {
        unset %bool_clasifica*
        set %chan_clasifica $chan
        set %clasifica.serie $lower($2)
        sockopen clasifica  www.marca.com  80
      }
      else { msg $chan -Clasifica primera division- Conexion Socket abierta | halt }
    }
    elseif ($2 == segunda) {
      if (!$sock(clasifica)) {
        unset %bool_clasifica*
        set %chan_clasifica $chan
        set %clasifica.serie $lower($2)
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Clasifica segunda division- Conexion Socket abierta | halt }
    }
    else { 
      msg $chan Categoria disponible primera y segunda 
      halt 
    }
  }
  if ($1 == !marcador) {
    if ($2 == primera) {
      if (!$sock(marcador)) {
        unset %bool_marcador*
        set %chan_marcador $chan
        set %marcador.primera $lower($2)
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Marcador- Conexion Socket abierta | halt }
    }
    elseif ($2 == segunda) {
      if (!$sock(marcador)) {
        set %marcatori.serie $lower($2)
        unset %bool_marcador*
        set %chan_marcador $chan
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Marcador- Conexion Socket abierta | halt }
    }
    else { 
      msg $chan Categoria disponible primera y segunda 
      halt 
    }
  }
  if ($1 == !proxima_jornada) {
    if ($2 == primera) {
      if (!$sock(jornada)) {
        unset %bool_jornada*
        unset %cont.jornada
        set %chan_jornada $chan
        set %jornada.liga $lower($2)
        set %prox.o.risul 0
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Proxima jornada- Conexion Socket abierta | halt }
    }
    elseif ($2 == segunda) {
      if (!$sock(jornada)) {
        unset %cont.jornada
        set %jornada.serie $lower($2)
        unset %bool_jornada*
        set %chan_turni $chan
        set %prox.o.risul 0
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Proxima jornada- Conexion Socket abierta | halt }
    }
    else { 
      msg $chan Categoria disponible primera y segunda
      halt 
    }
  }
  if ($1 == !resultado) {
    if ($2 == primera) {
      if (!$sock(jornada)) {
        unset %bool_jornada*
        unset %cont.jornada
        set %chan_jornada $chan
        set %jornada.serie $lower($2)
        set %prox.o.risul 1
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Proxima jornada- Conexion Socket abierta | halt }
    }
    elseif ($2 == segunda) {
      if (!$sock(jornada)) {
        unset %cont.jornada
        set %jornada.serie $lower($2)
        unset %bool_jornada*
        set %chan_jornada $chan
        set %prox.o.risul 1
        sockopen clasifica http://www.marca.com 80
      }
      else { msg $chan -Proxima jornada- Conexion Socket abierta | halt }
    }
    else { 
      msg $chan Categoria disponible primera y segunda 
      halt 
    }
  }
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;error
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias errore_clasifica {
  msg %chan_clasifica -Socket Error-
  sockclose clasifica
  unset %bool_clasifica*
}

alias errore_marcador {
  msg %chan_marcador -Socket Error-
  sockclose marcador
  unset %bool_marcador*
}

alias errore_jornada {
  msg %chan_jornada -Socket Error-
  sockclose jornada
  unset %bool_jornada*
}

Comments

Sign in to comment.
coco   -  Dec 15, 2011

I am trying to solve the problem but I can see where the error in the code so that if I want someone who knows more can verify and say where is the error would be appreciated, however I'm trying to figure out what goes wrong!

 Respond  
Annaiidziithaa   -  Dec 15, 2011

here on this website manage things much less important, and this not? LOL!

 Respond  
Annaiidziithaa   -  Dec 15, 2011

and why not fix this?

 Respond  
coco   -  Dec 15, 2011

annaiidziithaa if I had to work out of this brief but gives socket problem error! and can not find where is the bug!

 Respond  
Annaiidziithaa   -  Dec 12, 2011

This works exactly as written?

 Respond  
Fuzionx   -  Dec 09, 2011

Thanks for the explenation SReject and Jethro ^^

 Respond  
jaytea   -  Dec 08, 2011

For those wondering, $regsub (Not to be confused with $regsubex) is an older way of doing RegExp substitutions.

older, and also different, since with $regsubex() a lot more work is performed by mIRC in delaying the evaluation of the substitution parm until after replacements have been made. we should use $regsub() when we can and $regsubex() when we must. since the latter's syntax is a bit friendlier, it's often easy to misuse, and we can probably forgive a man for doing so.

 Respond  
coco   -  Dec 08, 2011

I still run the code and I'm going crazy to work :S

 Respond  
Jethro   -  Dec 08, 2011

SReject pretty much explained it, Fuzionx.

The advantage of using regsub() is that it will work for older mIRC versions below 6.17 and the latest versions that have since been released. With $regsubex, you must start with 6.17 and up. In other words, $regsubex() is not "backward compatible." :p

 Respond  
SReject   -  Dec 08, 2011

Use regsubex instead

alias -l html return $regsubex($1,/(?:^|<)[^<>]+>|(?:<[^>]+$)|&nbsp;/g,)

For those wondering, $regsub (Not to be confused with $regsubex) is an older way of doing RegExp substitutions. It returns the number of substitutions made(?), and fills an output variable with the resulting text:

$regsub(<input string>,/pattern/,replacement text,%outputvar)
 Respond  
Fuzionx   -  Dec 08, 2011

Would you care to explain your code Jetho, because I think I'm missing the point lol.

 Respond  
coco   -  Dec 08, 2011

thanks for the comments, I will try to revise the code, because when you run, jump socket error error and where it can not be the fault

 Respond  
Jethro   -  Dec 08, 2011

No need for the $remove(). You can do it all with $regsub():

alias -l html { 
var %h 
echo -q $regsub($1,/<[^>]*>|&nbsp;/g,,%h)
return %h 
}
 Respond  
Fuzionx   -  Dec 08, 2011
alias -l html {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}

You set %i but you never use it again..
Try:

alias -l html return $remove($regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,$1-), &nbsp;)

I dont know what the ",$null,$1-" part does though..

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.