This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Updated horoscope pls

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

Updated horoscope pls

Post by anotherrace »

Can I please request for a new horoscope script. Because I think Yahoo Horoscope for Eggdrop by FordLawnmower has stopped working. Thank You
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

package require http
# to activate on a #channel : .chanset #channel +horo
setudef flag horo

bind pub - .horo horo_pub

proc horo_pub {nick uhost hand chan text} {
   if {![channel get $chan horo]} { return }
      set q [lindex [split [string tolower $text]] 0]
	   set horos "Aries|Taurus|Gemini|Cancer|Leo|Virgo|Libra|Scorpio|Sagittarius|Capricorn|Aquarius|Pisces"
	  
   if {$q eq ""} {
       puthelp "NOTICE $nick :\002Usage\002 : \00304$::lastbind $horos\003"
	   return 0
	   }
	   
   if {[regexp -nocase -- $q $horos]} {
      set url [http::geturl "http://www.lcblack.com/horoscope?sign=$q" -timeout 4000]
      set data [split [http::data $url] \n]
	  http::cleanup $url
	  regexp {<div class="horoscope">(.*?)</p>} $data "" output
	  regsub -all -- "<p>" $output "" output
	  regsub -all -- \} $output "" output
	  regsub -all -- \{ $output "" output
	     puthelp "PRIVMSG $chan :\00312$output\003"
	  } else {
	     puthelp "NOTICE $nick :\00303$horos\003"
	  }
  return 0
}
btw , FordLawnmower's script still Works fine.... i just made a test. His script requires tcl-tls package .
Life iS Just a dReaM oN tHE wAy to DeaTh
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

The new script is working great

Post by anotherrace »

I apologize for the misunderstanding with Yahoo Horoscope. I guess i have yet to fix my tcl-tls package problems. The script is probably working but my system needs to be updated. The new script works like a charm and im using now. Thanks a lot =)
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

New horoscope script pls

Post by anotherrace »

Good day Heartbroken!
I've been using your horoscope script for a few months now. I enjoy using it a lot for my channel now but doesnt seem to be working anymore. Can you help me to find a working horoscope script? Anyone?
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

package require http 
 # to activate on a #channel : .chanset #channel +horo 
 setudef flag horo 

 bind pub - .horo horo_pub 

 proc horo_pub {nick uhost hand chan text} { 
    if {![channel get $chan horo]} { return 0 } 
       set q [lindex [split [string tolower $text]] 0] 
       set horos "Aries|Taurus|Gemini|Cancer|Leo|Virgo|Libra|Scorpio|Sagittarius|Capricorn|Aquarius|Pisces" 
      
    if {$q eq ""} { puthelp "NOTICE $nick :\002Usage\002 : \00304$::lastbind $horos\003"; return 0 } 
        
    if {[regexp -nocase -- $q $horos]} { 
       set url [http::geturl "http://www.lcblack.com/horoscope?sign=$q" -timeout 4000] 
       set data [split [http::data $url] \n] 
       http::cleanup $url 
	  
       regexp {horoscope_date">(.*?)<.+horoscope_title">(.*?)<.+horoscope">(.*?)</p>} $data "" hdate htitle houtput
       #regexp {aspects_title">(.*?)</h3>.+aspect_time">(.*?)<.+aspect_event">(.*?)<.+aspect_meaning">(.*?)<} $data "" atitle atime aevent ameaning
       regexp {love">(.*?)<span>(.*?)<.+communication">(.*?)<span>(.*?)<.+work">(.*?)<span>(.*?)<} $data "" love lno comm cno work wno
	  
       set houtput [string map {\} "" \{ "" <p> ""} [string trim $houtput]]
	   #set aspects "\00302$atitle\003 - \00304$atime\003 - \00305$aevent\003 : \00314$ameaning\003"
	   set lcw "\00304$love\003 : \002$lno\002 - \00304$comm\003 : \002$cno\002 - \00304$work\003 : \002$wno\002"
	   #set aspects [string map {\} "" \{ ""} [string trim $aspects]]
	   set lcw [string map {\} "" \{ ""} [string trim $lcw]]
	   
        puthelp "PRIVMSG $chan :\00309$hdate\003 - \00312$htitle\003 :"
		 puthelp "PRIVMSG $chan :\00314$houtput\003"
		 #puthelp "PRIVMSG $chan :$aspects"
		 puthelp "PRIVMSG $chan :$lcw"
      } else { 
         puthelp "NOTICE $nick :\00303$horos\003" 
      } 
   return 0 
 }
.horo aries
< bot > Wednesday, July 9 - Today's Horoscope :
< bot > Set long-range goals over the next two days. Start planning a vacation or trip. Don't quit your day job yet, but get your ducks in a row. Remember home obligations. Stick to practical actions.
< bot> Love : 9 - Communication : 9 - Work : 8
.horo cancer
< bot > Wednesday, July 9 - Today's Horoscope :
< bot > The work's intricate, but rewarding for the next two days. Ask for more and get it. Keep costs down as much as possible. Get into action. With diligence, you'll succeed. Take a deep bow.
< bot > Love : 9 - Communication : 8 - Work : 8
Life iS Just a dReaM oN tHE wAy to DeaTh
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

Good day

Post by anotherrace »

Im getting an error Tcl error [horo_pub]: can't read "houtput": no such variable.

Am i doing something wrong? Thanks for the speedy response.
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

Updated version

Post by anotherrace »

Ive tried the updated (April 12, 2014) version of yahoo horoscope by By FordLawnmower. It seems to be working. But please keep me posted heartbroken. I want to use your script also =)
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

i just check it once again and i follow it on partyline ,but i didn't get any err ...
anyway i re-edit to , if that "houtput" thingy exists or not in this edit...
should fixed the err with this way.

Code: Select all

package require http 
  # to activate on a #channel : .chanset #channel +horo 
  setudef flag horo 

  bind pub - .horo horo_pub 

  proc horo_pub {nick uhost hand chan text} { 
     if {![channel get $chan horo]} { return 0 } 
        set q [lindex [split [string tolower $text]] 0] 
        set horos "Aries|Taurus|Gemini|Cancer|Leo|Virgo|Libra|Scorpio|Sagittarius|Capricorn|Aquarius|Pisces" 
       
     if {[llength $q] < 1 || ![regexp -nocase -- $q $horos]} { 
	       puthelp "NOTICE $nick :\002Usage\002 : \00304$::lastbind $horos\003"
		   return 0
		} 
         		
        set url [http::geturl "http://www.lcblack.com/horoscope?sign=$q" -timeout 4000] 
        set data [split [http::data $url] \n] 
        http::cleanup $url 
      
        regexp {horoscope_date">(.*?)<.+horoscope_title">(.*?)<.+horoscope">(.*?)</p>} $data "" hdate htitle houtput 
        #regexp {aspects_title">(.*?)</h3>.+aspect_time">(.*?)<.+aspect_event">(.*?)<.+aspect_meaning">(.*?)<} $data "" atitle atime aevent ameaning 
        regexp {love">(.*?)<span>(.*?)<.+communication">(.*?)<span>(.*?)<.+work">(.*?)<span>(.*?)<} $data "" love lno comm cno work wno 
		
     if {[info exists houtput]} {
        set houtput [string map {\} "" \{ "" <p> ""} [string trim $houtput]] 
       #set aspects "\00302$atitle\003 - \00304$atime\003 - \00305$aevent\003 : \00314$ameaning\003" 
        set lcw "\00304$love\003 : \002$lno\002 - \00304$comm\003 : \002$cno\002 - \00304$work\003 : \002$wno\002" 
       #set aspects [string map {\} "" \{ ""} [string trim $aspects]] 
        set lcw [string map {\} "" \{ ""} [string trim $lcw]] 
        
          puthelp "PRIVMSG $chan :\00309$hdate\003 - \00312$htitle\003 :" 
          puthelp "PRIVMSG $chan :\00314$houtput\003" 
         #puthelp "PRIVMSG $chan :$aspects" 
          puthelp "PRIVMSG $chan :$lcw" 
         } else { 
          putlog "err...nothing found." 
         } 
     return 0
  } 
you can also try incith-horoscope ( i dunno if its updated & Works . )
Life iS Just a dReaM oN tHE wAy to DeaTh
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

update

Post by anotherrace »

I tried your horoscope script heartbroken. The new version works great and i think its the best horoscope now. More power to you!
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

I know this is bumping an old one, but i have started learning tcl, so not sure how i would sort the link out.

It has changed from

"http://www.lcblack.com/horoscope?sign=$q"

to

http://www.lcblack.com/pisces_horoscope"
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

package require http
package require tls
package require htmlparse

setudef flag horoscope

set horo_cmds ".horo !horos !horoscope"

set horobot_PM 1

set horo_EggFlags -|-

foreach HoroCmd [split $horo_cmds { }] {
	bind pub $horo_EggFlags $HoroCmd horo_Pubs
	if {$horobot_PM != "" && $horobot_PM >= 1} {
		bind msg $horo_EggFlags $HoroCmd horo_BotPM
	}
}

::http::register https 443 [list ::tls::socket -ssl2 0 -ssl3 0 -tls1 1]

proc horo_BotPM {nick uhost hand text} {
	Horo_MainProc $nick $uhost $hand $nick $text
}

proc horo_Pubs {nick uhost hand chan text} {
	if {![channel get $chan horoscope]} { return }
	Horo_MainProc $nick $uhost $hand $chan $text
}

proc Horo_MainProc {nick uhost hand chan text} {
	set ValidHoros [list aries taurus gemini cancer leo virgo libra scorpio sagittarius capricorn aquarius pisces]
	set HoroQuery [lindex [split [string trimleft [stripcodes abcgru $text]]] 0]
	if {![llength $HoroQuery]} {
		puthelp "PRIVMSG $chan :Usage: $::lastbind <Horoscope>"
		return
	} elseif {[lsearch -nocase $ValidHoros $HoroQuery] == -1} {
		puthelp "PRIVMSG $chan :\"$HoroQuery\" is not a valid query!"
		return
	} else {
		set HoroData [fetch_Horo_HTML https://www.lcblack.com/${HoroQuery}_horoscope]
		set HoroRE {_date">(.*?)<.+?title">(.*?)</.+?cope">(.*?)</p>.+?love">(.*?)</li>.+?">(.*?)</li>.+?">(.*?)</li>}
		if {[regexp -- $HoroRE $HoroData -> Date Title Horoscope Love Communication Work]} {
			puthelp "PRIVMSG $chan :\00312$Date\003 [Clean_HoroHTML $Title]"
			puthelp "PRIVMSG $chan :[Clean_HoroHTML $Horoscope]"
			puthelp "PRIVMSG $chan :\002[Clean_HoroHTML $Love] \002[Clean_HoroHTML $Communication] \002[Clean_HoroHTML $Work]"
		} else {
			putcmdlog "[file tail [info script]] Regexp fails to match: https://www.lcblack.com/${HoroQuery}_horoscope"
		}

	}
	return 0
}

proc Clean_HoroHTML Horo {
	regsub -all -- {(?:<b>|</b>)} $Horo \002 Horo
	regsub -all -- {<span>(.*?)</span>} $Horo \002\00304\\0\003 Horo
	regsub -all -- "<.+?>" $Horo { } Horo
	regsub -all -- {\s+} $Horo " " Horo
	return [string trim $Horo]
}

proc fetch_Horo_HTML HoroURL {
	if {[catch {set HoroTok [http::geturl $HoroURL -timeout 12000]} Error]} {
		putcmdlog "[file tail [info script]]: [string map {\n " "} $Error]"
		return
	}
	if {[http::status $HoroTok] eq "ok" && [http::ncode $HoroTok] == 200} {
		set HoroHTML [http::data $HoroTok]
	} else {
		putcmdlog "[file tail [info script]]: [http::status $HoroTok] - [http::code $HoroTok]"
	}
	::http::cleanup $HoroTok
	if {[string length $HoroHTML] && [info exists HoroHTML]} {
		return [htmlparse::mapEscapes $HoroHTML]
	}
}

putlog "[file tail [info script]] loaded!"
Life iS Just a dReaM oN tHE wAy to DeaTh
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

heartbroken, It is possible to change from https://www.lcblack.com/
to https://www.horoscope.com/us/index.aspx
to read from that new web
his contribution would be very generous
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

I haven't tested! thus, I do not know if it works or not yet ,
but, you can make a test and let me know if you see any Error.

This script requires Tcl 8.6 ,tcllib ,TclTLS and eggdrop1.8 bot!

Code: Select all

# This script using some of Tcl8.6's commands,also needs Tcl-TLS for https links and tcllib for fixed outputs!
package require http
package require htmlparse
package require tls 1.6.4
package require textutil::split
package present Tcl 8.6
package require eggdrop 1.8

# to activate on your #channel : .chanset #channel +Horoscope in PartyLine
setudef flag Horoscope

namespace eval Horoscope {
    # You can add multiple Horoscope commands with a space between. 
	variable HoroCMD ".horo !horo !horoscope"
	
	# Would you like to use this script commands in your bot's pvt?
	# 1 yes , 0 no
	variable HoroEggPM 1
	
	# users able to make horo queries in seconds:times 
	variable FludControl 10:3
	
	# eggdrop user flags : general flags|channel flags
	variable HoroCmdFlags -|-
	
	# How many chars would allow to print in a line 
	variable HoroCharsInLineLen 312
	
	# daily horo query link
	variable DailyHoroURL {https://www.horoscope.com/us/horoscopes/general/horoscope-general-daily-today.aspx}
	
	# rating stars regexp
	variable HoroStarsRE {<div class="ratings">(.+?)</div>}
	
	# daily horoscope regexp
	variable HoroDailyRE {<strong class="date">(.*?)</p>}
	
	# matches regexp
	variable HoroMatchesRE {<h3>(.*?)</h3>.+?love\">(.*?)</p>.+?friend\">(.*?)</p>.+?career\">(.*?)</p>}
	
	# for filled star highlight
	variable UnicodeBlackStar \u2605
	
	# for filled star outputs
	variable UnicodeWhiteStar \u2606
	
	# connection timeout time in seconds
	variable TimeOutHoro 12
	
	# ratings title:
	variable MoodRatings "\00314Today's Star Ratings - Your general mood\003"
	# end of settings
	
	foreach CmdSign [split $HoroCMD { }] {
		bind pub $HoroCmdFlags $CmdSign [namespace current]::HorosPubProcName
		if {$HoroEggPM >= 1 && [string length $HoroEggPM]} {
			bind msg $HoroCmdFlags $CmdSign [namespace current]::EggPvtHorosProcName
		}
	};
	putlog "[file tail [info script]] Loaded!"

	namespace path {::http:: ::htmlparse:: ::textutil::split::}
	register https 443 [list tls::socket -ssl2 0 -ssl3 0 -tls1 1]

	proc MainHoroProcName {nick uhost hand chan text} {
		variable FludControl ;
		set TargetHost [lindex [split $uhost @] 1]
		if {![info exists ::HoroFludVar($TargetHost)] && ![info exists ::HoroFludVar($nick)]} {
			array set ::HoroFludVar [list $nick [clock seconds] $TargetHost 0]
		} else {
			incr ::HoroFludVar($TargetHost)
		}
		if {([expr {[clock seconds] - $::HoroFludVar($nick)}] <= [lindex [split $FludControl :] 0]) && ($::HoroFludVar($TargetHost) >= [lindex [split $FludControl :] 1])} {
			putserv "NOTICE $nick :$nick You able to use $::lastbind command [lindex [split $FludControl :] 1] times in [lindex [split $FludControl :] 0] seconds!";
			return 0;
		}
		utimer [lindex [split $FludControl :] 0] [list unset -nocomplain ::HoroFludVar($TargetHost) ::HoroFludVar($nick)]
		set HoroRequest [lindex [split [stripcodes * [string tolower $text]]] 0]
		set ListOfHoros [dict create aries 1 taurus 2 gemini 3 cancer 4 leo 5 virgo 6 libra 7 scorpio 8 sagittarius 9 capricorn 10 aquarius 11 pisces 12]
		if {![llength $HoroRequest]} {
			putserv "NOTICE $nick :Usage: $::lastbind <Horoscope>";
			return 0
		} elseif {$HoroRequest ni [dict keys $ListOfHoros]} {
			putserv "NOTICE $nick :\"$HoroRequest\" is not valid!";
			return
		} else {
			set HoroWhatWeGot [::Horoscope::FetchDisHoros ${Horoscope::DailyHoroURL}?sign=[dict get $ListOfHoros $HoroRequest]]
			if {[regexp -- $Horoscope::HoroDailyRE $HoroWhatWeGot -> TodaysHoro]} {
				::Horoscope::PrintHoro $chan [::Horoscope::HoroCleanUp $TodaysHoro] 
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroDailyRE";
			}
			if {[regexp -- $Horoscope::HoroStarsRE $HoroWhatWeGot -> HiLightStars]} {
				puthelp "PRIVMSG $chan :$Horoscope::MoodRatings : [::Horoscope::HoroCleanUp $HiLightStars]"; 
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroStarsRE";
			}
			if {[regexp -- $Horoscope::HoroMatchesRE $HoroWhatWeGot -> Matches Love Friend Career]} {
				puthelp "PRIVMSG $chan :[::Horoscope::HoroCleanUp [set AllMatches "\00314$Matches\003: $Love - $Friend - $Career"]]";
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroMatchesRE";
			}
		};
		return 0
	}

	proc HorosPubProcName {nick uhost hand chan arg} {
		if {![channel get $chan Horoscope]} { return 0 };
		::Horoscope::MainHoroProcName $nick $uhost $hand $chan $arg
	}

	proc EggPvtHorosProcName {nick uhost hand chan arg} {
		::Horoscope::MainHoroProcName $nick $uhost $hand $nick $arg
	}

	proc PrintHoro {HoroTarget HoroString} {
		lmap HoroLines [splitn $HoroString $Horoscope::HoroCharsInLineLen] { puthelp "PRIVMSG $HoroTarget :[::Horoscope::HoroCleanUp $HoroLines]" }
	}

	proc HoroCleanUp HoroHTMLs { 
       regsub -all -- {<i class="icon-star-filled highlight"></i>} $HoroHTMLs \00307$Horoscope::UnicodeBlackStar\003 HoroHTMLs 
       regsub -all -- {<i class="icon-star-filled"></i>} $HoroHTMLs \00314$Horoscope::UnicodeWhiteStar\003 HoroHTMLs 
       #regsub -all -- {(:?<strong>|</strong>|<b>|</b>)} $HoroHTMLs \002 HoroHTMLs 
       regsub -all -- {(:?<h4>|</h4>)} $HoroHTMLs \002 HoroHTMLs 
       regsub -all -- {<p>([^\s]*)} $HoroHTMLs \00304\\0\003  HoroHTMLs 
       regsub -all -- "<.+?>" $HoroHTMLs {} HoroHTMLs 
       regsub -all -- {\s+} $HoroHTMLs " " HoroHTMLs 
       return [string trim $HoroHTMLs] 
    } 

	proc FetchDisHoros Link4Horo {
		try {
			set TokenHoro [geturl $Link4Horo -timeout [expr {round(1000 * $Horoscope::TimeOutHoro)}]]
		} on error { HoroErrorMsg } {
			putcmdlog "[file tail [info script]]: [string map {\n " "} $HoroErrorMsg]"
		} finally {
			if {[status $TokenHoro] eq "ok" && [ncode $TokenHoro] == 200} {
				set TheHoroData [data $TokenHoro]
			} else {
				putcmdlog "[file tail [info script]]: [status $TokenHoro] , [code $TokenHoro]" }; cleanup $TokenHoro
			if {[info exists TheHoroData] && [string length $TheHoroData]} {
				return [mapEscapes $TheHoroData]
			} else {
				putcmdlog "[file tail [info script]]: Got no any data from: $Link4Horo"
			}
		}
	}
}
P.S. latest edit!
Last edited by heartbroken on Tue Jun 11, 2019 5:46 pm, edited 5 times in total.
Life iS Just a dReaM oN tHE wAy to DeaTh
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

heartbroken..
I apologize if it is possible for the tcl to work in eggdrop1.6.21 (tcl8.5) I would really appreciate it, and thanks for your help.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

This one tested & fixed. it is workin' now!

Image
Ok This is my last edit . I've made some cosmetic changes for nicer outputs.

Code: Select all

package require http
package require htmlparse
package require tls 1.6.4

setudef flag Horoscope

namespace eval Horoscope {

	variable HoroCMD ".horo !horo !horoscope"

	variable HoroEggPM 1

	variable FludControl 10:3

	variable HoroCmdFlags -|-

	variable HoroWordsInLineLen 36

	variable DailyHoroURL {https://www.horoscope.com/us/horoscopes/general/horoscope-general-daily-today.aspx}

	variable HoroStarsRE {<div class="ratings">(.+?)</div>}

	variable HoroDailyRE {<strong class="date">(.*?)</p>}

	variable HoroMatchesRE {<h3>(.*?)</h3>.+?love\">(.*?)</p>.+?friend\">(.*?)</p>.+?career\">(.*?)</p>}

	variable UnicodeBlackStar \u2605

	variable UnicodeWhiteStar \u2606

	variable TimeOutHoro 12

	variable MoodRatings "\00303Today's Star Ratings - Your general mood\003"

	foreach CmdSign [split $HoroCMD { }] {
		bind pub $HoroCmdFlags $CmdSign [namespace current]::HorosPubProcName
		if {$HoroEggPM >= 1 && [string length $HoroEggPM]} {
			bind msg $HoroCmdFlags $CmdSign [namespace current]::EggPvtHorosProcName
		}
	};
	putlog "[file tail [info script]] Loaded!"

	namespace path {::http:: ::htmlparse::}
	register https 443 [list tls::socket -ssl2 0 -ssl3 0 -tls1 1]

	proc MainHoroProcName {nick uhost hand chan text} {
		variable FludControl
		set TargetHost [lindex [split $uhost @] 1]
		if {![info exists ::HoroFludVar($TargetHost)] && ![info exists ::HoroFludVar($nick)]} {
			array set ::HoroFludVar [list $nick [clock seconds] $TargetHost 1]
		} else {
			incr ::HoroFludVar($TargetHost)
		}
		if {([expr {[clock seconds] - $::HoroFludVar($nick)}] < [lindex [split $FludControl :] 0]) && ($::HoroFludVar($TargetHost) > [lindex [split $FludControl :] 1])} {
			putserv "NOTICE $nick :$nick You able to use $::lastbind command [lindex [split $FludControl :] 1] times in [lindex [split $FludControl :] 0] seconds!";
			return 0;
		}
		utimer [lindex [split $FludControl :] 0] [list unset -nocomplain ::HoroFludVar($TargetHost) ::HoroFludVar($nick)]
		set HoroRequest [lindex [split [stripcodes abcgru [string tolower $text]]] 0]
		array set ListOfHoros [list aries 1 taurus 2 gemini 3 cancer 4 leo 5 virgo 6 libra 7 scorpio 8 sagittarius 9 capricorn 10 aquarius 11 pisces 12]
		if {![llength $HoroRequest]} {
			putserv "NOTICE $nick :Usage: $::lastbind <Horoscope>";
			return 0
		} elseif {$HoroRequest ni [array names ListOfHoros]} {
			putserv "NOTICE $nick :\"$HoroRequest\" is not valid!";
			return
		} else {
			set HoroWhatWeGot [::Horoscope::FetchDisHoros ${Horoscope::DailyHoroURL}?sign=$ListOfHoros($HoroRequest)]
			if {[regexp -- $Horoscope::HoroDailyRE $HoroWhatWeGot -> TodaysHoro]} {
				::Horoscope::PrintHoro $chan [::Horoscope::HoroCleanUp $TodaysHoro]
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroDailyRE";
			}
			if {[regexp -- $Horoscope::HoroStarsRE $HoroWhatWeGot -> HiLightStars]} {
				puthelp "PRIVMSG $chan :$Horoscope::MoodRatings : [::Horoscope::HoroCleanUp $HiLightStars]"; 
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroStarsRE";
			}
			if {[regexp -- $Horoscope::HoroMatchesRE $HoroWhatWeGot -> Matches Love Friend Career]} {
				puthelp "PRIVMSG $chan :[::Horoscope::HoroCleanUp [set AllMatches "\00314$Matches\003: $Love - $Friend - $Career"]]";
			} else {
				putcmdlog "[file tail [info script]]: Somethings wrong with $Horoscope::HoroMatchesRE";
			}
		};
		return 0
	}

	proc HorosPubProcName {nick uhost hand chan arg} {
		if {![channel get $chan Horoscope]} { return 0 };
		::Horoscope::MainHoroProcName $nick $uhost $hand $chan $arg
	}

	proc EggPvtHorosProcName {nick uhost hand chan arg} {
		::Horoscope::MainHoroProcName $nick $uhost $hand $nick $arg
	}

	proc PrintHoro {HoroTarget HoroString} {
		if {[set HoroLineLen [llength [set HoroLenght [split $HoroString]]]] > $Horoscope::HoroWordsInLineLen} {
			for { set i 0 } { $i < $HoroLineLen } { incr i $Horoscope::HoroWordsInLineLen } {
				if {$i == 0} {
					puthelp "PRIVMSG $HoroTarget :[join [lrange $HoroLenght $i [expr {$i + ($Horoscope::HoroWordsInLineLen - 1)}]]]"
				} {
					puthelp "PRIVMSG $HoroTarget :[join [lrange $HoroLenght $i [expr {$i + ($Horoscope::HoroWordsInLineLen - 1)}]]]"
				}
			}
		}
	}

	proc HoroCleanUp HoroHTMLs { 
       regsub -all -- {<i class="icon-star-filled highlight"></i>} $HoroHTMLs \00307$Horoscope::UnicodeBlackStar\003 HoroHTMLs 
       regsub -all -- {<i class="icon-star-filled"></i>} $HoroHTMLs \00314$Horoscope::UnicodeWhiteStar\003 HoroHTMLs 
       #regsub -all -- {(:?<strong>|</strong>|<b>|</b>)} $HoroHTMLs \002 HoroHTMLs 
       regsub -all -- {(:?<h4>|</h4>)} $HoroHTMLs \002 HoroHTMLs 
       regsub -all -- {<p>([^\s]*)} $HoroHTMLs \00304\\0\003  HoroHTMLs 
       regsub -all -- "<.+?>" $HoroHTMLs {} HoroHTMLs 
       regsub -all -- {\s+} $HoroHTMLs " " HoroHTMLs 
       return [string trim $HoroHTMLs] 
    } 

	proc FetchDisHoros Link4Horo {
		if {[catch { set TokenHoro [geturl $Link4Horo -timeout [expr {round(1000 * $Horoscope::TimeOutHoro)}]] } HoroErrorMsg]} {
			putcmdlog "[file tail [info script]]: [string map {\n " "} $HoroErrorMsg]"
		}
		if {[string equal -nocase [status $TokenHoro] ok] && [ncode $TokenHoro] == 200} {
			set TheHoroData [data $TokenHoro]
		} else {
			putcmdlog "[file tail [info script]]: [status $TokenHoro] , [code $TokenHoro]"
		};
		cleanup $TokenHoro
		if {[info exists TheHoroData] && [string length $TheHoroData]} {
			return [mapEscapes $TheHoroData]
		} else {
			putcmdlog "[file tail [info script]]: Got no any data from: $Link4Horo"
		}
	}
}
Life iS Just a dReaM oN tHE wAy to DeaTh
Post Reply