Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##############################################################################################
- ## ## 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 "http://www.margriet.nl"
- 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 /horoscoop/${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 {^wat} $text]} { return waterman
- } elseif {[regexp -nocase {^vis} $text]} { return vissen
- } elseif {[regexp -nocase {^ram} $text]} { return ram
- } elseif {[regexp -nocase {^sti} $text]} { return stier
- } elseif {[regexp -nocase {^twe} $text]} { return tweelingen
- } elseif {[regexp -nocase {^cra} $text]} { return crab
- } elseif {[regexp -nocase {^lee} $text]} { return leeuw
- } elseif {[regexp -nocase {^maa} $text]} { return maagd
- } elseif {[regexp -nocase {^wee} $text]} { return weegschaal
- } elseif {[regexp -nocase {^sco} $text]} { return scorpion
- } elseif {[regexp -nocase {^boo} $text]} { return boogschutter
- } elseif {[regexp -nocase {^ste} $text]} { return steenbok
- } else { return "error" }
- }
- bind pub - ${horoscopecmdchar}horo horoscope
- setudef flag horo
- putlog "\017\002Horoscope Script by Ford_Lawnmower successfully loaded!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement