Weather script for mIRC

By eqrunner on Dec 10, 2009

Screenshots

READ FIRST:
Current script does not work. And is currently ARCHIVED. wunderground stopped supporting api. And I need to find a new api service to use. ETA is unknown due to my busy scheduled. Ill will let everyone know if I make any progress.

VERSION 5.0 AND UP NOTICE: Script now REQUIRES an API key. You must get your own key in order for you to use version 5.0 and up.
Go to http://www.wunderground.com/weather/api/ and sign up for free. Follow the steps to create a API Key ID. When complete, Insert it into the code below in the 'Preparation' section set %wu_api
wundergoround is phasing out their old xml site and up to Version 4.0 held on as long as possible. The script has been updated to work with wundergrounds new API. I can not give out my API key due to the limit of hits my API key can take before billing gets involved. Sorry for the inconvenience.
/READ FIRST.

Weather Bot Script. Does !WEATHER - !CURRENT - !FORECASTS - !ALERTS - !TIME - !ALMANAC WorldWide coverage.

I built a Weather bot script for that gets its data from wunderground.com site for mIRC. It allows the ability to get the weather, forecasts, alerts, and time from around the world.

I did see there was one for php but needed one for mIRC. weather.com only accepts US zipcodes, and there are users from across the world. This will work with US and outside zipcodes (ex: e2l1n5) or city and state (dallas,tx) or city,country (Sydney,AU or Sydney, Australia) and airports (LAX)

Commands:
!w or !weather [zipcode|city,state|city,country|airport] = will return weather current conditions.
!current [zipcode|city,state|city,country|airport] = will return current conditions.
!forecast [zipcode|city,state|city,country|airport] = will give detailed 3 day forecast (for us)
!forecast5 [zipcode|city,state|city,country|airport] = will send 5 day forecast to $nick that requested. (to prevent chan flooding)
!alerts [zipcode|city,state|city,country|airport] = will tell you if there are any weather alerts in your area.
!alertinfo [zipcode|city,state|city,country|airport] = will send $nick the detailed report of alerts in said area
!time [zipcode|city,state|city,country|airport] = will return current time.
!almanac = Will give almanac records
!moon or !moonphase = Will give the status of the moon

Script uses 1 socket for all above commands, but each command links to slightly different xml page.
It is setup right now to grab all the data from the xml page and set them to all to corresponding variables.(long list of if statements) To view what it returns, just comment out the unset %wu_* at the bottom of the script. execute the script (ex: !weather 90210) and then look at your variables.

on sockclose you will find a lot of $+ and $chr(##) actions. This is to squish the results together and to add items like °F ($chr(176),F) or I have spacers like -|- ($chr(45) $+ $chr(124) $+ $chr(45))
ex: msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(40),%wu_temp_c,$chr(176),C,$chr(41))
gives you City,State: Overcast and 34°F(1°C)

Revisions noted in bottom of script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; weather underground for mIRC ;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;by eqrunner ;;v5.41;
;;;;;;http://www.hawkee.com/snippet/7010/;;;;;;;;;;;

ARCHIVED

/*
-- REQUIRMENTS --
- YOU MUST HAVE AN API CODE TO USE USE VERSION 5.0 AND ABOVE
- Go to http://www.wunderground.com/weather/api/ and sign up for free. 
- Follow the steps to create a API Key ID. 
- When complete, Insert it into the code below in the 'Preperation' section set %wu_api

-- COMMANDS --
!w  or !weather [zipcode|city,state|city,country|airport] = will return weather current conditions.
!current [zipcode|city,state|city,country|airport] = will return current conditions.
!forecast [zipcode|city,state|city,country|airport] = will give detailed 3 day forecast (for us)
!forecast[1-10] [zipcode|city,state|city,country|airport] = will send from 1 day up to 10 day forecast to $nick that requested. (to prevent chan flooding)
!alerts [zipcode|city,state|city,country|airport] = will tell you if there are any weather alerts in your area.
!alertinfo [zipcode|city,state|city,country|airport] = will send $nick the detailed report of alerts in said area
!time [zipcode|city,state|city,country|airport] = will return current time.
!almanac [zipcode|city,state|city,country|airport] = will return the record highs and lows.

-- REGISTER --
Register - Each user can assign a default location with themself. So in the future they can use just the command ( !weather, or !forecast, or !alerts, etc)
![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REGISTER [zipcode|city,state|city,country|airport] = will link user to said default location
![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REGISTER [zipcode|city,state|city,country|airport] = will CHANGE users default if they already have registured.
![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REMOVE = will remove the users default location
User can use any of the !commands to registure. !weather register 90210, will work just as well as !time register 90210

-- HELP --
![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] [?|help] = Will message user the list of above commands just as they are written.

-- Switch --
![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] [ON|OFF] = Will turn the script ON or OFF. Currently only set for Ops only.

-- NOTES-
Notes from wunderground:
We don't support old style abbreviations like Conn. for Connecticut, use CT
If you are searching for an international city, try the name of the country or province
Don't use provinces for non-us cities (ie: Vancouver, BC)
Zipcodes only work in Canada, UK and the US
*/

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:CONNECT: {
  if ($hget(wu_reg) == $null) { hmake wu_reg 100 }
  if ($isfile(wu_reg.dat)) { hload wu_reg wu_reg.dat }
}
ON *:DISCONNECT: {
  if ($hget(wu_reg)) { hsave -o wu_reg wu_reg.dat }
}

on $*:INPUT:#: {
  if ($regex($1,/^[!](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac|moon|moonphase)?/Si)) wunderground $1-
}

on $*:text:/^[!](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac|moon|moonphase)/Si:#: {
  wunderground $1-
}

;-----------------------------------------------------------------------------
; Preperation
;-----------------------------------------------------------------------------

