Basic Horoscope script for Eggdrop.
Thanks to mentok for testing :)
Now Requires TLS , OpenSSl and HTTP
Trigger: !horo sign
Chanset: +horo
The colors, commandchar and logo can be changed in the setup.
This script will accept the first 3 letters of your sign so you don't have to type the whole sign.
Example Output::
18:49:01 <!Ford_Lawnmower> !horo sco
18:49:03 Horoscope It will be a stimulating day for you Scorpio! You'll be feeling great and you'll have no trouble channeling all your energy into your activities. But don't be surprised if you encounter some resistance. Creative as your ideas are they may not suit everyone. In fact you may be confronted
18:49:04 Horoscope with some rebelliousness. Be persuasive and you'll get your way today...
##############################################################################################
## ## Horoscope.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
##############################################################################################
## To use this script you must set channel flag +horo (ie .chanset #chan +horo) ##
##############################################################################################
##############################################################################################
## ____ __ ########################################### ##
## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
## /___/ /___/ /_/ ########################################### ##
## ########################################### ##
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
package require http
package require tls
## Change the character between the "" below to change the command character/trigger. ##
set horoscopecmdchar "!"
proc horoscope {nick host hand chan search} {
if {[lsearch -exact [channel info $chan] +horo] != -1} {
## Change the characters between the "" below to change the logo shown with each result. ##
set horoscopelogo "\002\00314H\0034o\0038r\00314o\0039s\0034c\00314o\0038p\0039e\002\003"
## Change the format codes between the "" below to change the color/state of the text. ##
set textf "\0034"
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
set horoscopesite "https://uk.astrology.yahoo.com"
set horoscopesign [getsign $search]
if {$horoscopesign == "error"} {
putserv "PRIVMSG $chan :$horoscopelogo Valid signs are: Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn."
} else {
set horoscopeurl /horoscopes/${horoscopesign}/
set horoscopefound ""
::http::register https 443 tls::socket
::http::config -accept "text/html" -useragent "firefox"
set horoscopetoken [::http::geturl ${horoscopesite}${horoscopeurl}]
set horoscopevar [::http::data $horoscopetoken]
::http::cleanup $horoscopetoken
::http::unregister https
if {[regexp {<div class="astro-tab-body">(.*?)<\/div>} $horoscopevar match horoscoperesult]} {
set horoscoperesult [textsplit $horoscoperesult. 50]
set counter 0
while {$counter <= [llength $horoscoperesult]} {
if {[lindex $horoscoperesult $counter] != ""} {
putserv "PRIVMSG $chan :$horoscopelogo $textf[lindex $horoscoperesult $counter]"
}
incr counter
}
}
}
}
}
proc textsplit {text limit} {
set text [split $text " "]
set tokens [llength $text]
set start 0
set return ""
while {[llength [lrange $text $start $tokens]] > $limit} {
incr tokens -1
if {[llength [lrange $text $start $tokens]] <= $limit} {
lappend return [join [lrange $text $start $tokens]]
set start [expr $tokens + 1]
set tokens [llength $text]
}
}
lappend return [join [lrange $text $start $tokens]]
return $return
}
proc getsign {text} {
if {[regexp -nocase {^aqu} $text]} { return aquarius
} elseif {[regexp -nocase {^pis} $text]} { return pisces
} elseif {[regexp -nocase {^ari} $text]} { return aries
} elseif {[regexp -nocase {^tau} $text]} { return taurus
} elseif {[regexp -nocase {^gem} $text]} { return gemini
} elseif {[regexp -nocase {^can} $text]} { return cancer
} elseif {[regexp -nocase {^leo} $text]} { return leo
} elseif {[regexp -nocase {^vir} $text]} { return virgo
} elseif {[regexp -nocase {^lib} $text]} { return libra
} elseif {[regexp -nocase {^sco} $text]} { return scorpio
} elseif {[regexp -nocase {^sag} $text]} { return sagittarius
} elseif {[regexp -nocase {^cap} $text]} { return capricorn
} else { return "error" }
}
bind pub - ${horoscopecmdchar}horo horoscope
setudef flag horo
putlog "\017\002Horoscope Script by Ford_Lawnmower successfully loaded!"
@Bri1977 I never noticed leaving out the nocase option on the first if. I think I might have edited an old version of the script. I dropped the shell I used with most of my tcl's, so I really don't know.
Anyway, I updated it.
cheers @FordLawnmower women are never bloody happy lol
[18:00:59] bri, submit another ticket lol
[18:01:11] why?
[18:01:15] proc getsign {text} {
[18:01:16] # if {[regexp {^aqu} $text]} { return aqu << original
[18:01:16] if {[regexp -nocase {^aqu} $text]} { return aqu << mine
[18:01:19] } elseif {[regexp -nocase {^pis} $text]} { return pis
[18:01:20] } elseif {[regexp -nocase {^ari} $text]} { return ari
It works fine tho and she has made the edits herself ;)
@FordLawnmower i think this script needs an update like the mIRC version did, some pest is mithering me :p
[13:21:27] any update for the hoto trigger?
[13:21:33] !horo
[13:21:53] no idea lol
[13:22:44] !horo
[13:22:46] Horoscope Valid signs are: Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn.
[13:22:54] !horo aqu
[13:23:06] no errors
Great script,congratulations!!Can you port the code to read portuguese horoscope from this site http://horoscopovirtual.uol.com.br/horoscopo/signo-libra.html ??I tried only substitute the urls on your script,but didnt work...(Also substitute the sign names to match the url ones,for sure)
Thank You!!
EDIT:Got it with this url : http://www.joaobidu.com.br/jb2/html/horoscopos.php?signo=7 ,but theres a "day's color" after the horoscope phrase,and it's not appearing on chan...Is possible to append this on code?