| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat Jun 18, 2016 4:16 am Post subject: help with web sockets |
|
|
To be honest I never understood about sockets.
I need a horoscope in Spanish and I found a website that takes a lot of time online.
home page: http://www.elhoroscopodehoy.es/
signs URLs examples:
for ARIES
http://www.elhoroscopodehoy.es/horoscopo-hoy/aries.php
for TAURUS
http://www.elhoroscopodehoy.es/horoscopo-hoy/tauro.php
For each sign is added to the home page:
horoscopo-hoy/the_sign_is.php
I only began it, there are messages in spanish if you need any traslation please ask for them:
| Code: |
##############################################################################################################
package require http 2.3
bind pub - !sign signs
bind msg - !sign signsmsg
set horochans [string tolower $horochans]
set horopriv [string tolower $horopriv]
proc signsmsg {nick uhost hand text} {
if {![onchan $nick]} {return}
signs $nick $uhost $hand privmsg $text
return
}
proc signs {nick uhost hand chan text} {
set chan [string tolower $chan];
if {([lsearch -exact $::horochans $chan] == -1) && ($chan != "privmsg")} {return}
if {([lsearch -exact $::horopriv $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
set signs "Aries Tauro Geminis Cancer Leo Virgo Libra Escorpio Sagitario Capricornio Acuario Piscis"
set signlc [string tolower $signs]
set text [string trim [string tolower $text]]
set sign [split $text]
if {[lsearch -exact $signlc $sign] == -1} {
puthelp "PRIVMSG $chan :Por favor usa un Signo válido: $signs"
return
} else {
set hurl "http://www.elhoroscopodehoy.es/horoscopo-hoy/$sign.php"
catch {set page [::http::geturl $hurl -timeout $::urlwait]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $nick :Error: No hay conexión..Intenta mas tarde"
::http::cleanup $page
return
}
if { [::http::status $page] == "timeout" } {
puthelp "PRIVMSG $nick :Error: Conexion fuera de Tiempo."
::http::cleanup $page
return
}
set html [::http::data $page]
::http::cleanup $page
##########I arrived upto here..............I don't have the code to retrieve data ........#############
}
} |
_________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
u2pop Voice
Joined: 23 Jun 2008 Posts: 11
|
Posted: Sat Jun 18, 2016 10:41 pm Post subject: Horoscopo.tcl en Español |
|
|
Hola aqui te comparto mi tcl para que pueda ver horoscopo en español de otra pagina web, que lo disfriute!
| Code: |
##############################################################################################################
##############################################################################################################
# Horoscopo en español (basado en HoroEsp - Realizado por Joan joanlion@yahoo.es) & Modificado por
# _u2pop_ (u2pop@live.com)
#
# Cuando me encontre con este script el mismo ya no funcionaba, por lo que
# me dispuse a ponerlo en funcionamiento. Por suerte se realizaron dos
# modificaciones en el codigo fuente y con eso fue suficiente.
#
#
# Cualquier consulta me pueden encontrarme en #Republica_Dominicana o #Ayuda_irc en ChatHispano
#
# Para su funcionamiento es NECESARIO contar con http.tcl
#
##############################################################################################################
##############################################################################################################
#
# Versión del sctipt tcl
#
set shver "2.0"
##############################################################################################################
#
# Uso: !horoscopo <SignoZodiaco> (donde <SignoZodiaco> es tu signo zodiacal)
#
# También se puede utilizar /msg nickdelbot !horoscopo <SignoZodiaco>
#
# Nota: La información del hosroscopo es suministrada por HoroscopoFree.Com
#
##############################################################################################################
#Configuración:
##########
# Canales donde se permite el uso por comando al canal, son (lista separada por espacios)
set shorochans "#canal"
# Sin considerar los canales de arriba, en estos canales SOLAMENTE
# se repondera via PRIVMSG (privado) al usuario en teoria segun el HoroEsp:
set shoroquiet ""
# Tiempo de espera a obtener la URL (no cambiar):
set shtout "30000"
##############################################################################################################
package require http 2.3
bind pub - !horoscopo shoro
bind pub - .horoscopo shoro
bind pub - ?horoscopo shoro
bind pub - !signo shoro
bind pub - .signo shoro
bind pub - ?signo shoro
bind msg - !horoscopo shoromsg
bind msg - .horoscopo shoromsg
bind msg - !signo shoromsg
bind msg - .signo shoromsg
set shorochans [string tolower $shorochans]
set shoroquiet [string tolower $shoroquiet]
proc shoromsg {nick uhost hand text} {
if {![onchan $nick]} {return}
shoro $nick $uhost $hand privmsg $text
return
}
proc shoro {nick uhost hand chan text} {
set chan [string tolower $chan];
if {([lsearch -exact $::shorochans $chan] == -1) && ($chan != "privmsg")} {return}
if {([lsearch -exact $::shoroquiet $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
set signs "Aries Tauro Geminis Cancer Leo Virgo Libra Escorpio Sagitario Capricornio Acuario Piscis"
set signlc [string tolower $signs]
set text [string trim [string tolower $text]]
set sign [split $text]
if {[lsearch -exact $signlc $sign] == -1} {
puthelp "NOTICE $nick :Porfavor utiliza el comando !signo <SignoZodiaco> los signos válidos son: $signs Ejemplo !horoscopo aries"
return
} else {
set shurl "http://es.horoscopofree.com/object/html/iframe-sign-$sign"
catch {set page [::http::geturl $shurl -timeout $::shtout]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :Error: No hay conexion..Intenta mas tarde."
::http::cleanup $page
return
}
if { [::http::status $page] == "timeout" } {
puthelp "PRIVMSG $chan :Error: Conexion fuera de Tiempo."
::http::cleanup $page
return
}
set html [::http::data $page]
::http::cleanup $page
set shout ""
if {[regexp {</strong>(.*?)<a href=} $html match shout]} {
set shout [string trim $shout]
regsub -all {\n} $shout {} shout
# word wrapper
set j 0
set shct 0
foreach line [split $shout \n] {
if {$line != ""} {
set len 375
set splitChr " "
set out [set cur {}]; set i 0
foreach word [split $line $splitChr] {
if {[incr i [string len $word]]>$len} {
lappend out [join $cur $splitChr]
set cur [list $word]
set i [string len $word]
incr j
} else {
lappend cur $word
}
incr i
}
lappend out [join $cur $splitChr]
foreach line2 $out {
if {$shct == 0} {
set line2 [linsert $line2 0 \002[string totitle $sign]\002:]
incr shct
if {$j >= 1} {
set line2 [linsert $line2 end \002(con't)\002]
set j [expr $j - 1]
}
} else {
set line2 [linsert $line2 0 \002([string totitle $sign] con't)\002]
if {$j >= 1} {
set line2 [linsert $line2 end \002(con't)\002]
set j [expr $j - 1]
}
}
puthelp "PRIVMSG $chan :$line2"
}
}
}
} else {
puthelp "PRIVMSG $chan :Lo siento, no puedo encontrar tu horoscopo, intentalo mas tarde!!!"
}
}
}
putlog "\002horoscopo.tcl $shver por _u2pop_ - Cargado...\002"
|
|
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Mon Jun 20, 2016 4:44 pm Post subject: |
|
|
Muchas gracias u2pop
Justamente ese fue el que traté de modificar y no me funcionaba  _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sun Jul 03, 2016 4:46 am Post subject: |
|
|
Perdón por el doble post, pero me quedó una pregunta.
u2pop tienes idea de como modificar el len =375 ?
Lo que deseo es que compare un número de caracteres, pero que no corte la oración sino encuentra un punto.
Habría que poner un comparador que si len es menor o igual que 375 y el último caracter de la oración es un punto, que pase a la segunda línea.
Alguna idea? _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Jul 14, 2016 1:43 pm Post subject: |
|
|
Apparently u2pop code this returns and cuts the horoscope. It has a disorder when it launches the horoscope. Some friend to correct the order of release in this tcl.
example:
(Current horoscope with disorder)
| Quote: |
<12@Arnold_X-P> .signo virgo
<03@Kantuta> (Virgo con't) tu pareja logra darte la calma que necesitas.
<03@Kantuta> Virgo: Hoy estarás intratable, demostrarás nerviosismo al punto que se leerá en tu cara deberás cambiar esta actitud porque quien tienes a tu alrededor reaccionará alejándose de ti. En el trabajo, te sentirás oprimido y esta situación te pondrá mucha ansiedad y miedo, tú podrás lograr todo lo que te propones no tienes nada que temer. En el amor, todo continua por el camino justo, (con't)
|
[b](the correct is)
| Quote: |
<12@Arnold_X-P> .signo virgo
<03@Kantuta> Virgo: Hoy estarás intratable, demostrarás nerviosismo al punto que se leerá en tu cara deberás cambiar esta actitud porque quien tienes a tu alrededor reaccionará alejándose de ti. En el trabajo, te sentirás oprimido y esta situación te pondrá mucha ansiedad y miedo, tú podrás lograr todo lo que te propones no tienes nada que temer. En el amor, todo continua por el camino justo, tu pareja logra darte la calma que necesitas.
|
the detail is on the line 120 and 126 foreach line2 $out {
please someone help correct this crossing tcl throwing this in the horoscope we greatly appreciate it _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
|