Advertisement
LoveAbleElf

weather

Jun 21st, 2017
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.42 KB | None | 0 0
  1. -- COMMANDS --
  2. !w or !weather [zipcode|city,state|city,country|airport] = will return weather current conditions.
  3. !current [zipcode|city,state|city,country|airport] = will return current conditions.
  4. !forecast [zipcode|city,state|city,country|airport] = will give detailed 3 day forecast (for us)
  5. !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)
  6. !alerts [zipcode|city,state|city,country|airport] = will tell you if there are any weather alerts in your area.
  7. !alertinfo [zipcode|city,state|city,country|airport] = will send $nick the detailed report of alerts in said area
  8. !time [zipcode|city,state|city,country|airport] = will return current time.
  9. !almanac [zipcode|city,state|city,country|airport] = will return the record highs and lows.
  10.  
  11. -- REGISTER --
  12. 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)
  13. ![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REGISTER [zipcode|city,state|city,country|airport] = will link user to said default location
  14. ![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REGISTER [zipcode|city,state|city,country|airport] = will CHANGE users default if they already have registured.
  15. ![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] REMOVE = will remove the users default location
  16. User can use any of the !commands to registure. !weather register 90210, will work just as well as !time register 90210
  17.  
  18. -- HELP --
  19. ![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] [?|help] = Will message user the list of above commands just as they are written.
  20.  
  21. -- Switch --
  22. ![w|forecast|forecast5|alerts|alertinfo|time|current|almanac] [ON|OFF] = Will turn the script ON or OFF. Currently only set for Ops only.
  23.  
  24. -- NOTES- -
  25. Notes from wunderground:
  26. We don't support old style abbreviations like Conn. for Connecticut, use CT
  27. If you are searching for an international city, try the name of the country or province
  28. Don't use provinces for non-us cities (ie: Vancouver, BC)
  29. Zipcodes only work in Canada, UK and the US
  30. */
  31.  
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. on *:CONNECT: {
  34. if ($hget(wu_reg) == $null) { hmake wu_reg 100 }
  35. if ($isfile(wu_reg.dat)) { hload wu_reg wu_reg.dat }
  36. }
  37. ON *:DISCONNECT: {
  38. if ($hget(wu_reg)) { hsave -o wu_reg wu_reg.dat }
  39. }
  40.  
  41. on $*:INPUT:#: {
  42. if ($regex($1,/^[!](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si)) wunderground $1-
  43. }
  44.  
  45. on $*:text:/^[!](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time|current|almanac)/Si:#: {
  46. wunderground $1-
  47. }
  48.  
  49. ;-----------------------------------------------------------------------------
  50. ; Preperation
  51. ;-----------------------------------------------------------------------------
  52.  
  53. alias wunderground {
  54. ;botabuse
  55. unset %wu_*
  56.  
  57. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  58. ;--- Preperation. Sets up all the variables needed for the script ---
  59. set %wu_command $1
  60. set %wu_2 $2
  61. set %wu_location $2-
  62. set %wu_3 $3
  63. set %wu_3_long $3-
  64. set %wu_nick $nick
  65. set %wu_network $network
  66. set %wu_chan $chan
  67. set %wu_host api.wunderground.com
  68.  
  69. ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  70. set %wu_api 028cbc08adbf40d2
  71. ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  72.  
  73. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  74. ;--- Registration Check. Checks to see if the $nick already has a 'default' location on file ---
  75. if ($2 == $null) {
  76. if ($hget(wu_reg,%wu_nick) != $null) {
  77. set %wu_location $hget(wu_reg,%wu_nick)
  78. }
  79. if ($hget(wu_reg,%wu_nick) == $null) {
  80. .notice $nick Please specify a location $1 [zipcode|city,state|city,country|airport]
  81. wu_cleanup
  82. }
  83. }
  84.  
  85. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  86. ;--- Modify Registration and Help and ON/OFF Switch ---
  87. if ($2 != $null) {
  88. if (%wu_2 == register) && (%wu_3 != $null) {
  89. ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  90. ;set %wu_api 028cbc08adbf40d2
  91. ;APIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEYAPIKEY
  92. set %wu_command $replace(%wu_command,$chr(46),$chr(33))
  93. hadd -m wu_reg %wu_nick %wu_3_long
  94. .notice %wu_nick You are now linked to %wu_3_long
  95. set %wu_location $hget(wu_reg,%wu_nick)
  96. ;echo -s %wu_location
  97. }
  98. if (%wu_2 == remove) {
  99. hdel wu_reg %wu_nick
  100. .notice %wu_nick Your location association has been removed.
  101. wu_cleanup
  102. halt
  103. }
  104. ;;--- Checks to see if the $2 is an already registured nick. ----
  105. if ($hget(wu_reg,%wu_2) != $null) {
  106. set %wu_location $hget(wu_reg,%wu_2)
  107. }
  108. if (%wu_2 == ?) || (%wu_2 == help) {
  109. wu_help
  110. wu_cleanup
  111. halt
  112. }
  113. ;;;---Below is used to turn the script on or off, but only if user is an op of a channel ---
  114.  
  115. if (%wu_2 == on) || (%wu_2 == off) && (%wu_nick isop %wu_chan) {
  116. if (%wu_2 == on) {
  117. set $+(%,wunderground_,%wu_chan) ON
  118. .notice %wu_nick !weather script is now ON
  119. wu_cleanup
  120. halt
  121. }
  122. if (%wu_2 == off) {
  123. set $+(%,wunderground_,%wu_chan) OFF
  124. .notice %wu_nick !weather script is now OFF
  125. wu_cleanup
  126. halt
  127. }
  128. } ;end of %wu_on/off
  129.  
  130. ;--- Default for a channel ---
  131. if ($2 == shoutdrive) && (%wu_network == iPocalypse) {
  132. set %wu_location 90046
  133. } ; end of Default for a channel
  134.  
  135. } ;end of ($2 != $null)
  136.  
  137. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  138. ;--- Checks if wunderground is suppost to be OFF for the channel --
  139. if ($($+(%,wunderground_,%wu_chan),2) == OFF) {
  140. wu_cleanup
  141. halt
  142. }
  143.  
  144. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  145. ;---Command Prep. Checks command to see which data file it will be pulling from depending on command entered ---
  146. ;NEW
  147. ;Reformats City, State to the corrected /State/City.xml
  148.  
  149. if ($chr(44) isin %wu_location) {
  150. ;set %wu_location_format $+(/,$remove($gettok(%wu_location,2,44),/,$gettok(%wu_location,1,44))
  151. var %wu_location_city $replace($gettok(%wu_location,1,44),$chr(32),$chr(95))
  152. var %wu_location_state $remove($gettok(%wu_location,2,44),$chr(32))
  153. ;echo -s %wu_location_city %wu_location_State
  154. set %wu_address $+(/,%wu_location_state,/,%wu_location_city)
  155.  
  156. ;echo -s %wu_address
  157. ;wu_cleanup
  158. ;halt
  159. }
  160. if ($chr(44) !isin %wu_location) {
  161. set %wu_address $replace(%wu_location,$chr(32),$chr(95))
  162. ;echo -s %wu_address
  163. ;wu_cleanup
  164. ;halt
  165. }
  166. ;/NEW
  167.  
  168. ;PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  169. ;-- Sets specific %wu_links depending on what is requested.
  170.  
  171. ;-- Weather --
  172. if (%wu_command == !w ) set %wu_command !weather
  173. if (%wu_command == !weather) || (%wu_command == !current) || (%wu_command == !time) {
  174. ;Eample: set %wu_link $+(/api/154dfe245e155eee1/conditions/q/20721.xml)
  175. set %wu_link $+(/api/,%wu_api,/conditions/q/,%wu_address,.xml)
  176. }
  177. ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  178. ;-- Forecast --
  179. ;- Below finds out if it is a !forecast or a !forecast[1-10]. If there is a number,
  180. ; then it strips the number and sets %wu_command back to !forecast5 so remainder of the code
  181. ; works. and creates a %wu_forecast_count to be used after the sock closes.
  182.  
  183. if ($left(%wu_command,9) == !forecast) {
  184. if ($mid(%wu_command,10,0) > 0) {
  185. set %wu_forecast_count $remove(%wu_command,!forecast)
  186. ; ^ removes !forecast, leaving only the number
  187. if (%wu_forecast_count > 10) set %wu_forecast_count 10
  188. ; ^ If number is greater than 10. Changes it to 10. (no one wants 999 days of forecast)
  189. set %wu_command !forecast5
  190. ; ^ resets %wu_command back to !forecast5 so the rest of the code works.
  191. }
  192. }
  193.  
  194. if (%wu_command == !forecast) || (%wu_command == !forecast5) {
  195. set %wu_link $+(/api/,%wu_api,/forecast10day/q/,%wu_address,.xml)
  196. }
  197.  
  198. ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  199. ;-- Alerts --
  200. if (%wu_command == !alert) set %wu_command !alerts
  201. if (%wu_command == !alertsinfo) set %wu_command !alertinfo
  202. if (%wu_command == !alerts) || (%wu_command == !alertinfo) {
  203. set %wu_link $+(/api/,%wu_api,/alerts/q/,%wu_address,.xml)
  204. set %wu_a_count 0
  205. }
  206. ;pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
  207. ;-- Almanac --
  208. if (%wu_command == !almanac) {
  209. set %wu_link $+(/api/,%wu_api,/almanac/q/,%wu_address,.xml)
  210. }
  211. sockopen wunderground %wu_host 80
  212. ;echo -s LINK: %wu_link
  213. }
  214.  
  215. ;-----------------------------------------------------------------------------
  216. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  217. ; SOCKETS
  218. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  219. ;-----------------------------------------------------------------------------
  220.  
  221. on *:sockopen:wunderground: {
  222. sockwrite -n $sockname GET %wu_link HTTP/1.1
  223. sockwrite -n $sockname Host: %wu_host
  224. sockwrite -n $sockname $crlf
  225.  
  226. }
  227.  
  228. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  229.  
  230. on *:sockread:wunderground: {
  231. sockread %wu_temp
  232. if ($regex(%wu_temp,/([[:xdigit:]]{2});/)) {
  233. set %wu_temp $replace(%wu_temp,$+(&#x,$regml(1),;),$chr($base($regml(1),16,10)))
  234. }
  235. set %wu_temp $regsubex(%wu_temp,/[\46\43](\d+)\73/g,$chr(\1))
  236. set %wu_temp $replacex(%wu_temp,&quot;,",&amp;lt;,<,&amp;rt;,>,&amp;deg;,°,&amp;,&)
  237. if (<name> isin %wu_temp) && (%wu_name == $null) %wu_name = $remove(%wu_temp,<name>,</name>,$chr(9))
  238.  
  239. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  240. ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  241. ;checks for an error
  242. if (<error> isin %wu_temp) set %wu_error Error
  243. if (%wu_error == Error) && (<description> isin %wu_temp) {
  244. set %wu_error_description $remove(%wu_temp,<description>,</description>,$chr(9))
  245. }
  246.  
  247. if (<results> isin %wu_temp) set %wu_results ON
  248. if (%wu_results == ON) {
  249. if (<result> isin %wu_temp) inc %wu_result_count
  250. if (<city> isin %wu_temp) set $+(%,wu_result_city,%wu_result_count) $remove(%wu_temp,<city>,</city>,$chr(9))
  251. if (<state> isin %wu_temp) set $+(%,wu_result_state,%wu_result_count) $remove(%wu_temp,<state>,</state>,$chr(9))
  252. if (<country_name> isin %wu_temp) set $+(%,wu_result_country_name,%wu_result_count) $remove(%wu_temp,<country_name>,</country_name>,$chr(9))
  253.  
  254. }
  255.  
  256. ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  257. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  258.  
  259. ;set %wu_temp $regsubex(%wu_temp,/&#(\d+)\;/g,$chr(\1))
  260. ;echo -s %wu_temp
  261.  
  262. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  263. ;--- Variables for Weather, Current and Time Command ---
  264. if (%wu_command == !weather) || (%wu_command == !current) || (%wu_command == !time) {
  265. ; local info
  266. if (<full> isin %wu_temp) && (%wu_full == $null) %wu_full = $remove(%wu_temp,<full>,</full>,$chr(9))
  267. if (<city> isin %wu_temp) && (%wu_city == $null) %wu_city = $remove(%wu_temp,<city>,</city>,$chr(9))
  268. if (<state> isin %wu_temp) && (%wu_state == $null) %wu_state = $remove(%wu_temp,<state>,</state>,$chr(9))
  269. if (<state_name> isin %wu_temp) && (%wu_state_name == $null) %wu_state_name = $remove(%wu_temp,<state_name>,</state_name>,$chr(9))
  270. if (<country> isin %wu_temp) && (%wu_country == $null) %wu_country = $remove(%wu_temp,<country>,</country>,$chr(9))
  271. if (<country_iso3166> isin %wu_temp) && (%wu_country_iso3166 == $null) %wu_country_iso3166 = $remove(%wu_temp,<country_iso3166>,</country_iso3166>,$chr(9))
  272. if (<zip> isin %wu_temp) && (%wu_zip == $null) %wu_zip = $remove(%wu_temp,<zip>,</zip>,$chr(9))
  273. if (<latitude> isin %wu_temp) && (%wu_latitude == $null) %wu_latitude = $remove(%wu_temp,<latitude>,</latitude>,$chr(9))
  274. if (<longitude> isin %wu_temp) && (%wu_longitude == $null) %wu_longitude = $remove(%wu_temp,<longitude>,</longitude>,$chr(9))
  275. if (<elevation> isin %wu_temp) && (%wu_elevation == $null) %wu_elevation = $remove(%wu_temp,<elevation>,</elevation>,$chr(9))
  276.  
  277. ;; NO LONGER if (<local_time> isin %wu_temp) %wu_local_time = $remove(%wu_temp,<local_time>,</local_time>,$chr(9))
  278. if (<local_time_rfc822> isin %wu_temp) %wu_local_time_rfc822 = $remove(%wu_temp,<local_time_rfc822>,</local_time_rfc822>,$chr(9))
  279.  
  280. ; current weather
  281. if (<weather> isin %wu_temp) %wu_weather = $remove(%wu_temp,<weather>,</weather>,$chr(9))
  282. if (<temperature_string> isin %wu_temp) %wu_temperature_string = $remove(%wu_temp,<temperature_string>,</temperature_string>,$chr(9))
  283. if (<temp_f> isin %wu_temp) %wu_temp_f = $remove(%wu_temp,<temp_f>,</temp_f>,$chr(9))
  284. if (<temp_c> isin %wu_temp) %wu_temp_c = $remove(%wu_temp,<temp_c>,</temp_c>,$chr(9))
  285. if (<relative_humidity> isin %wu_temp) %wu_relative_humidity = $remove(%wu_temp,<relative_humidity>,</relative_humidity>,$chr(9))
  286.  
  287. ; wind
  288. if (<wind_string> isin %wu_temp) %wu_wind_string = $remove(%wu_temp,<wind_string>,</wind_string>,$chr(9))
  289. if (<wind_dir> isin %wu_temp) %wu_wind_dir = $remove(%wu_temp,<wind_dir>,</wind_dir>,$chr(9))
  290. if (<wind_degrees> isin %wu_temp) %wu_wind_degrees = $remove(%wu_temp,<wind_degrees>,</wind_degrees>,$chr(9))
  291. if (<wind_mph> isin %wu_temp) %wu_wind_mph = $remove(%wu_temp,<wind_mph>,</wind_mph>,$chr(9))
  292. if (<wind_gust_mph> isin %wu_temp) %wu_wind_gust_mph = $remove(%wu_temp,<wind_gust_mph>,</wind_gust_mph>,$chr(9))
  293.  
  294. if (<pressure_string> isin %wu_temp) %wu_pressure_string = $remove(%wu_temp,<pressure_string>,</pressure_string>,$chr(9))
  295. if (<pressure_mb> isin %wu_temp) %wu_pressure_mb = $remove(%wu_temp,<pressure_mb>,</pressure_mb>,$chr(9))
  296. if (<pressure_in> isin %wu_temp) %wu_pressure_in = $remove(%wu_temp,<pressure_in>,</pressure_in>,$chr(9))
  297. if (<dewpoint_string> isin %wu_temp) %wu_dewpoint_string = $remove(%wu_temp,<dewpoint_string>,</dewpoint_string>,$chr(9))
  298. if (<dewpoint_f> isin %wu_temp) %wu_dewpoint_f = $remove(%wu_temp,<dewpoint_f>,</dewpoint_f>,$chr(9))
  299. if (<dewpoint_c> isin %wu_temp) %wu_dewpoint_c = $remove(%wu_temp,<dewpoint_c>,</dewpoint_c>,$chr(9))
  300.  
  301. if (<heat_index_string> isin %wu_temp) %wu_heat_index_string = $remove(%wu_temp,<heat_index_string>,</heat_index_string>,$chr(9))
  302. if (<heat_index_f> isin %wu_temp) %wu_heat_index_f = $remove(%wu_temp,<heat_index_f>,</heat_index_f>,$chr(9))
  303. if (<heat_index_c> isin %wu_temp) %wu_heat_index_c = $remove(%wu_temp,<heat_index_c>,</heat_index_c>,$chr(9))
  304. if (<windchill_string> isin %wu_temp) %wu_windchill_string = $remove(%wu_temp,<windchill_string>,</windchill_string>,$chr(9))
  305. if (<windchill_f> isin %wu_temp) %wu_windchill_f = $remove(%wu_temp,<windchill_f>,</windchill_f>,$chr(9))
  306. if (<windchill_c> isin %wu_temp) %wu_windchill_c = $remove(%wu_temp,<windchill_c>,</windchill_c>,$chr(9))
  307.  
  308. if (<visibility_mi> isin %wu_temp) %wu_visibility_mi = $remove(%wu_temp,<visibility_mi>,</visibility_mi>,$chr(9))
  309. if (<visibility_km> isin %wu_temp) %wu_visibility_km = $remove(%wu_temp,<visibility_km>,</visibility_km>,$chr(9))
  310. }
  311.  
  312. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  313. ;--- Variables for Forecast Command ---
  314. if (%wu_command == !forecast) || (%wu_command == !forecast5) {
  315. if (<simpleforecast> isin %wu_temp) set %wu_period 1
  316. set %wu_temp $remove(%wu_temp,<![CDATA[,]]>)
  317. if (<period> isin %wu_temp) set %wu_period $remove(%wu_temp,<period>,</period>,$chr(9),$chr(32))
  318.  
  319. ;-- Detailed Forecast ---
  320. if (%wu_command == !forecast) {
  321. if (<title> isin %wu_temp) set $+(%,wu_df_title_,%wu_period) $remove(%wu_temp,<title>,</title>,$chr(9))
  322. if (<fcttext> isin %wu_temp) set $+(%,wu_df_fcttext_,%wu_period) $remove(%wu_temp,<fcttext>,</fcttext>,$chr(9))
  323. if (<fcttext_metric> isin %wu_temp) set $+(%,wu_df_fcttext_metric_,%wu_period) $remove(%wu_temp,<fcttext_metric>,</fcttext_metric>,$chr(9))
  324. if (<pop> isin %wu_temp) set $+(%,wu_df_pop_,%wu_period) $remove(%wu_temp,<pop>,</pop>,$chr(9))
  325. ; pop = possibility of precipitation
  326. }
  327.  
  328. ;-- Simple Forecast ---
  329. if (%wu_command == !forecast5) {
  330. if (<simpleforecast> isin %wu_temp) set %wu_period 1
  331. ;-- ^ Resets %wu_period to 1 when entering the <simpleforecast> section
  332. if (</forecastday> isin %wu_temp) inc %wu_period
  333. ;-- ^ Need the increase becasue the <period> is after the <weekday>
  334.  
  335. if (<weekday> isin %wu_temp) set $+(%,wu_sf_weekday_,%wu_period) $remove(%wu_temp,<weekday>,</weekday>,$chr(9))
  336. if (<high> isin %wu_temp) set %wu_sf_temp high
  337. if (<low> isin %wu_temp) set %wu_sf_temp low
  338. if (<fahrenheit> isin %wu_temp) set $+(%,wu_sf_fahrenheit_,%wu_sf_temp,_,%wu_period) $+($remove(%wu_temp,<fahrenheit>,</fahrenheit>,$chr(9)),$chr(176),F)
  339. if (<celsius> isin %wu_temp) set $+(%,wu_sf_celsius_,%wu_sf_temp,_,%wu_period) $+($remove(%wu_temp,<celsius>,</celsius>,$chr(9)),$chr(176),C)
  340. if (<conditions> isin %wu_temp) set $+(%,wu_sf_conditions_,%wu_period) $remove(%wu_temp,<conditions>,</conditions>,$chr(9))
  341. }
  342.  
  343. }
  344. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  345. ;--- Variables for Alerts Command ---
  346. if (%wu_command == !alerts) || (%wu_command == !alertinfo) {
  347. ;echo -s %wu_temp
  348. ;set -n %wu_ac <alert count="
  349. ;-- Counts the amount of alerts.
  350. if (<alert> isin %wu_temp) { inc %wu_a_i | inc %wu_a_count }
  351.  
  352. ;-- Writes variables for each alert.
  353. if (<type> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_type) $remove(%wu_temp,<type>,</type>,$chr(9))
  354. if (<description> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_description) $remove(%wu_temp,<description>,</description>,$chr(9))
  355. if (<date> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_date) $remove(%wu_temp,<date>,</date>,$chr(9))
  356. if (<expires> isin %wu_temp) set $+(%,wu_a,%wu_a_i,_expires) $remove(%wu_temp,<expires>,</expires>,$chr(9))
  357. 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 }
  358. if (%wu_msg == ON) {
  359. inc %wu_msg_gc
  360. inc %wu_msg_c
  361. set $+(%,wu_a,%wu_a_i,_message,%wu_msg_c) %wu_temp
  362. }
  363. if (<message> isin %wu_temp) { set %wu_msg ON }
  364. }
  365.  
  366. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  367. ;---- Variables for Almanac ----
  368. if (%wu_command == !almanac) {
  369. if (<airport_code> isin %wu_temp) {
  370. set %wu_airport $remove(%wu_temp,<airport_code>,</airport_code>,$chr(9))
  371. if (%wu_airport == $null) {
  372. set %wu_almanac_error NotFound
  373. sockclose wunderground
  374. wu_sockclose
  375. }
  376. }
  377. if (<temp_high> isin %wu_temp) set %wu_almanac_temp high
  378. if (<temp_low> isin %wu_temp) set %wu_almanac_temp low
  379. if (<normal> isin %wu_temp) set %wu_almanac_rate normal
  380. if (<record> isin %wu_temp) set %wu_almanac_rate record
  381. 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)
  382. 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)
  383. if (<recordyear> isin %wu_temp) set $+(%,wu_almanac_,%wu_almanac_temp,_year) $remove(%wu_temp,<recordyear>,</recordyear>,$chr(9))
  384. }
  385. ;VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
  386. ;---- End of xml ----
  387. if (</response> isin %wu_temp) {
  388. ; 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.
  389. ;echo -s ---- wunderground sockclose ----
  390. sockclose wunderground
  391. wu_sockclose
  392. }
  393. }
  394.  
  395. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  396.  
  397. on *:sockclose:wunderground: {
  398. ; OLD
  399. ; This section has been changed to an alias.
  400. }
  401.  
  402. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  403. ; END SOCKETS
  404. ;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
  405.  
  406. ;-----------------------------------------------------------------------------
  407. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  408. ; RESULT
  409. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  410. ;-----------------------------------------------------------------------------
  411.  
  412. alias wu_sockclose {
  413. ;echo -s Result: wu_sockclose
  414. ;--- Spacers. Such as -|- | and -|
  415. set %wu_space $+($chr(45),$chr(124),$chr(45))
  416. set %wu_space2 $+($chr(32),$chr(124),$chr(32))
  417. set %wu_spaceend $+($chr(45),$chr(124))
  418.  
  419. ;--- Removes + sign from address variable
  420. set %wu_address $replace(%wu_address,$chr(43),$chr(32))
  421.  
  422. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  423. ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  424. ; Error? Was there an error?
  425. if (%wu_error == error) {
  426. msg %wu_chan Error: %wu_error_description
  427. wu_cleanup
  428. halt
  429. }
  430.  
  431. if (%wu_results == ON) {
  432. msg %wu_nick %wu_result_count Found. Please be more specific:
  433. set %wu_results_int 1
  434. while (%wu_results_int <= %wu_result_count) {
  435. .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)
  436. inc %wu_results_int
  437. }
  438. .timer 1 %wu_results_int wu_cleanup
  439. halt
  440. }
  441.  
  442. ;-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING-ERROR-CHECKING
  443. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  444.  
  445. if (%wu_command == !weather) {
  446.  
  447. msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(47),%wu_temp_c,$chr(176),C)
  448. }
  449. if (%wu_command == !current) {
  450. msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(47),%wu_temp_c,$chr(176),C) $&
  451. $+ %wu_space2 Heat Index: $+(%wu_heat_index_f,$chr(176),F,$chr(47),%wu_heat_index_c,$chr(176),C)$&
  452. $+ %wu_space2 Winds %wu_wind_string $&
  453. $+ %wu_space2 Windchill: $+(%wu_windchill_f,$chr(176),F,$chr(47),%wu_windchill_c,$chr(176),C) $&
  454. $+ %wu_space2 Pressure: $+(%wu_pressure_in,in,$chr(47),%wu_pressure_mb,mb) $&
  455. $+ %wu_space2 Humidity: %wu_relative_humidity $&
  456. $+ %wu_space2 Dew: $+(%wu_dewpoint_f,$chr(176),F,$chr(47),%wu_dewpoint_c,$chr(176),C) $&
  457. $+ %wu_space2 Visiblity: $+(%wu_visibility_mi,mi,$chr(47),%wu_visibility_km,km)
  458. }
  459. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  460. if (%wu_command == !time) {
  461. ; Military time format (Strait from the code):
  462. msg %wu_chan %wu_full $+ : %wu_local_time_rfc822
  463.  
  464. ; Standard time format (modified):
  465. ;Coming soon, maybe.
  466.  
  467. }
  468.  
  469. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  470. ;To Start, Let see if the location accually exists:
  471. if (%wu_command == !forecast) {
  472. .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
  473. .timer 1 1 msg %wu_chan %wu_df_title_2 $+ : %wu_df_fcttext_2 %wu_space %wu_df_title_3 $+ : %wu_df_fcttext_3
  474. }
  475.  
  476. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  477. if (%wu_command == !forecast5) {
  478. ;echo -s %wu_forecast_count
  479.  
  480. .timer 1 0 .msg %wu_nick Your forecast for %wu_location
  481.  
  482. set %wu_f_i 1
  483. while (%wu_f_i <= %wu_forecast_count) {
  484. ; Setup variables
  485. set %wu_sf_dow $($+(%,wu_sf_weekday_,%wu_f_i),2)
  486. set %wu_sf_con $($+(%,wu_sf_conditions_,%wu_f_i),2)
  487. set %wu_sf_fh $($+(%,wu_sf_fahrenheit_high_,%wu_f_i),2)
  488. set %wu_sf_ch $($+(%,wu_sf_celsius_high_,%wu_f_i),2)
  489. set %wu_sf_fl $($+(%,wu_sf_fahrenheit_low_,%wu_f_i),2)
  490. set %wu_sf_cl $($+(%,wu_sf_celsius_low_,%wu_f_i),2)
  491. ; msg nick: DayOfWeek: CurrentCondition. High: 00°F(00°C) - Low: 00°F(00°C)
  492. .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))
  493. inc %wu_f_i
  494. }
  495. }
  496.  
  497. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  498. if (%wu_command == !alerts) {
  499. ;echo -s --Start of alerts---
  500. if (%wu_a_count == 0) msg %wu_chan %wu_location $+ : No Alerts
  501. if (%wu_a_count > 0) {
  502. msg %wu_chan %wu_location $+ : %wu_a_count Alerts
  503. var %i 1
  504. while (%i <= %wu_a_count) {
  505. .timer 1 %i msg %wu_chan %wu_a_start $($+(%,wu_a,%i,_description),2) till $($+(%,wu_a,%i,_expires),2) %wu_a_end
  506. inc %i
  507. }
  508. .timer 1 %i .notice %wu_nick use $chr(2) !alertinfo $chr(2) [zipcode|city,state|city,country|airport] for alert details
  509. }
  510. }
  511. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  512. if (%wu_command == !alertinfo) {
  513. if (%wu_a_count == 0) msg %wu_chan %wu_location $+ : No Alerts
  514. if (%wu_a_count > 0) {
  515. ;msg %wu_chan %wu_location $+ : %wu_a_count Alerts - See PM for details
  516. .timer 1 1 .msg %wu_nick %wu_location $+ : %wu_a_count Alerts
  517. .timer 1 2 .msg %wu_nick Type STOP at any time to end.
  518.  
  519. set %wu_alert_total_alerts 1
  520. ; Used to count the while loops compaired to the origial totall of Alerts
  521. ; Aka, what Alert are we on.
  522.  
  523. set %wu_alert_timer_msgcount 3
  524. ; Used to tally the message count used for timers
  525.  
  526. while (%wu_alert_total_alerts <= %wu_a_count) { ;Is the tally of alerts less than or equal to the Total a_counts
  527. ;echo -s Total Alerts %wu_alert_total_alerts
  528. set %wu_alert_alert_message 1
  529.  
  530. .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)
  531. inc %wu_alert_timer_msgcount
  532.  
  533. while (%wu_alert_alert_message <= $($+(%,wu_a,%wu_alert_total_alerts,_count),2)) {
  534. ;echo -s Total Alert %wu_alert_total_alerts Messages %wu_alert_alert_message
  535. $+(.,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)
  536.  
  537. inc %wu_alert_alert_message
  538. inc %wu_alert_timer_msgcount
  539. }
  540.  
  541. inc %wu_alert_total_alerts
  542. }
  543. $+(.,timer_wu_,%wu_nick,_,alert_,%wu_alert_total_alerts,_message_End) 1 %wu_alert_timer_msgcount .msg %wu_nick --------- End of Alerts -------
  544.  
  545. }
  546. }
  547. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  548. if (%wu_command == !almanac) {
  549. if (%wu_almanac_error == NotFound) && (%wu_name == $null) msg %wu_chan Location Not Found. Try location near an airport.
  550. if (%wu_almanac_error == $null) && (%wu_name != $null) msg %wu_chan %wu_name Found. No data provided.
  551.  
  552. if (%wu_almanac_error == $null) && (%wu_name == $null) {
  553. .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))
  554. .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
  555. }
  556. }
  557. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  558.  
  559. ;echo -s End-------- of WU $time --------
  560. wu_cleanup
  561. }
  562.  
  563. ;RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
  564.  
  565. :MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  566.  
  567. ;--- Private Message ----
  568. ; -- If user requested !AlertsInfo, and wants to stop the long string of alerts. they can simply type STOP ---
  569. on 1:OPEN:?:*stop*:{
  570. $+(.,timer_wu_,$nick,$chr(42)) off
  571. .msg $nick --------- Alerts Stopped -------
  572.  
  573. }
  574.  
  575. :MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  576.  
  577. alias wu_help {
  578. .timer 1 0 .msg %wu_nick $me $+ ' Weather Commands: (16 lines)
  579. .timer 1 1 .msg %wu_nick !weather !current !forecast !forecast5 !alerts !alertinfo !time !almanac
  580. .timer 1 2 .msg %wu_nick Use above commands with your desired location.
  581. .timer 1 3 .msg %wu_nick !weather [zipcode|city,state|city,country|airport]
  582. .timer 1 4 .msg %wu_nick Examples: !weather 90210 - !weather Beverly Hills, CA - !weather LAX - !weather E2J4C7
  583. .timer 1 5 .msg %wu_nick You can also set a default location for yourself. Just type: !weather REGISTER [location]
  584. .timer 1 6 .msg %wu_nick To remove from the list, simply type !weather REMOVE
  585. .timer 1 7 .msg %wu_nick After you have registure, You can simply use !weather and it will bring up your default
  586. .timer 1 8 .msg %wu_nick -----END OF WEATHER HELP -----
  587. wu_cleanup
  588. }
  589.  
  590. ;=============================================================================
  591. alias wu_cleanup {
  592. ;echo -s End-------- of WU $time --------
  593. unset %wu_*
  594. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement