Advertisement
Guest User

Untitled

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