alias wunderground {
  ;botabuse 
  unset %wu_*

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;--- Preperation. Sets up all the variables needed for the script ---
  set %wu_command $1
  set %wu_2 $2
  set %wu_location $2-
  set %wu_3 $3
  set %wu_3_long $3-
  set %wu_nick $nick
  set %wu_network $network
  set %wu_chan $chan
  set %wu_host api.wunderground.com

  ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  set %wu_api YourAPICodeGoesHere
  ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ; Option to Change ! to something else. Simply remove the ; comment and change this to reflect your new command
  ; Displayed is for users who want to use the Period (.) $chr(46)
  ; Below command does this: Replace(%wu_command, "replace .", "with a !")
  ;set %wu_command $replace(%wu_command,$chr(46),$chr(33))

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;--- Registration Check. Checks to see if the $nick already has a 'default' location on file ---
  if ($2 == $null) { 
    if ($hget(wu_reg,%wu_nick) != $null) {
      set %wu_location $hget(wu_reg,%wu_nick)
    }
    if ($hget(wu_reg,%wu_nick) == $null) {
      .notice $nick Please specify a location $1 [zipcode|city,state|city,country|airport]
      wu_cleanup
    }
  }

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;--- Modify Registration and Help and ON/OFF Switch ---
  if ($2 != $null) {
    if (%wu_2 == register) && (%wu_3 != $null) {
      hadd -m wu_reg %wu_nick %wu_3_long
      .notice %wu_nick You are now linked to %wu_3_long
      set %wu_location $hget(wu_reg,%wu_nick)
      ;echo -s %wu_location
    }
    if (%wu_2 == remove) {
      hdel wu_reg %wu_nick
      .notice %wu_nick Your location association has been removed. 
      wu_cleanup
      halt
    }
    ;;--- Checks to see if the $2 is an already registured nick. ----
    if ($hget(wu_reg,%wu_2) != $null) {
      set %wu_location $hget(wu_reg,%wu_2)
    }
    if (%wu_2 == ?) || (%wu_2 == help) { 
      wu_help 
      wu_cleanup
      halt
    }
    ;;;---Below is used to turn the script on or off, but only if user is an op of a channel ---

    if (%wu_2 == on) || (%wu_2 == off) && (%wu_nick isop %wu_chan) {
      if (%wu_2 == on) {
        set $+(%,wunderground_,%wu_chan) ON
        .notice %wu_nick !weather script is now ON
        wu_cleanup
        halt   
      }
      if (%wu_2 == off) {
        set $+(%,wunderground_,%wu_chan) OFF
        .notice %wu_nick !weather script is now OFF
        wu_cleanup
        halt     
      }
    } ;end of %wu_on/off

    ;--- Default for a channel ---
    if ($2 == shoutdrive) && (%wu_network == iPocalypse) {
      set %wu_location 90046
    } ; end of Default for a channel
    if ($2 == shoutdrive) && (%wu_network == freenode) {
      set %wu_location 90046
    } ; end of Default for a channel

  } ;end of ($2 != $null)

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;--- Checks if wunderground is suppost to be OFF for the channel --
  if ($($+(%,wunderground_,%wu_chan),2) == OFF) {
    wu_cleanup
    halt
  }

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;---Command Prep. Checks command to see which data file it will be pulling from depending on command entered ---
  ;NEW
  ;Reformats City, State to the corrected  /State/City.xml

  if ($chr(44) isin %wu_location) {
    ;set %wu_location_format $+(/,$remove($gettok(%wu_location,2,44),/,$gettok(%wu_location,1,44))
    var %wu_location_city $replace($gettok(%wu_location,1,44),$chr(32),$chr(95))
    var %wu_location_state $remove($gettok(%wu_location,2,44),$chr(32))
    ;echo -s %wu_location_city %wu_location_State
    set %wu_address $+(/,%wu_location_state,/,%wu_location_city)

    ;echo -s %wu_address
    ;wu_cleanup
    ;halt
  }
  if ($chr(44) !isin %wu_location) {
    set %wu_address $replace(%wu_location,$chr(32),$chr(95))
    ;echo -s %wu_address
    ;wu_cleanup
    ;halt
  }
  ;/NEW

  ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  ;-- Sets specific %wu_links depending on what is requested.

  ;-- Weather --
  if (%wu_command == !w )  set %wu_command !weather
  if (%wu_command == !weather) || (%wu_command == !current) || (%wu_command == !time) { 
    ;Eample: set %wu_link $+(/api/154dfe245e155eee1/conditions/q/20721.xml)
    set %wu_link $+(/api/,%wu_api,/conditions/q/,%wu_address,.xml)
  }
  ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  ;-- Forecast --
  ;- Below finds out if it is a !forecast or a !forecast[1-10]. If there is a number,
  ;  then it strips the number and sets %wu_command back to !forecast5 so remainder of the code
  ;  works. and creates a %wu_forecast_count to be used after the sock closes.

  if ($left(%wu_command,9) == !forecast) {
    if ($mid(%wu_command,10,0) > 0)  {
      set %wu_forecast_count $remove(%wu_command,!forecast)
      ; ^ removes !forecast, leaving only the number
      if (%wu_forecast_count > 10) set %wu_forecast_count 10
      ; ^ If number is greater than 10. Changes it to 10. (no one wants 999 days of forecast)
      set %wu_command !forecast5
      ; ^ resets %wu_command back to !forecast5 so the rest of the code works.
    }
  }

  if (%wu_command == !forecast) || (%wu_command == !forecast5) { 
    set %wu_link $+(/api/,%wu_api,/forecast10day/q/,%wu_address,.xml)
  }

  ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  ;-- Alerts --
  if (%wu_command == !alert) set %wu_command !alerts
  if (%wu_command == !alertsinfo) set %wu_command !alertinfo
  if (%wu_command == !alerts) || (%wu_command == !alertinfo) { 
    set %wu_link $+(/api/,%wu_api,/alerts/q/,%wu_address,.xml)
    set %wu_a_count 0
  }
  ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  ;-- Almanac --
  if (%wu_command == !almanac) { 
    set %wu_link $+(/api/,%wu_api,/almanac/q/,%wu_address,.xml)
  }
  ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  ;-- Moon --
  if (%wu_command == !moonphase) set %wu_command !moon
  if (%wu_command == !moon) { 
    set %wu_link $+(/api/,%wu_api,/astronomy/q/,%wu_address,.xml)
  }

  sockopen wunderground %wu_host 80
  ;echo -s LINK: %wu_link
}

;-----------------------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
; SOCKETS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;-----------------------------------------------------------------------------

on *:sockopen:wunderground: {
  sockwrite -n $sockname GET %wu_link HTTP/1.1
  sockwrite -n $sockname Host: %wu_host
  sockwrite -n $sockname $crlf

}

;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

on *:sockread:wunderground: {
  sockread %wu_temp
  if ($regex(%wu_temp,/([[:xdigit:]]{2});/)) {
    set %wu_temp $replace(%wu_temp,$+(&#x,$regml(1),;),$chr($base($regml(1),16,10)))
  }
  set %wu_temp $regsubex(%wu_temp,/[\46\43](\d+)\73/g,$chr(\1))
  set %wu_temp $replacex(%wu_temp,&quot;,",&amp;lt;,<,&amp;rt;,>,&amp;deg;,°,&amp;,&)
  if (<name> isin %wu_temp) && (%wu_name == $null) %wu_name = $remove(%wu_temp,<name>,</name>,$chr(9))

  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  ;checks for an error
  if (<error> isin %wu_temp) set %wu_error Error
  if (%wu_error == Error) && (<description> isin %wu_temp) {
    set %wu_error_description $remove(%wu_temp,<description>,</description>,$chr(9))
  }

  if (<results> isin %wu_temp) set %wu_results ON
  if (%wu_results == ON) {
    if (<result> isin %wu_temp) inc %wu_result_count 
    if (<city> isin %wu_temp) set $+(%,wu_result_city,%wu_result_count) $remove(%wu_temp,<city>,</city>,$chr(9))
    if (<state> isin %wu_temp) set $+(%,wu_result_state,%wu_result_count) $remove(%wu_temp,<state>,</state>,$chr(9))
    if (<country_name> isin %wu_temp) set $+(%,wu_result_country_name,%wu_result_count) $remove(%wu_temp,<country_name>,</country_name>,$chr(9))

  }

  ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

  ;set %wu_temp $regsubex(%wu_temp,/&#(\d+)\;/g,$chr(\1))
  ;echo -s %wu_temp

  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;--- Variables for Weather, Current and Time Command ---
  if (%wu_command == !weather) || (%wu_command == !current) || (%wu_command == !time) { 
    ; local info
    if (<full> isin %wu_temp) && (%wu_full == $null) %wu_full = $remove(%wu_temp,<full>,</full>,$chr(9)) 
    if (<city> isin %wu_temp) && (%wu_city == $null) %wu_city = $remove(%wu_temp,<city>,</city>,$chr(9)) 
    if (<state> isin %wu_temp) && (%wu_state == $null) %wu_state = $remove(%wu_temp,<state>,</state>,$chr(9)) 
    if (<state_name> isin %wu_temp) && (%wu_state_name == $null) %wu_state_name = $remove(%wu_temp,<state_name>,</state_name>,$chr(9)) 
    if (<country> isin %wu_temp) && (%wu_country == $null)  %wu_country = $remove(%wu_temp,<country>,</country>,$chr(9)) 
    if (<country_iso3166> isin %wu_temp) && (%wu_country_iso3166 == $null) %wu_country_iso3166 = $remove(%wu_temp,<country_iso3166>,</country_iso3166>,$chr(9)) 
    if (<zip> isin %wu_temp) && (%wu_zip == $null)  %wu_zip = $remove(%wu_temp,<zip>,</zip>,$chr(9)) 
    if (<latitude> isin %wu_temp) && (%wu_latitude == $null) %wu_latitude = $remove(%wu_temp,<latitude>,</latitude>,$chr(9)) 
    if (<longitude> isin %wu_temp) && (%wu_longitude == $null) %wu_longitude = $remove(%wu_temp,<longitude>,</longitude>,$chr(9)) 
    if (<elevation> isin %wu_temp) && (%wu_elevation == $null) %wu_elevation = $remove(%wu_temp,<elevation>,</elevation>,$chr(9)) 

    ;; NO LONGER if (<local_time> isin %wu_temp) %wu_local_time = $remove(%wu_temp,<local_time>,</local_time>,$chr(9)) 
    if (<local_time_rfc822> isin %wu_temp) %wu_local_time_rfc822 = $remove(%wu_temp,<local_time_rfc822>,</local_time_rfc822>,$chr(9)) 

    ; current weather
    if (<weather> isin %wu_temp) %wu_weather = $remove(%wu_temp,<weather>,</weather>,$chr(9)) 
    if (<temperature_string> isin %wu_temp) %wu_temperature_string = $remove(%wu_temp,<temperature_string>,</temperature_string>,$chr(9)) 
    if (<temp_f> isin %wu_temp) %wu_temp_f = $remove(%wu_temp,<temp_f>,</temp_f>,$chr(9))
    if (<temp_c> isin %wu_temp) %wu_temp_c = $remove(%wu_temp,<temp_c>,</temp_c>,$chr(9)) 
    if (<relative_humidity> isin %wu_temp) %wu_relative_humidity = $remove(%wu_temp,<relative_humidity>,</relative_humidity>,$chr(9)) 

    ; wind
    if (<wind_string> isin %wu_temp) %wu_wind_string = $remove(%wu_temp,<wind_string>,</wind_string>,$chr(9)) 
    if (<wind_dir> isin %wu_temp) %wu_wind_dir = $remove(%wu_temp,<wind_dir>,</wind_dir>,$chr(9)) 
    if (<wind_degrees> isin %wu_temp) %wu_wind_degrees = $remove(%wu_temp,<wind_degrees>,</wind_degrees>,$chr(9)) 
    if (<wind_mph> isin %wu_temp) %wu_wind_mph = $remove(%wu_temp,<wind_mph>,</wind_mph>,$chr(9)) 
    if (<wind_gust_mph> isin %wu_temp) %wu_wind_gust_mph = $remove(%wu_temp,<wind_gust_mph>,</wind_gust_mph>,$chr(9)) 

    if (<pressure_string> isin %wu_temp) %wu_pressure_string = $remove(%wu_temp,<pressure_string>,</pressure_string>,$chr(9)) 
    if (<pressure_mb> isin %wu_temp) %wu_pressure_mb = $remove(%wu_temp,<pressure_mb>,</pressure_mb>,$chr(9))
    if (<pressure_in> isin %wu_temp) %wu_pressure_in = $remove(%wu_temp,<pressure_in>,</pressure_in>,$chr(9))
    if (<dewpoint_string> isin %wu_temp) %wu_dewpoint_string = $remove(%wu_temp,<dewpoint_string>,</dewpoint_string>,$chr(9))
    if (<dewpoint_f> isin %wu_temp) %wu_dewpoint_f = $remove(%wu_temp,<dewpoint_f>,</dewpoint_f>,$chr(9))
    if (<dewpoint_c> isin %wu_temp) %wu_dewpoint_c = $remove(%wu_temp,<dewpoint_c>,</dewpoint_c>,$chr(9))

    if (<heat_index_string> isin %wu_temp) %wu_heat_index_string = $remove(%wu_temp,<heat_index_string>,</heat_index_string>,$chr(9))
    if (<heat_index_f> isin %wu_temp) %wu_heat_index_f = $remove(%wu_temp,<heat_index_f>,</heat_index_f>,$chr(9))
    if (<heat_index_c> isin %wu_temp) %wu_heat_index_c = $remove(%wu_temp,<heat_index_c>,</heat_index_c>,$chr(9))
    if (<windchill_string> isin %wu_temp) %wu_windchill_string = $remove(%wu_temp,<windchill_string>,</windchill_string>,$chr(9))
    if (<windchill_f> isin %wu_temp) %wu_windchill_f = $remove(%wu_temp,<windchill_f>,</windchill_f>,$chr(9))
    if (<windchill_c> isin %wu_temp) %wu_windchill_c = $remove(%wu_temp,<windchill_c>,</windchill_c>,$chr(9))

    if (<visibility_mi> isin %wu_temp) %wu_visibility_mi = $remove(%wu_temp,<visibility_mi>,</visibility_mi>,$chr(9))
    if (<visibility_km> isin %wu_temp) %wu_visibility_km = $remove(%wu_temp,<visibility_km>,</visibility_km>,$chr(9))
  }

  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;--- Variables for Forecast Command ---
  if (%wu_command == !forecast) || (%wu_command == !forecast5) {
    if (<simpleforecast> isin %wu_temp) set %wu_period 1
    set %wu_temp $remove(%wu_temp,<![CDATA[,]]>)
    if (<period> isin %wu_temp) set %wu_period $remove(%wu_temp,<period>,</period>,$chr(9),$chr(32))

    ;-- Detailed Forecast ---
    if (%wu_command == !forecast) {
      if (<title> isin %wu_temp) set $+(%,wu_df_title_,%wu_period) $remove(%wu_temp,<title>,</title>,$chr(9))
      if (<fcttext> isin %wu_temp) set $+(%,wu_df_fcttext_,%wu_period) $remove(%wu_temp,<fcttext>,</fcttext>,$chr(9))
      if (<fcttext_metric> isin %wu_temp) set $+(%,wu_df_fcttext_metric_,%wu_period) $remove(%wu_temp,<fcttext_metric>,</fcttext_metric>,$chr(9))
      if (<pop> isin %wu_temp) set $+(%,wu_df_pop_,%wu_period) $remove(%wu_temp,<pop>,</pop>,$chr(9))
      ; pop = possibility of precipitation 
    }

    ;-- Simple Forecast ---
    if (%wu_command == !forecast5) {
      if (<simpleforecast> isin %wu_temp) set %wu_period 1
      ;-- ^ Resets %wu_period to 1 when entering the <simpleforecast> section
      if (</forecastday> isin %wu_temp) inc %wu_period
      ;-- ^ Need the increase becasue the <period> is after the <weekday>

      if (<weekday> isin %wu_temp) set $+(%,wu_sf_weekday_,%wu_period) $remove(%wu_temp,<weekday>,</weekday>,$chr(9))
      if (<high> isin %wu_temp) set %wu_sf_temp high
      if (<low> isin %wu_temp) set %wu_sf_temp low
      if (<fahrenheit> isin %wu_temp) set $+(%,wu_sf_fahrenheit_,%wu_sf_temp,_,%wu_period) $+($remove(%wu_temp,<fahrenheit>,</fahrenheit>,$chr(9)),$chr(176),F)
      if (<celsius> isin %wu_temp) set $+(%,wu_sf_celsius_,%wu_sf_temp,_,%wu_period) $+($remove(%wu_temp,<celsius>,</celsius>,$chr(9)),$chr(176),C)
      if (<conditions> isin %wu_temp) set $+(%,wu_sf_conditions_,%wu_period) $remove(%wu_temp,<conditions>,</conditions>,$chr(9))
    }

  }
  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;--- Variables for Alerts Command ---
  if (%wu_command == !alerts) || (%wu_command == !alertinfo) { 
    ;echo -s %wu_temp
    ;set -n %wu_ac <alert count="
    ;-- Counts the amount of alerts.
    if (<alert> isin %wu_temp) { inc %wu_a_i | inc %wu_a_count }

    ;-- Writes variables for each alert. 
    if (<type> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_type) $remove(%wu_temp,<type>,</type>,$chr(9)) 
    if (<description> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_description) $remove(%wu_temp,<description>,</description>,$chr(9))
    if (<date> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_date) $remove(%wu_temp,<date>,</date>,$chr(9))
    if (<expires> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_expires) $remove(%wu_temp,<expires>,</expires>,$chr(9))
    if (</message> isin %wu_temp) { set %wu_msg OFF | set $+(%,wu_a,%wu_a_i,_count) $(%wu_msg_c,2) | set %wu_msg_c 0 }
    if (%wu_msg == ON) {
      inc %wu_msg_gc
      inc %wu_msg_c 
      set $+(%,wu_a,%wu_a_i,_message,%wu_msg_c) %wu_temp
    }
    if (<message> isin %wu_temp) { set %wu_msg ON }
  }

  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;---- Variables for Almanac ----
  if (%wu_command == !almanac) {
    if (<error> isin %wu_temp) {
      set %wu_airport $remove(%wu_temp,<airport_code>,</airport_code>,$chr(9))
      if (%wu_airport == $null) {
        set %wu_almanac_error NotFound
        sockclose wunderground
        wu_sockclose
      }
    }
    if (<temp_high> isin %wu_temp) set %wu_almanac_temp high
    if (<temp_low> isin %wu_temp) set %wu_almanac_temp low
    if (<normal> isin %wu_temp) set %wu_almanac_rate normal
    if (<record> isin %wu_temp) set %wu_almanac_rate record
    if (<F> isin %wu_temp)  set $+(%,wu_almanac_,%wu_almanac_rate,_,%wu_almanac_temp,_F) $+($remove(%wu_temp,<F>,</F>,$chr(9)),$chr(176),F)
    if (<C> isin %wu_temp)  set $+(%,wu_almanac_,%wu_almanac_rate,_,%wu_almanac_temp,_C) $+($remove(%wu_temp,<C>,</C>,$chr(9)),$chr(176),C)
    if (<recordyear> isin %wu_temp) set $+(%,wu_almanac_,%wu_almanac_temp,_year) $remove(%wu_temp,<recordyear>,</recordyear>,$chr(9))
  }
  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  ;---- Variables for Moon ----
  if (%wu_command == !moon) {

    if (<percentIlluminated> isin %wu_temp) set %wu_percentIlluminated  $remove(%wu_temp,<percentIlluminated>,</percentIlluminated>,$chr(9))
    if (<ageOfMoon> isin %wu_temp) set %wu_ageOfMoon $remove(%wu_temp,<ageOfMoon>,</ageOfMoon>,$chr(9))

  }
  ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

  ;---- End of xml ----
  if (</response> isin %wu_temp) {
    ; This is so at the end of the reading, it immedely closes the socket and moves on, instead of waiting for the connection to time out.
    ;echo -s ---- wunderground sockclose ----
    sockclose wunderground
    wu_sockclose
  }
}

;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

on *:sockclose:wunderground: {
  ; OLD 
  ; This section has been changed to an alias. 
}

;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
; END SOCKETS
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

;-----------------------------------------------------------------------------
;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
; RESULT
;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
;-----------------------------------------------------------------------------

alias wu_sockclose {
  ;echo -s Result: wu_sockclose
  ;--- Spacers. Such as -|-  |  and -|
  set %wu_space $+($chr(45),$chr(124),$chr(45))
  set %wu_space2 $+($chr(32),$chr(124),$chr(32))
  set %wu_spaceend $+($chr(45),$chr(124))

  ;--- Removes + sign from address variable
  set %wu_address $replace(%wu_address,$chr(43),$chr(32)) 

  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  ; Error? Was there an error?
  if (%wu_error == error) {
    msg %wu_chan Error: %wu_error_description
    wu_cleanup 
    halt
  }

  if (%wu_results == ON) {
    msg %wu_nick %wu_result_count Found. Please be more specific: ---- Type STOP at any time to end ---
    set %wu_results_int 1
    while (%wu_results_int <= %wu_result_count) {
      ;.timer 1  %wu_results_int .msg %wu_nick Option $+(%wu_results_int,$chr(58)) $+($($+(%,wu_result_city,%wu_results_int),2),$chr(44))  $+($($+(%,wu_result_state,%wu_results_int),2),$chr(46)) Country: $+(%,wu_result_country_name,%wu_results_int)
      $+(.,timer_wu_,%wu_nick,_,error_,%wu_results_int) 1 %wu_results_int .msg %wu_nick Option $+(%wu_results_int,$chr(58)) $+($($+(%,wu_result_city,%wu_results_int),2),$chr(44))  $+($($+(%,wu_result_state,%wu_results_int),2),$chr(46)) Country: $+(%,wu_result_country_name,%wu_results_int)

      inc  %wu_results_int
    }
    .timer 1 %wu_results_int wu_cleanup
    halt
  }

  ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

  if (%wu_command == !weather) { 

    msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(47),%wu_temp_c,$chr(176),C)
  }  
  if (%wu_command == !current) { 
    msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(47),%wu_temp_c,$chr(176),C) $&
      $+ %wu_space2 Heat Index: $+(%wu_heat_index_f,$chr(176),F,$chr(47),%wu_heat_index_c,$chr(176),C)$&
      $+ %wu_space2 Winds %wu_wind_string $&
      $+ %wu_space2 Windchill: $+(%wu_windchill_f,$chr(176),F,$chr(47),%wu_windchill_c,$chr(176),C) $&
      $+ %wu_space2 Pressure: $+(%wu_pressure_in,in,$chr(47),%wu_pressure_mb,mb) $&
      $+ %wu_space2 Humidity: %wu_relative_humidity $&
      $+ %wu_space2 Dew: $+(%wu_dewpoint_f,$chr(176),F,$chr(47),%wu_dewpoint_c,$chr(176),C) $&
      $+ %wu_space2 Visiblity: $+(%wu_visibility_mi,mi,$chr(47),%wu_visibility_km,km)
  }
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  if (%wu_command == !time) {
    ; Military time format (Strait from the code):
    msg %wu_chan %wu_full $+ : %wu_local_time_rfc822

    ; Standard time format (modified):
    ;Coming soon, maybe.

  }

  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR  
  ;To Start, Let see if the location accually exists:
  if (%wu_command == !forecast) {
    .timer 1 0 msg %wu_chan %wu_location $+ : %wu_df_title_0 $+ : %wu_df_fcttext_0 %wu_space %wu_df_title_1 $+ : %wu_df_fcttext_1
    .timer 1 1 msg %wu_chan %wu_df_title_2 $+ : %wu_df_fcttext_2 %wu_space %wu_df_title_3 $+ : %wu_df_fcttext_3 
  }

  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  if (%wu_command == !forecast5) {
    ;echo -s %wu_forecast_count

    .timer 1 0 .msg %wu_nick Your forecast for %wu_location

    set %wu_f_i 1
    while (%wu_f_i <= %wu_forecast_count) {
      ; Setup variables
      set %wu_sf_dow $($+(%,wu_sf_weekday_,%wu_f_i),2)
      set %wu_sf_con $($+(%,wu_sf_conditions_,%wu_f_i),2)
      set %wu_sf_fh $($+(%,wu_sf_fahrenheit_high_,%wu_f_i),2)
      set %wu_sf_ch $($+(%,wu_sf_celsius_high_,%wu_f_i),2)
      set %wu_sf_fl $($+(%,wu_sf_fahrenheit_low_,%wu_f_i),2)
      set %wu_sf_cl $($+(%,wu_sf_celsius_low_,%wu_f_i),2)
      ; msg nick: DayOfWeek: CurrentCondition. High: 00°F(00°C) - Low: 00°F(00°C)
      .timer 1 %wu_f_i .msg %wu_nick %wu_sf_dow $+ : %wu_sf_con $+ . High: $+(%wu_sf_fh,$chr(40),%wu_sf_ch,$chr(41)) - Low: $+(%wu_sf_fl,$chr(40),%wu_sf_cl,$chr(41))
      inc %wu_f_i
    }
  }

  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  if (%wu_command == !alerts) {
    ;echo -s --Start of alerts---
    if (%wu_a_count == 0) msg %wu_chan %wu_location $+ : No Alerts
    if (%wu_a_count > 0) {
      msg %wu_chan %wu_location $+ : %wu_a_count Alerts
      var %i 1
      while (%i <= %wu_a_count) {
        .timer 1 %i msg %wu_chan %wu_a_start $($+(%,wu_a,%i,_description),2) till $($+(%,wu_a,%i,_expires),2) %wu_a_end
        inc %i
      }
      .timer 1 %i .notice %wu_nick use $chr(2) !alertinfo $chr(2) [zipcode|city,state|city,country|airport] for alert details
    }
  }
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR  
  if (%wu_command == !alertinfo) {
    if (%wu_a_count == 0) msg %wu_chan %wu_location $+ : No Alerts
    if (%wu_a_count > 0) {
      ;msg %wu_chan %wu_location $+ : %wu_a_count Alerts - See PM for details
      .timer 1 1 .msg %wu_nick %wu_location $+ : %wu_a_count Alerts
      .timer 1 2 .msg %wu_nick Type STOP at any time to end.

      set %wu_alert_total_alerts 1
      ; Used to count the while loops compaired to the origial totall of Alerts
      ; Aka, what Alert are we on. 

      set %wu_alert_timer_msgcount 3
      ; Used to tally the message count used for timers

      while (%wu_alert_total_alerts <= %wu_a_count) {     ;Is the tally of alerts less than or equal to the Total a_counts
        ;echo -s Total Alerts %wu_alert_total_alerts
        set %wu_alert_alert_message 1

        .timer 1 %wu_alert_timer_msgcount .msg %wu_nick $chr(2) $($+(%,wu_a,%wu_alert_total_alerts,_description),2) $chr(2) from $($+(%,wu_a,%wu_alert_total_alerts,_date),2) till $($+(%,wu_a,%wu_alert_total_alerts,_expires),2)
        inc %wu_alert_timer_msgcount

        while (%wu_alert_alert_message <= $($+(%,wu_a,%wu_alert_total_alerts,_count),2)) {
          ;echo -s Total Alert %wu_alert_total_alerts Messages %wu_alert_alert_message
          $+(.,timer_wu_,%wu_nick,_,alert_,%wu_alert_total_alerts,_message,%wu_alert_alert_message) 1 %wu_alert_timer_msgcount .msg %wu_nick $($+(%,wu_a,%wu_alert_total_alerts,_message,%wu_alert_alert_message),2)

          inc %wu_alert_alert_message
          inc %wu_alert_timer_msgcount
        }

        inc %wu_alert_total_alerts
      }
      $+(.,timer_wu_,%wu_nick,_,alert_,%wu_alert_total_alerts,_message_End) 1 %wu_alert_timer_msgcount .msg %wu_nick --------- End of Alerts -------

    }
  }
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR  
  if (%wu_command == !almanac) {
    if (%wu_almanac_error == NotFound) && (%wu_name == $null) msg %wu_chan Location Not Found. Try location near an airport.
    if (%wu_almanac_error == $null) && (%wu_name != $null) msg %wu_chan %wu_name Found. No data provided.

    if (%wu_almanac_error == $null) && (%wu_name == $null) {
      .timer 1 0 msg %wu_chan $+(%wu_airport,$chr(58)) Normal High: $+(%wu_almanac_normal_high_F,$chr(47),%wu_almanac_normal_high_C,$chr(46)) Normal Low: $+(%wu_almanac_normal_low_F,$chr(47),%wu_almanac_normal_low_C,$chr(46))
      .timer 1 1 msg %wu_chan $+(%wu_airport,$chr(58)) Record High: $+(%wu_almanac_record_high_F,$chr(47),%wu_almanac_record_high_C) in %wu_almanac_high_year - Record Low: $+(%wu_almanac_record_low_F,$chr(47),%wu_almanac_record_low_C,) in %wu_almanac_low_year
    }
  }
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR  
  if (%wu_command == !moon) {
    msg %wu_chan $+(%wu_location ,$chr(39),s) Moon is $+(%wu_percentIlluminated,$chr(37)) illuminated. Age: %wu_ageOfMoon days

  }
  ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR  
  ;echo -s End-------- of WU $time --------
  wu_cleanup
}

;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

;--- Private Message ----
; -- If user requested !AlertsInfo, and wants to stop the long string of alerts. they can simply type STOP ---
on 1:OPEN:?:*stop*:{
  $+(.,timer_wu_,$nick,$chr(42)) off
  .msg $nick --------- Messages Stopped -------

}

:MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

alias wu_help {
  .timer 1 0 .msg %wu_nick $me $+ ' Weather Commands: (16 lines)
  .timer 1 1 .msg %wu_nick !weather !current !forecast !forecast5 !alerts !alertinfo !time !almanac
  .timer 1 2 .msg %wu_nick Use above commands with your desired location. 
  .timer 1 3 .msg %wu_nick !weather [zipcode|city,state|city,country|airport]
  .timer 1 4 .msg %wu_nick Examples: !weather 90210 - !weather Beverly Hills, CA - !weather LAX - !weather E2J4C7
  .timer 1 5 .msg %wu_nick You can also set a default location for yourself. Just type: !weather REGISTER [location]
  .timer 1 6 .msg %wu_nick To remove from the list, simply type !weather REMOVE
  .timer 1 7 .msg %wu_nick After you have registure, You can simply use !weather and it will bring up your default
  .timer 1 8 .msg %wu_nick -----END OF WEATHER HELP -----
  wu_cleanup
}

;=============================================================================
alias wu_cleanup {
  ;echo -s End-------- of WU $time --------
  unset %wu_*
}

;=============================================================================
/*
---- VERSION HISTORY -----
1.0 
- Original creation

2.0 
- Added !current command
- Unknown modifications (Did so many, I can't remember)

3.0 
- Added REGISTER and HELP functions
- Fixed !forecast, !forecast5, !alerts !alertinfo Address still including + sign error.

3.1
- Added !weather ON and OFF command to turn the script on or off. (set for OPS ONLY)

3.2
- Modified !weather ON/OFF command. Now the ON and OFF commands are Per #channel basis. (allowing it to be on in one chan, but off in another

3.3
- Line 238, TOS line had changed. Updated $remove() to reflect new text.

4.0
- Local Support. Now Local user (mIRC client hosting the script) can also activate and use the script. .
4.1
- Fixed !w command. Now it works.

5.0
- New Format: Code now uses wunderground's API. YOU MUST HAVE AN API code in order for this to work.
- Various parts changed to accomidate the new API requirments. OLD stuff commented out and NEW stuff noted (For those who read the code)
- Current code uses CONDITIONS, FORECAST. But wunderground has more paramerters you can pull from not included in this code: http://www.wunderground.com/weather/api/d/docs?d=data/index&MR=1
- Release to the public in Working order. But may still have bugs. 
5.1
- Added line spacers to each section. (I kept getting lost, so I decided to add spacers for each section so I knew where I was in the code)
- Added !almanac for record highs and lows.
5.2
- Fixed !alerts, !alertinfo, Now works with new API platform
- Added STOP ablity to long !alertinfo. (Simply type STOP in the private message window)
- Fixed !forecast and !forecast5 to new API platform.
5.3
- Added !forecast[1-10] ablity. Now you can request up to 10 days of private messages. Instead of the default 5. Want 3 days? !forecast3.  Want 10 days? !forecast10
- Fixed Spelling issue with forecast. (forEcast)
- Fixed Location Not Found to effect All commands. Added responce if city is found, but with out any information. Ex: ORD  (Chicago-O'Hare International Airport)
- Fixed !almanac not responding to local input. Due to extra space on INPUT, If line.
5.4
- Adjusted !forecast $chan message. To include %wu_location
- Fixed !weather REMOVE command resulting in a /sockopen: insufficient parameters error. 
- Fixed "Location Found, No results." Multiple locations are actually found, user is givin a list to choose from.
- Fixed !alertinfo From [Time] till [Time] glitch. (had old $right() from old xml that was removing text)
- Fixed !alertinfo Message timer glitch. Kept overwriting previous alert messages.
- Added script ULR to top of code for easy refference
5.41
- Changed Location Not Found to now output the error reported from wunderground
5.42
- Added private message STOP feature to also stop City/State Option [#] messages.
5.43
- Added Change activation command string to allow a user to call upon this script with a different leading character, and not have to change the entire code. 
5.44
- Added !moon and !moonphase to show the current status of the moon 
5.45
- Fixed the wu_cleanup to empty out the variables
- Line 68. commented out the botabuse script
*/
Archived. 

Comments

Sign in to comment.
Vegitha   -  Oct 26, 2019

hi, any update on this?

Alexandru  -  Oct 27, 2019

This is an old script.. nowadays are some scripts that can provide more better info about weather even without using an api.. for example, in mIRC Korona the weather script that i've created, doesn't use api keys so is not need to update it everytime an api is out and the script collects the info from www.foreca.com, where some tools from Windows 10 also collect from this web.

ovelayer  -  Oct 31, 2019

your comparing a full script to a addon.. i understand the differences but to use yours would envolve using your script.. now if it was a stand alone addon would be different. also without using an api you have to deal with site's changing the layout.. and unless you plan on constantly updating your script i think it will run into problems..

Alexandru  -  Nov 04, 2019

Yes, but for 5 years the foreca web site has the same structure and even they will change the layout, is not so hard to update it.. believe me, faster the api will be out than the layout will be changed. I have many years of scripting, analyzing etc. and i see the differences. For example, in this case.. Is using the api, but the script needs to be updated, even you must use an api. I saw cases when the user make a script using api and followed the syntaxes from the web replies, but in one day the web changed their syntaxes and the script had to be updated again. So no matter, using a web layout or through an api is the same thing, the differences that the user have to create an api to use the script, but in case of layouts, the user doesn't have to do nothing. So, why to complicate the things to use an api, better to use scripts that make the users to use it more simply and with more efficiency .

Sign in to comment

ovelayer   -  Apr 05, 2019

https://www.apixu.com/api.aspx

provides a free api..
wondering if you could use this?

Karlien  -  Apr 15, 2019

Ya, IBM took over wunderground and killed the free api's. We used this weather script all the time. Would love to see it converted with the link you posted.

eqrunner  -  Jul 30, 2019

No promises, but I will look into this

ovelayer  -  Aug 21, 2019

https://openweathermap.org
also provides free api keys

Sign in to comment

ovelayer   -  Mar 06, 2019

Wunderground seems to have removed the free api's again..stopped working

 Respond  
ovelayer   -  Jul 31, 2018

was wondering if there was a way to make it so when you do !weather/!forecast . if there are any alerts it will display "2 alerts"
only way now to know if there are alerts is !alerts

 Respond  
Alexandru   -  Mar 20, 2017

Here're many weather scripts that not need for API code and with more performance. This code is oldest and, also, have a lot of bugs.

duckz  -  Nov 04, 2017

This one appears to work for me, others connect to other weather sites which no longer have feeds.

Sign in to comment

XxBonf1r3xX   -  Nov 11, 2016

How I can make my BOT to send !weather and !w commands with /me color code? How I need to edit this script to make this work?

Thank you for your phenomenal script my friend.

dma  -  Nov 11, 2016

thats all you have to do is !w or !weather thats what i do with mine

XxBonf1r3xX  -  Nov 11, 2016

But would it be possible to do it automatically, if I do "!weather /me " with Ankhbot it won't work.

For example my BOT's color is red, so when I do "!weather /me" my BOT would answer me with a red text instead of default white text.

duckz  -  Nov 04, 2017

How might I use another trigger say !weatherforX represent !weather 90210; in another script I could use $weatherm(90210,W) with trigger !bhweather ...

Sign in to comment

RothschildJR   -  Jun 25, 2016

error msg for any !w xxx : BOTABUSE Unknown command

/sockopen: 'wunderground' socket in use (line 235, remote.ini)

eqrunner  -  Dec 17, 2016

Line 66. I forgot to comment out my botabuse script. You can delete it

Sign in to comment

Karlien   -  Mar 03, 2016

I just got this script and everything works great! For the first person to use it. If you then enter another zip, city, whatever it will only output the first person's information. I've tried deleting all the variables from .vars and the same thing happens again. Its a great script with great features but this is driving me crazy and I can't figure it out. Help please

eqrunner  -  Dec 17, 2016

I forgot to un-comment the wu_cleanup on line 599. Remove the semicolon and all will be well

Sign in to comment

Shadow7557   -  Feb 18, 2016

Hi, what would I do if I only !weather by itself

dma  -  Feb 18, 2016

i dunno i use something different - try !w

eqrunner  -  Dec 17, 2016

!weather by its self should bring up your selection. or will come back with an error cause nothing was entered.

Sign in to comment

ovelayer   -  Dec 24, 2015

eqrunner
is there a way to change it so that when you use the forecast and !forecast5 it shows the city and state instead of zipcode? like it does when you do !weather
?
would be cool
thanks for your amazing script

eqrunner  -  Dec 17, 2016

Short answer, No. There is a weird way wunderground works. It has those options for Current weather, but forecast uses a different page, and does not show options to pull up the actual name of the location.

You could double the script up, and have it first check the !forecast location to do !weather location first. grab the name. then do it again to grab the actual forecast data.

Sign in to comment

ovelayer   -  Oct 16, 2015

keep getting this error now..

(Fri 8:35pm) BOTABUSE Unknown command

i see it on line 66 in your script as
alias wunderground {
botabuse
unset %wu_*

but i find no alias for it?

rebel9  -  Oct 24, 2015

Then delete the 'botabuse' line, or create a botabuse alias that disables users from spam. Here's one I found within 30 seconds of searching for it, and it's by eqrunner.

alias botabuse {

  var %botabuse_count = $hget(botabuse ,$nick)
  if (%botabuse_count > 60 ) {
    .notice $nick is citing bot abuse. $me is now ignoring you.
    .notice eqrunner -IGNORED- $nick
    .msg BotServ ACT $chan adds $nick to $me $+ 's ignore list
    hinc -zm botabuse $nick 1800
    echo -s IGNORED: $nick on $chan at $date(mm/dd/yyyy) $time(HH:nn.ss)
    ignore -pcntikdu1800 $nick
  }
  if ($nick isop #) { hinc -zm botabuse $nick 15 }
  if ($nick ishop #) { hinc -zm botabuse $nick 30 }
  if ($nick isvoice #) { hinc -zm botabuse $nick 30 }
  if ($nick isreg #) { hinc -zm botabuse $nick 35 }
}
eqrunner  -  Dec 17, 2016

Correct. It is for the additional bot abuse script I created.

You can simply comment out or delete that line.

Sign in to comment

mrdoody55   -  Oct 15, 2015

I first want to say thanks for the great script, I've been using it in a friends & family irc channel for a while now, and haven't had any issues. This unfortunately stopped today, as the script is no longer responding to any of the commands, except for help and remove. There seems to be no response for register, weather, current, forecast, or alerts.

eqrunner  -  Dec 17, 2016

It appears to be still working on my end. Might be either a limit on your Hash. or another script interfering with weather.

Sign in to comment

ovelayer   -  Oct 13, 2015

one thing i noted is that this script creates and leave's a bunch of var's...
anyway to clean those once the script is done msgin the output?

eqrunner  -  Dec 17, 2016

My error on the last update. Line 614: wu_cleanup was commented out. just remove the semicolon and all should be well.

Sign in to comment

H0LLYWOOD   -  Oct 12, 2015

i know this is being overly picky and asking a lot, but, since users have profiles. for their individual weather. i'm wondering if there's a way to make the !w and !weather triggers network + channel specific. so if a channel owner doesn't want to use !w for the full layout and just use !weather for the one-liner, they can choose to do so. and since the bot may be on two or more networks with the same channel name. that's why i put $network + $chan
thanks for continuing to update and provide this great script.

dma  -  Oct 18, 2015

yes you can make it .. it !w is the long way full ( !weather ) is the short way to do it

eqrunner  -  Dec 17, 2016

You could. Down in the results section, you will just have to specify IF #channelA, then message like this... Or if #channelB and network b. then write it out like this...

You are welcomed to customize it to your likeing

Sign in to comment

ovelayer   -  Sep 26, 2015

Ever thought of adding !moonphase/!phase trigger that would display the different moon phases and their dates? Dont know if u can but it would be cool

eqrunner  -  Sep 28, 2015

Done! I uploaded version 5.44. You currently get the percentage of illumination, and the age of Moon when you use the command !moon or !moonphase.

I am not up on the status of the moon, So you may need to adjust to what you need. Hope this helps.

ovelayer  -  Sep 29, 2015

nice i really like it
(Tue 7:37pm) <~xXBERTOXx> !moonphase
(Tue 7:37pm) <~BrAiNs> 99004's Moon is 94% illuminated. Age: 17 days
is there anyway to add more info to it? like !moon would give the current moonphase but !moonphase would give the current moonphase and the dates of the expected changes to the moonphase leading up to the fullmoonphase? or u could just use !fullmoon to show when the next expected date of the full moon would be..
but awsome job this is a NICE addition

eqrunner  -  Dec 17, 2016

That I can not. Wundergound does not have any entries for those. They only have the following options for moon.
https://www.wunderground.com/weather/api/d/docs?d=data/astronomy
precentIlluminated
ageOfMoon
current_time.hour
current_time.minute
sunrise.hour
sunrise.minute
sunset.hour
sunset.minute

Sign in to comment

dma   -  May 11, 2015

is this updated ?last time i tried it wasnt

eqrunner  -  May 20, 2015

Most recent verison 5.41 was updated last year. And has been working with no issues. No further updates since then.

Sign in to comment

tlchost   -  Apr 20, 2014

How can I modify the script so that all messages go to the nick, rather then the channel?

cptpan  -  Apr 21, 2014

Change instances of msg $chan to either notice $nick or msg $nick

tlchost  -  Apr 24, 2014

ah...the current version of the script doesn't seem to have those instances.

cptpan  -  Apr 26, 2014

Fuks me then. Soz

eqrunner  -  May 03, 2014

You can change all the "msg %wu_chan" to "msg %wu_nick" (Lines
444
467
478
482
493-494
522
524
527

751-752
575-576)

Sign in to comment

anviska   -  Mar 15, 2014

Great script! thanks! I just have one problem. When I type i. e. "!w finland" and the bot PM's me all the available location, there is so much data coming in such a short time that Quakenet kills my bot for excess flood. What kind of flood settings I should have in mIRC to prevent this from happening or is there any script that would somehow make the locations come a bit slower?

 Respond  
TehJibba   -  Mar 10, 2014

This script has a major security flaw in the !w register command that leaves anyone running this open to possible attacks. Im not going into public detail about what is wrong with it so that this wont become a widely known flaw. the author can contact me for a better explanation, The exploit was tested several times on several different users and it does infact work

 Respond  
damaks   -  Feb 27, 2014

Hi, great script, but could you please make metric version? Than it would be prefect!
Thanks!

eqrunner  -  Mar 11, 2014

There is already metric in the script. if you comment out the 'unset' at the very bottom in the alias 'WUCLEANUP' . Run the script, and look at all the variables tab for all the available results. Then simply modify the msg %wu_chan Lines in the alias 'WU_SOCKCLOSE' to adapt to your likeing. A simple of change of things like "%wu_windchill_f" to "%wu_windchill_c", or "%wu_visibility_mi" to %wu_visibility_km" would work as a simple fix.

I do have intentions at some point to give an option in the beginning of the script to select Imperial or Metric as the 'primary.' But that would result in a lot of adjustment to the code. Along with each user who uses my code may have a different audience who lives in different locations. But I will keep this in mind. [As I write this, I could see my self adding to the !weather REGISTER function a way to also specify your preferred measurement scale. I will continue to ponder this one]

damaks  -  Mar 11, 2014

yes i have changed all eg. %wu_windchill_f to %wu_windchill_c" , and everything works great except !forecast . with that i cant do anything about, it always shows in imperial units

eqrunner  -  Mar 13, 2014

Forecast has it. You need to use the #wu_fcttext_metric variable.

damaks  -  Mar 14, 2014

thx! :)

Sign in to comment

cptpan   -  Feb 16, 2014

There are so many areas now that just result in:

WHATEVER Found. No data provided.

eqrunner  -  Feb 17, 2014

That is due to the site the script pulls from. It's api shows that the location exisits, but the site does not have any information from that location at all. Nothing that I can do on the script will fix this issue. Your users will just have to enter in a more populated/larger city.

cptpan  -  Feb 22, 2014

lol. It often happens for some of the biggest cities in the world.

Their API must be a piece of $hit then.

eqrunner  -  Feb 23, 2014

I can understand this being a big issue if it was in the states. But around the world, there are so many cities and countries around the world. And not all of the are connected to the internet 24/7. Or have sensors in those towns that are made public that can be accessed online.

Sign in to comment

chachin2009   -  Jan 16, 2014

I know i've asked this before.. and it was a loooong time ago and code has changed so much i cant find a way to do it.. so how can i have

!fc amy is not my bot.. Baytown, TX Forecast (High/Low) - Updated: 11:41 CST Thursday: Clear, 20/6°C (68/43°F) Friday: Clear, 18/3°C (64/37°F) Saturday: Clear, 20/8°C (68/46°F) instead of all that stuff on pm do show 3 days only like that on chan instead of pm :) ty like always
rebel9  -  Jan 16, 2014

You can make it message a channel now.

Line 553:
.timer 1 %wu_f_i .msg %wu_nick %wu_sf_dow $+ : %wu_sf_con $+ . High: $+(%wu_sf_fh,$chr(40),%wu_sf_ch,$chr(41)) - Low: $+(%wu_sf_fl,$chr(40),%wu_sf_cl,$chr(41))

Change that to:
.timer 1 %wu_f_i .msg %wu_chan %wu_sf_dow $+ : %wu_sf_con $+ . High: $+(%wu_sf_fh,$chr(40),%wu_sf_ch,$chr(41)) - Low: $+(%wu_sf_fl,$chr(40),%wu_sf_cl,$chr(41))

You can also make it notice by changing .msg %wu_chan to .notice %wu_nick. This way it doesn't spam the channel when people !forecast3/4/5/6 etc and only you get the information, nobody else cares about what your weather is going to do for 5 days in your area.

Sign in to comment

chachin2009   -  Dec 08, 2013

what about instead of posting Heat Index: NA°F/NA°C or cold index na make it so it hides it when you do .current to make it look clean or shorter since its not there why bother having heat or cold depending on weather :)

ovelayer  -  Dec 08, 2013

well it works for me when it is 0 and we have a windchill factor like now its -2

Sign in to comment

TerrapinStaion   -  Nov 25, 2013

eqrunner, Perhaps the script could be ported to http://www.localweather.net or even yahoo weather. As wunderground.com was bought out by the weather channel. The weather channel is believe it or not a very bias reporting weather network. They are bias on reporting weather news on the cities on the east coast almost exclusively. Even if its just a half inch of rain their going to receive or 3 inches of snow. This is a catastrophe for the east coast cities according to the Weather Channel. Also weather network and website WeatherNation "www.weathernationtv.com" founded by world founded by world famous meteorologist from Minnesota Paul Douglas would also be another excellent source.

eqrunner  -  Nov 26, 2013

@TerrapinStaion The buyout was over 18 months ago and has not affected the wundergound script that I have created. The Weather Channel may be opinionated to be biast, but the script above is not. What The Weather Channel reports on has no effect on the wunderground script as the individual user requests the info they want. I have looked at localweather.net and weathernation.tv in the past but neither of them support an API platform on which the script now runs on. Yahoo Weather API does not contain all the additional features that wunderground supports. Hence the reason why I have stuck with wunderground as the source.

Sign in to comment

Wizardkat   -  Nov 12, 2013

What are the chances of adding a Celsius to Fahrenheit converter and vice versa to the script? Something like !convert 15F or !convert 15C

eqrunner  -  Nov 12, 2013

Odds are stacked against you. If you are looking for the script to spit out Celsius answers, you can always modify the msg $chan section, as there are Celsius variables availble (%wu_temp_c, %wu_dewpoint_c, %wu_heat_index_c, %wu_windchill_c, etc) This weather script is not intended to do conversions.

Might I suggest you search above for a temperature converter script, or post a request in the forums http://www.hawkee.com/phpBB2/viewforum.php?f=9

(after doing a little searching) I can suggest http://www.hawkee.com/snippet/6727/ or http://www.hawkee.com/snippet/3826/ That is a simple script you can use.

Sign in to comment

morte   -  Nov 05, 2013

Sorry, I am new here and thought I screwed something up and posted something that is not at all relevant to this script.

 Respond  
chachin2009   -  Nov 04, 2013

Hey eqrunner could you be cool and come to irc.freenode.net #chick3n to help me out with a script? :P

 Respond  
RIcko   -  Oct 24, 2013

In spite of the on INPUT and on TEXT issues, I'm getting this error each time I typ !weather or !forecast:

(Oct-Fri-25|4:30:04|am) <~Ricko> !weather Florida
[my bot's status window]: * /sockopen: 'wunderground' socket in use (line 224, Weather-Script-2.ini)

blackvenomm666  -  Oct 24, 2013

On your bot type /sockclose wunderground then try using it again

Sign in to comment

^WeSt   -  Oct 09, 2013

LOL have a look here:

!wow -RafaeLLa-v2- Please specify a location !wow [zipcode|city,state|city,country|airport] * /sockopen: insufficient parameters (line 224, script4.ini) !what-a-fuck -RafaeLLa-v2- Please specify a location !what-a-fuck [zipcode|city,state|city,country|airport] * /sockopen: insufficient parameters (line 224, script4.ini) !w -RafaeLLa-v2- Please specify a location !w [zipcode|city,state|city,country|airport] * /sockopen: insufficient parameters (line 224, script4.ini)
eqrunner  -  Oct 09, 2013

Yup, this is a problem I still haven't been able to get right. It is in the on INPUT and on TEXT part. For some reason, because of the w| part. If I add a space w |. It doesn't work. But if is just the w|. I t will respond to all W related things.

^WeSt  -  Oct 11, 2013

This is an several bug , into my bot i have a lot of !w.... commands so you must find a way to fix this, try an other way and not the regex.

^WeSt  -  Oct 11, 2013

Also the problem is not only in !weather and on the other commands:

e.g:

!forecastttttttt
!alertsssssssssssssss
!timeeeeeeeeeeee
.....

eqrunner  -  Oct 11, 2013

I am unable to recreate your issue. Other than !forecast. But I will keep an eye on this.

For now, just remove the W from the on text and on input section.

 on $*:INPUT:#: {
  if ($regex($1,/^[!](weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si)) wunderground $1-
}

on $*:text:/^[!](weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si:#: {
  wunderground $1-
}
^WeSt  -  Oct 11, 2013

Ok but i don't know why this is happening.

rebel9  -  Oct 20, 2013

on $*:text:/^!? /Si:#: {
wunderground $1-
} A simple ? after the (weather|forecast|etc|)? /Si: <--will fix the issue.

eqrunner  -  Oct 23, 2013

@rebel9 That works for the onTEXT. But not for the onINPUT

rebel9  -  Oct 23, 2013

on $*:INPUT:#: {
if ($regex($1,/^!? /Si)) wunderground $1-
}
This doesnt work? If not try almanac)? \w+$/Si))

Sign in to comment

chachin2009   -  Oct 08, 2013

Yo eqrunner. SO i went and try to do the code change so i can use . instead of ! so the bot doesn't interfere with the other bot i have that uses !w for other stuff but that one bot is'nt mine so i can't do nothing about it and im not op to kick the that bot :P so i went for the lines 47 to 53 then try to go down to 130 to 131 or whatever but couldnt find the rest so Im stuck on 47 to 53.. if you wanna be cool to help me once again.. you're just too awesome. thanks anyways :)

eqrunner  -  Oct 09, 2013

Let me simplify that for you. Change the following: (Lines 55 thru 58)

on $*:INPUT:#: {
  if ($regex($1,/^[.](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si)) 
  wunderground $1-
}

on $*:text:/^[.](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si:#: {
  wunderground $1-
}

This is just changing the ! to a .

And add this code right below the APIKEY area (Insert at line 88)

  ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  ;set %wu_api YourAPICodeGoesHere
  ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
set %wu_command $replace(%wu_command,$chr(46),$chr(33))

This will solve all your problems. This allows you to use .weather .time .forecast etc. But once the script is started. It internally changes it back to !weather !time !forecast, etc. So that the rest of the code works.

chachin2009  -  Oct 10, 2013

wow just wow this is so much better.. thank you man.. like always you're just too awesome :)

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.