Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. ##############################################################################################
  2. ## ## Horoscope.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
  3. ##############################################################################################
  4. ## To use this script you must set channel flag +horo (ie .chanset #chan +horo) ##
  5. ##############################################################################################
  6. ##############################################################################################
  7. ## ____ __ ########################################### ##
  8. ## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
  9. ## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
  10. ## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
  11. ## /___/ /___/ /_/ ########################################### ##
  12. ## ########################################### ##
  13. ##############################################################################################
  14. ## ## Start Setup. ## ##
  15. ##############################################################################################
  16. package require http
  17. package require tls
  18. ## Change the character between the "" below to change the command character/trigger. ##
  19. set horoscopecmdchar "!"
  20. proc horoscope {nick host hand chan search} {
  21. if {[lsearch -exact [channel info $chan] +horo] != -1} {
  22. ## Change the characters between the "" below to change the logo shown with each result. ##
  23. set horoscopelogo "\002\00314H\0034o\0038r\00314o\0039s\0034c\00314o\0038p\0039e\002\003"
  24. ## Change the format codes between the "" below to change the color/state of the text. ##
  25. set textf "\0034"
  26. ##############################################################################################
  27. ## ## End Setup. ## ##
  28. ##############################################################################################
  29. set horoscopesite "http://www.margriet.nl"
  30. set horoscopesign [getsign $search]
  31. if {$horoscopesign == "error"} {
  32. putserv "PRIVMSG $chan :$horoscopelogo Valid signs are: Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn."
  33. } else {
  34. set horoscopeurl /horoscoop/${horoscopesign}/
  35. set horoscopefound ""
  36. ::http::register https 443 tls::socket
  37. ::http::config -accept "text/html" -useragent "firefox"
  38. set horoscopetoken [::http::geturl ${horoscopesite}${horoscopeurl}]
  39. set horoscopevar [::http::data $horoscopetoken]
  40. ::http::cleanup $horoscopetoken
  41. ::http::unregister https
  42. if {[regexp {<div class="astro-tab-body">(.*?)<\/div>} $horoscopevar match horoscoperesult]} {
  43. set horoscoperesult [textsplit $horoscoperesult. 50]
  44. set counter 0
  45. while {$counter <= [llength $horoscoperesult]} {
  46. if {[lindex $horoscoperesult $counter] != ""} {
  47. putserv "PRIVMSG $chan :$horoscopelogo $textf[lindex $horoscoperesult $counter]"
  48. }
  49. incr counter
  50. }
  51. }
  52. }
  53. }
  54. }
  55. proc textsplit {text limit} {
  56. set text [split $text " "]
  57. set tokens [llength $text]
  58. set start 0
  59. set return ""
  60. while {[llength [lrange $text $start $tokens]] > $limit} {
  61. incr tokens -1
  62. if {[llength [lrange $text $start $tokens]] <= $limit} {
  63. lappend return [join [lrange $text $start $tokens]]
  64. set start [expr $tokens + 1]
  65. set tokens [llength $text]
  66. }
  67. }
  68. lappend return [join [lrange $text $start $tokens]]
  69. return $return
  70. }
  71. proc getsign {text} {
  72. if {[regexp -nocase {^wat} $text]} { return waterman
  73. } elseif {[regexp -nocase {^vis} $text]} { return vissen
  74. } elseif {[regexp -nocase {^ram} $text]} { return ram
  75. } elseif {[regexp -nocase {^sti} $text]} { return stier
  76. } elseif {[regexp -nocase {^twe} $text]} { return tweelingen
  77. } elseif {[regexp -nocase {^cra} $text]} { return crab
  78. } elseif {[regexp -nocase {^lee} $text]} { return leeuw
  79. } elseif {[regexp -nocase {^maa} $text]} { return maagd
  80. } elseif {[regexp -nocase {^wee} $text]} { return weegschaal
  81. } elseif {[regexp -nocase {^sco} $text]} { return scorpion
  82. } elseif {[regexp -nocase {^boo} $text]} { return boogschutter
  83. } elseif {[regexp -nocase {^ste} $text]} { return steenbok
  84. } else { return "error" }
  85. }
  86. bind pub - ${horoscopecmdchar}horo horoscope
  87. setudef flag horo
  88. putlog "\017\002Horoscope Script by Ford_Lawnmower successfully loaded!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement