All pastes #615077 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-11 22:29 UTC
rendered paste body
on *:sockread:weather*: {
  sockread %temp
  if (">Updated isin %temp) {
    set %we.update $nohtml(%temp) | haltdef
  }
  if (</B></TD> isin %temp) { 
    if ( isin $nohtml(%temp)) {
      set %we.cond $remove($nohtml(%temp),$chr(9)) | haltdef
    }
  }
  if (ALIGN="left"><H2 CLASS="moduleTitleBar"><B>Right Now for</B><BR> isin %temp) { 
    set %we.loc $remove($remove($gettok($nohtml(%temp),3-,32),for),Save this Location) | haltdef
  }
  if (Feels Like isin %temp) { 
    set %we.temp $remove($nohtml(%temp),$chr(9)) | set %we.temperature $remove($replace($gettok(%we.temp,1,32),&deg;, $+ $chr(176)),Feels) | set %we.feelslike $chr(40) $+ feels like $replace($gettok(%we.temp,3,32),&deg;, $+ $chr(176)) $+ $chr(41) | haltdef
  }
  if (*CLASS="obsTextA">*%</td>* iswm %temp) {
    set %we.hum %temp | set %we.humidity $gettok($gettok(%we.hum,2,62),1,60) | haltdef 
  }
  if (*CLASS="obsTextA">*mph</td>* iswm %temp) {
    set %we.wind %temp | set %we.windex $gettok($gettok(%we.wind,2,62),1,60) | haltdef
  }
  if (*CLASS="obsTextA">*&deg;*</td>* iswm %temp) {
    set %we.dew %temp | set %we.dewpoint $replace($gettok($gettok(%we.dew,2,62),1,60),&deg;, $+ $chr(176)) | haltdef
  }
  if (sunrise: isin %temp) {
    set %we.sunrise $remove($nohtml(%temp),$chr(9),sunrise:)
  }
  if (sunset: isin %temp) {
    set %we.sunset $remove($nohtml(%temp),$chr(9),sunset:)
  }
  if (*CLASS="obsTextA">*miles</td>* iswm %temp) {
    set %we.vis %temp | set %we.visibility $gettok($gettok(%we.vis,2,62),1,60) | haltdef
  }
}

on *:SOCKCLOSE:weather*:{
  msg %we.chan 4,1 [^B] $+ %we.loc $+ [^B]: %we.temperature %we.feelslike - [^B]Conditions[^B]: %we.cond - [^B]Humidity[^B]: %we.humidity - [^B]Visibility[^B]: %we.visibility - [^B]Wind[^B]: %we.windex - [^B]Dew Point[^B]: %we.dewpoint - [^B]Sunrise[^B]: %we.sunrise - [^B]Sunset[^B]: %we.sunset - $chr(40) $+ %we.update $+ $chr(41) - [^B]www.weather.com[^B] | unset %we.  | unset %temp 
}

alias -l nohtml {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}

on *:TEXT:!weather *:#:{
  if ($2 isnum) && ($len($2) == 5) {
  /weather $2 | set %we.chan $chan }
  else {
    msg $chan Incorrect zip code format.
  }
}