Aether's Horoscope Finder — File Browser

AethersHoroscopeFinderv1.4 / AethersHoroscopeFinderv1.4 / horoscope.mrc

horoscope.mrc — 7.48 KB — Download this file

; Horoscopes.Astrology.Com addon
;
alias horoscope {
  if ($1 == unload) { .unload -rs $+(",$script,") }
  else {
    if (!$dialog(horoscope)) { dialog -md horoscope horoscope }
    else { dialog -v horoscope }
  }
}
dialog horoscope {
  title "Aether's Horoscope Finder v1.4"
  size -1 -1 232 87
  option dbu
  combo 2, 20 2 60 74, size drop
  edit "", 3, 4 38 220 43, read multi return autovs
  text "Horoscope:", 4, 6 30 45 8
  button "Get Horoscope", 5, 179 1 47 12, default
  text "Sign", 1, 6 3 11 8
  text "Type", 8, 82 3 14 8
  combo 9, 95 2 60 74, size drop
  menu "Quit", 6
  item "Unload", 529, 6
  item "Quit", 7, 6, ok cancel
}
menu status,menubar,channel {
  Horoscope Finder:horoscope
  -
}
on *:LOAD: {
  echo -a ^- Welcome -^
  echo -a Aether's Horoscope Finder finds horoscopes on Astrology.com
  echo -a To launch the dialog type in: /horoscope
  echo -a To turn the trigger for chatrooms on/off type in /horotrig, The trigger is !horoscope [sign] [type]
  echo -a You can unload horoscope finder by typing in "/horoscope unload"
}
on *:UNLOAD: {
  echo -a Aether's Horoscope Finder, Now unloaded
  unset %_horo.*
}
alias horotrig {
  if ($group(#bothorotrigger) == on) { echo -a Trigger turned off | .disable #bothorotrigger }
  else { echo -a Trigger turned on | .enable #bothorotrigger }
}
#bothorotrigger on

;######### BEGINNING OF BOT CODE #################;
;# You can copy the code below and place it in your bot
;#################################################;
alias bothoro {
  .notice %_horo.nick.trig Connection was timed out... We could not find your horoscope
  bothoroclear
}
alias bothoroclear {
  set %_horo.inuse.trig 0
  set %_horo.nick.trig
  set %_horo.sign.trig
  set %_horo.type.trig
  sockclose bothoro
  halt
}
on *:TEXT:!horoscope*:# {
  if (!$2) {
    .notice $nick Aether's Horoscope Finder:
    .notice $nick Type in: !horoscope [sign] [type]
    .notice $nick Signs are: Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scropio, Sagittarius, Capricorn, Aquaris, Pisces
    .notice $nick Types are: Daily, Extended, Single's Love, Couple's Love, Teen, Work, Flirt, Quick
  }
  if ($2 && !$3) { .notice $nick Please use !horoscope $2 [type] | .notice $nick Types are: Daily, Extended, Single's Love, Couple's Love, Teen, Work, Flirt, Quick }
  elseif ($3) {
    if (%_horo.inuse.trig == 1) { .notice $nick Sorry, But Somebody else is already looking up a horoscope. | halt }
    
    if ($left($2,2) == Ar) { set %_horo.sign.trig aries }
    elseif ($left($2,2) == Ta) { set %_horo.sign.trig taurus }
    elseif ($left($2,2) == Ge) { set %_horo.sign.trig gemini }
    elseif ($left($2,3) == Can) { set %_horo.sign.trig cancer }
    elseif ($left($2,2) == Le) { set %_horo.sign.trig leo }
    elseif ($left($2,2) == Vi) { set %_horo.sign.trig virgo }
    elseif ($left($2,2) == Li) { set %_horo.sign.trig libra }
    elseif ($left($2,2) == Sc) { set %_horo.sign.trig scorpio }
    elseif ($left($2,2) == Sa) { set %_horo.sign.trig sagittarius }
    elseif ($left($2,3) == cap) { set %_horo.sign.trig capricorn }
    elseif ($left($2,2) == Aq) { set %_horo.sign.trig aquarius }
    elseif ($left($2,2) == pi) { set %_horo.sign.trig pisces }
    else { set %_horo.sign.trig invalid }
    
    if ($left($3,2) == Da) { set %_horo.type.trig Daily }
    elseif ($left($3,2) == Ex) { set %_horo.type.trig Extended }
    elseif ($left($3,2) == Si) { set %_horo.type.trig Single's Love }
    elseif ($left($3,2) == Co) { set %_horo.type.trig Couple's Love }
    elseif ($left($3,2) == Te) { set %_horo.type.trig Teen }
    elseif ($left($3,2) == Wo) { set %_horo.type.trig Work }
    elseif ($left($3,2) == Fl) { set %_horo.type.trig Flirt }
    elseif ($left($3,2) == Qu) { set %_horo.type.trig Quick }
    else { set %_horo.type.trig invalid }
    
    if (%_horo.sign.trig == invalid) { .notice $nick Invalid Sign $2 $+ ... | halt }
    if (%_horo.type.trig == invalid) { .notice $nick Invalid Type $3-4 $+ ... | halt }
    
    set %_horo.inuse.trig 1
    set %_horo.nick.trig $nick
    
    sockclose bothoro
    sockopen bothoro horoscopes.astrology.com 80
    
    .notice $nick [Aether's] Horoscope [Finder]... Searching...
    .timer-bothoro 1 45 bothorotimeout
    
  }
}
on *:sockopen:bothoro: {
  sockwrite -n $sockname GET /daily $+ $botchhorotype($lower(%_horo.type.trig)) $+ $lower(%_horo.sign.trig) $+ .html HTTP/1.0
  sockwrite -n $sockname Host: horoscopes.astrology.com $+ $CRLF $+ $CRLF
  
  .notice %_horo.nick.trig We are now connecting to the site, We are retriving your horoscope. Please wait....
}

on *:sockread:bothoro: {
  .timer-bothoro off
  if ($sockerr > 0) { .notice %_horo.nick.trig There has been an error... We could not retrive your horoscope. Sorry | bothoroclear }
  else {
    var %horo |  sockread %horo
    if (<daily_horoscope> isin %horo) {
      sockread %horo
      .notice %_horo.nick.trig Your Horoscope | .notice %_horo.nick.trig $botstrip(%horo)
      bothoroclear
    }
  }
}
alias -l botstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
alias -l botchhorotype { return $replace($1-,Daily,$null,Extended,long,Single's Love,singles,Couple's Love,rom,Teen,teen,Work,tech,Flirt,funflirty,Quick,quick) }
;############# END COPING OF BOT CODE ################;

#bothorotrigger end


on *:dialog:horoscope:close: { sockclose horo.get.daily }
on *:dialog:horoscope:init:0 {
  did -r $dname 2,3,9 | didtok $dname 2 44 Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Capricorn,Aquarius,Pisces | did -c $dname 2 1
  didtok $dname 9 44  Daily,Extended,Single's Love,Couple's Love,Teen,Work,Flirt,Quick | did -c $dname 9 1
}
on *:dialog:horoscope:menu:529 { var %y = $?!="Are you sure you want to unload?" | if (%y == $true) { horoscope unload } }

on *:dialog:horoscope:sclick:* {
  if ($did == 5) {
    set %_horo.sign $lower($did($dname,2).seltext)
    set %_horo.type $chhorotype($lower($did($dname,9).seltext))
    gethoro %_horo.sign
  }
}
alias striphtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
alias chhorotype { return $replace($1-,Daily,$null,Extended,long,Single's Love,singles,Couple's Love,rom,Teen,teen,Work,tech,Flirt,funflirty,Quick,quick) }
;# /gethoro [sign] [type]
alias gethoro {
  var %signs = Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Capricorn,Aquarius,Pisces
  var %types = Daily,Extended,Single's Love,Couple's Love,Teen,Work,Flirt,Quick
  if ($1 != $matchtok(%signs,$1,1,44) || $2 != $matchtok(%types,$2-,1,44)) { echo $color(info) -s Horoscope: Invalid Sign or Type }
  else {
    if ($dialog(horoscope)) {
      sockclose horo.get.daily
      sockopen horo.get.daily horoscopes.astrology.com 80
      did -ra horoscope 3 Connecting to Site...
    }
    else { sockclose horo.get.daily }
  }
}
on *:sockopen:horo.get.daily: {
  sockwrite -n $sockname GET /daily $+ %_horo.type $+ %_horo.sign $+ .html HTTP/1.0
  sockwrite -n $sockname Host: horoscopes.astrology.com $+ $CRLF $+ $CRLF
}

on *:sockread:horo.get.daily: {
  if ($sockerr > 0) {
    if ($dialog(horoscope)) { did -ra horoscope 3 An error has occured | sockclose $sockname }
    else { sockclose $sockname }
  }
  else {
    var %horo |  sockread %horo
    if (<daily_horoscope> isin %horo) {
      sockread %horo
      $iif($dialog(horoscope),did -ra horoscope 3 $striphtml(%horo),return)
      sockclose $sockname
    }
  }
}