chachin

Untitled

Mar 23rd, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 46.94 KB | None | 0 0
  1. ; IRC Weather Server Script
  2. ; by Riamus
  3. ; v1.25
  4. ; #OldGames on Undernet
  5.  
  6. ; In this version, § ( $chr(167) ) is used for linebreaking
  7.  
  8. ctcp *:version: {
  9.   .ctcpreply $nick version IRCWeather v1.25 by Riamus - http://www.KakkoiiTranslations.net/mircscripts/
  10. }
  11.  
  12. on *:start:{
  13.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AutoUpdate) == 1) {
  14.     IWUpdate
  15.   }
  16.   WeatherRegistrationsHash
  17. }
  18.  
  19. on *:load:{
  20.   dialog -m WSetup WSetup
  21. }
  22.  
  23. dialog WSetup {
  24.  
  25.   title "Weather Setup"
  26.   size -1 -1 150 202
  27.   option dbu
  28.  
  29.   box "Channels",10,6 4 59 60
  30.   combo 1,8 12 40 40,autohs
  31.   button "Add",100,50 12 14 10
  32.   button "Rem",101,50 22 14 10
  33.   check "All Channels",102,8 52 40 10
  34.  
  35.   check "Allow Weather in Query",300,75 37 80 10
  36.   check "Check for updates on start",301,75 47 80 10
  37.  
  38.   box "Colors",11,75 5 70 30
  39.   text "Primary:",12,77 12 30 10
  40.   combo 2,110 11 30 10,drop
  41.   text "Secondary:",13,77 23 30 10
  42.   combo 3,110 22 30 10,drop
  43.  
  44.   box "Default Units",15,6 66 139 20
  45.   radio "SI (Celsius, kilometers)",204,8 73 70 10,group
  46.   radio "US (Fahrenheit, miles)",205,80 73 62 10
  47.  
  48.   box "!weather Display Format",14,6 87 139 50
  49.   radio "Location: *, Updated: *, Temp: *, etc.",200,8 94 135 10,group
  50.   radio "Location: * § Updated: * § Temp: * § etc.",201,8 103 135 10
  51.   radio "Custom:",202,8 112 100 10
  52.   edit "",203,8 122 135 10,autohs
  53.  
  54.   box "!forecast Display Format",16,6 137 139 50
  55.   radio "Forecast for: *, Updated: * - Day1: * and *, etc.",206,8 144 135 10,group
  56.   radio "Forecast for: * § Updated: * § Day1: * and * § etc.",207,8 153 135 10
  57.   radio "Custom:",208,8 162 100 10
  58.   edit "",209,8 172 135 10,autohs
  59.  
  60.   button "OK",20,65 190 20 10
  61. }
  62.  
  63. on *:dialog:WSetup:init:0: {
  64.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,FormatNum) == 2) { did -c $dname 201 }
  65.   elseif ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,FormatNum) == 3) { did -c $dname 202 }
  66.   else { did -c $dname 200 }
  67.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,FormatNum.forecast) == 2) { did -c $dname 207 }
  68.   elseif ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,FormatNum.forecast) == 3) { did -c $dname 208 }
  69.   else { did -c $dname 206 }
  70.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,DefaultType) == si) { did -c $dname 204 }
  71.   else { did -c $dname 205 }
  72.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllChans) == 1) { did -c $dname 102 }
  73.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllowQuery) == 1) { did -c $dname 300 }
  74.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AutoUpdate) == 1) { did -c $dname 301 }
  75.   did -a $dname 2 Black
  76.   did -a $dname 2 White
  77.   did -a $dname 2 Blue
  78.   did -a $dname 2 Green
  79.   did -a $dname 2 Red
  80.   did -a $dname 2 Brown
  81.   did -a $dname 2 Purple
  82.   did -a $dname 2 Orange
  83.   did -a $dname 2 Yellow
  84.   did -a $dname 2 Light Green
  85.   did -a $dname 2 Cyan
  86.   did -a $dname 2 Light Cyan
  87.   did -a $dname 2 Royal Blue
  88.   did -a $dname 2 Pink
  89.   did -a $dname 2 Gray
  90.   did -a $dname 2 Light Gray
  91.   did -a $dname 3 Black
  92.   did -a $dname 3 White
  93.   did -a $dname 3 Blue
  94.   did -a $dname 3 Green
  95.   did -a $dname 3 Red
  96.   did -a $dname 3 Brown
  97.   did -a $dname 3 Purple
  98.   did -a $dname 3 Orange
  99.   did -a $dname 3 Yellow
  100.   did -a $dname 3 Light Green
  101.   did -a $dname 3 Cyan
  102.   did -a $dname 3 Light Cyan
  103.   did -a $dname 3 Royal Blue
  104.   did -a $dname 3 Pink
  105.   did -a $dname 3 Gray
  106.   did -a $dname 3 Light Gray
  107.   did -c $dname 2 $iif($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor),$calc($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor) + 1),4)
  108.   did -c $dname 3 $iif($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor),$calc($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor) + 1),10)
  109.   set %cnt 1
  110.   while ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  111.     did -a $dname 1 $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)
  112.     inc %cnt
  113.   }
  114.   did -a $dname 203 $iif($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format),$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format),See Help for codes to use for custom displays)
  115.   did -a $dname 209 $iif($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format.forecast),$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format.forecast),See Help for codes to use for custom displays)
  116.   unset %cnt
  117. }
  118.  
  119. on *:dialog:WSetup:sclick:*:{
  120.   if ($did == 100 && $did($dname,1).text) {
  121.     unset %checkchan
  122.     set %cnt 1
  123.     while (%cnt <= $did($dname,1).lines) {
  124.       if ($did($dname,1).text == $did($dname,1,%cnt)) { set %checkchan 1 }
  125.       inc %cnt
  126.     }
  127.     if (%checkchan != 1) { did -a $dname 1 $did($dname,1).text }
  128.     did -d WSetup 1 0
  129.   }
  130.   if ($did == 101 && $did($dname,1).sel) {
  131.     did -d $dname 1 $did($dname,1).sel
  132.   }
  133.   if ($did == 20) {
  134.     writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings PrimaryColor $iif($calc($did($dname,2).sel - 1) > 9,$calc($did($dname,2).sel - 1),0 $+ $calc($did($dname,2).sel - 1))
  135.     writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings SecondaryColor $iif($calc($did($dname,3).sel - 1) > 9,$calc($did($dname,3).sel - 1),0 $+ $calc($did($dname,3).sel - 1))
  136.     writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings AllChans $iif($did($dname,102).state == 1,1,0)
  137.     writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings AllowQuery $iif($did($dname,300).state == 1,1,0)
  138.     writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings AutoUpdate $iif($did($dname,301).state == 1,1,0)
  139.     if ($did($dname,200).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum 1 | writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format Location: #location, Updated: #time, Temp: #temp, Wind Chill: #wc, Dew Point: #dp, Humidity: #hum, Pressure: #pressure, Conditions: #cond, Wind: #wind, Visibility: #vis }
  140.     elseif ($did($dname,201).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum 2 | writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format Location: #location § Updated: #time § Temp: #temp § Wind Chill: #wc § Dew Point: #dp § Humidity: #hum § Pressure: #pressure § Conditions: #cond § Wind: #wind § Visibility: #vis }
  141.     elseif ($did($dname,202).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum 3 | $iif($did($dname,203).text,writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format $replace($replace($replace($replace($did($dname,203).text,,$chr(32) $ $+ + $ $+ chr(3) $ $+ + $+ $chr(32)),,$chr(32) $ $+ + $ $+ chr(15) $ $+ + $chr(32)),,$chr(32) $ $+ + $ $+ chr(2) $ $+ + $chr(32)),,$chr(32) $ $+ + $ $+ chr(31) $ $+ + $chr(32)),remini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format) }
  142.     if ($did($dname,206).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum.forecast 1 | writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format.forecast Forecast for: #location, Updated: #time - #day1: #temp1 and #cond1, #day2: #temp2 and #cond2, #day3: #temp3 and #cond3, #day4: #temp4 and #cond4, #day5: #temp5 and #cond5 }
  143.     elseif ($did($dname,207).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum.forecast 2 | writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format.forecast Forecast for: #location § Updated: #time § #day1: #temp1 and #cond1 § #day2: #temp2 and #cond2 § #day3: #temp3 and #cond3 § #day4: #temp4 and #cond4 § #day5: #temp5 and #cond5 }
  144.     elseif ($did($dname,208).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings FormatNum.forecast 3 | $iif($did($dname,209).text,writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format.forecast $replace($replace($replace($replace($did($dname,209).text,,$chr(32) $ $+ + $ $+ chr(3) $ $+ + $+ $chr(32)),,$chr(32) $ $+ + $ $+ chr(15) $ $+ + $chr(32)),,$chr(32) $ $+ + $ $+ chr(2) $ $+ + $chr(32)),,$chr(32) $ $+ + $ $+ chr(31) $ $+ + $chr(32)),remini " $+ $scriptdir\IRCWeather.ini $+ " Settings Format.forecast) }
  145.     if ($did($dname,204).state == 1) { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings DefaultType si }
  146.     else { writeini " $+ $scriptdir\IRCWeather.ini $+ " Settings DefaultType us }
  147.     set %cnt 1
  148.     remini " $+ $scriptdir\IRCWeather.ini $+ " Channels
  149.     while (%cnt <= $did($dname,1).lines) {
  150.       writeini " $+ $scriptdir\IRCWeather.ini $+ " Channels Channel $+ %cnt $did($dname,1,%cnt)
  151.       inc %cnt
  152.     }
  153.     unset %cnt
  154.     dialog -c WSetup
  155.   }
  156. }
  157.  
  158.  
  159. alias openmysock {
  160.   set %zipcode $1-
  161.   if ($sock(mysock)) { sockclose mysock }
  162.   sockopen mysock classic.wunderground.com 80
  163. }
  164.  
  165. alias historysock {
  166.   if ($sock(historysock)) { sockclose historysock }
  167.   sockopen historysock classic.wunderground.com 80
  168. }
  169.  
  170. on *:sockopen:mysock: {
  171.   sockwrite -n $sockname get /cgi-bin/findweather/getForecast?query= $+ %zipcode HTTP/1.0
  172.   sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  173.   sockwrite -n $sockname Host: classic.wunderground.com
  174.   sockwrite -n $sockname Accept-Language: en-us
  175.   ;sockwrite -n $sockname Accept-Encoding: gzip, deflate
  176.   sockwrite -n $sockname Accept: */*
  177.   sockwrite -n $sockname
  178. }
  179.  
  180. on *:sockopen:historysock: {
  181.   sockwrite -n $sockname get /history/airport/ $+ %forecast.code $+ / $+ $date(yyyy/mm/dd) $+ /DailyHistory.html HTTP/1.0
  182.   sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  183.   sockwrite -n $sockname Host: classic.wunderground.com
  184.   sockwrite -n $sockname Accept-Language: en-us
  185.   ;sockwrite -n $sockname Accept-Encoding: gzip, deflate
  186.   sockwrite -n $sockname Accept: */*
  187.   sockwrite -n $sockname
  188. }
  189.  
  190. on *:sockread:mysock: {
  191.   if ($sockerr) {
  192.     echo -a Error.
  193.     halt
  194.   }
  195.   else {
  196.     var %temptext
  197.     sockread %temptext
  198.     if (*pwsunit="metric"* iswm %temptext) { set %forcast.cf c }
  199.     if (*<td class="taC" >* iswm %temptext) {
  200.       inc %taC
  201.       if (%taC isnum 6-10) {
  202.         sockread %temptext
  203.         set %forecast.day $+ $calc(%taC - 5) $+ .cond $remove(%temptext,$chr(9))
  204.       }
  205.     }
  206.     if (*<tr class="wHover noBorder"> iswm %temptext) { set %tac 5 }
  207.     if (*<td class="taC" style="width: 20%;">* iswm %temptext) {
  208.       set %forecast.day $+ %daynum $remove($htmlfree(%temptext),$chr(9))
  209.       inc %daynum
  210.     }
  211.     if (*<span style="color: #900;">* iswm %temptext && *C</span> !iswm %temptext) {
  212.       set %forecast.day $+ %daynum2 $+ .temp $gettok($gettok(%temptext,1,38),2,62)
  213.       inc %daynum2
  214.     }
  215.     if (*<span class="b green">* iswm %temptext) {
  216.       set %forecast.day $+ $calc(%taC - 5) $+ .cond %forecast.day [ $+ [ $calc(%taC - 5) ] $+ [ .cond ] ] ( $+ $gettok($gettok(%temptext,2,62),1,60) $+ )
  217.     }
  218.     if (*pwsvariable="tempf"* iswm %temptext && %forecast.temp == N/A) {
  219.       set %forecast.temp $gettok(%temptext,-2,34)
  220.     }
  221.     if (*Windchill:</td> iswm %temptext) {
  222.       sockread %temptext
  223.       sockread %temptext
  224.       set %forecast.wc $gettok($gettok(%temptext,3,62),1,60)
  225.       if (%forecast.cf == c) { set %forecast.wc $calc(%forecast.wc * 9/5 + 32) }
  226.     }
  227.     if (*<td class="full b">*pwsvariable="dewptf"* iswm %temptext) {
  228.       set %forecast.dp $iif($gettok(%temptext,-2,34) isnum,$v1,N/A)
  229.     }
  230.     if (*<td class="full b">*pwsvariable="humidity"* iswm %temptext) {
  231.       set %forecast.humidity $remove($htmlfree(%temptext),$chr(9))
  232.     }
  233.     if (*pwsvariable="baromin"* iswm %temptext && %forecast.psi == N/A) {
  234.       if ($gettok(%temptext,-2,34) isnum && $gettok(%temptext,-2,34) != -9999.00) { set %forecast.psi $v1 in. }
  235.       sockread %temptext
  236.       sockread %temptext
  237.       sockread %temptext
  238.       sockread %temptext
  239.       sockread %temptext
  240.       set %forecast.psi %forecast.psi $remove($htmlfree(%temptext),$chr(9))
  241.     }
  242.     if (*</span>&nbsp;miles</span> iswm %temptext && %forecast.vis == N/A) {
  243.       set %forecast.vis $gettok($gettok(%temptext,3,62),1,60)
  244.     }
  245.     if (*out of 16* iswm %temptext) {
  246.       set %forecast.uv $remove($htmlfree(%temptext),$chr(9))
  247.     }
  248.     if (*Wind:</td> iswm %temptext) {
  249.       set -u5 %forecast.wind.chk On
  250.     }
  251.     if (*</span>&nbsp;mph</span> iswm %temptext && %forecast.wind.chk == On) {
  252.       unset %forecast.wind.chk
  253.       if (*Calm iswm %temptext || $gettok($gettok(%temptext,3,62),1,60) == 0) { set %forecast.wind Calm | goto Records }
  254.       set %forecast.wind $gettok($gettok(%temptext,3,62),1,60) $+ mph
  255.     }
  256.     if (*<span class="nb"> from the </span> iswm %temptext) {
  257.       sockread %temptext
  258.       sockread %temptext
  259.       var %direction = $remove(%temptext,$chr(9))
  260.       if (%direction != Variable && %direction != $null) { var %direction = from the %direction }
  261.       if (%forecast.wind != Calm) { set %forecast.wind %forecast.wind %direction }
  262.     }
  263.     :Records
  264.     if (*<td>Normal * iswm %temptext) {
  265.       sockread %temptext
  266.       sockread %temptext
  267.       set %forecast.avgmax $gettok($gettok(%temptext,3,62),1,60)
  268.       sockread %temptext
  269.       sockread %temptext
  270.       sockread %temptext
  271.       sockread %temptext
  272.       sockread %temptext
  273.       set %forecast.avgmin $gettok($gettok(%temptext,3,62),1,60)
  274.     }
  275.     if (*<td>Record * iswm %temptext) {
  276.       sockread %temptext
  277.       sockread %temptext
  278.       set %forecast.recmax $gettok($gettok(%temptext,3,62),1,60)
  279.       sockread %temptext
  280.       sockread %temptext
  281.       sockread %temptext
  282.       set %forecast.recmaxyear $gettok($htmlfree(%temptext,1,41),1,32)
  283.       sockread %temptext
  284.       sockread %temptext
  285.       set %forecast.recmin $gettok($gettok(%temptext,3,62),1,60)
  286.       sockread %temptext
  287.       sockread %temptext
  288.       sockread %temptext
  289.       set %forecast.recminyear $gettok($htmlfree(%temptext,1,41),1,32)
  290.     }
  291.     if (*<div class="bm10">Updated:* iswm %temptext) {
  292.       set %forecast.time $remove($htmlfree(%temptext),Updated: $+ $chr(32),$chr(9))
  293.     }
  294.     if (*<h1>*</h1> iswm %temptext && *there has been an error* !iswm %temptext) {
  295.       set %forecast.location $remove($htmlfree(%temptext),$chr(9))
  296.     }
  297.     if (*<div class="b" style="font-size:* iswm %temptext) {
  298.       set %forecast.cond $remove($htmlfree(%temptext),$chr(9))
  299.     }
  300.   }
  301.   if (*Click on a column heading to sort this information.* iswm %temptext) {
  302.     set %forecast.location Search Results::
  303.   }
  304.   if (*hidden value* iswm %temptext) {
  305.     set %forecast.code $gettok($gettok(%temptext,3,61),1,32)
  306.     historysock
  307.   }
  308.   if (*<span class="b">Active Advisory:</span>* iswm %temptext) {
  309.     sockread %temptext
  310.     set %forecast.adv $remove($htmlfree(%temptext),$chr(9))
  311.     if ($left(%forecast.adv,1) == $chr(32)) { set %forecast.adv $right(%forecast.adv,-1) }
  312.   }
  313.   if (</BODY> iswm %temptext) {
  314.     if (*Email* iswm %forecast.cond) { set %forecast.cond N/A }
  315.     set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  316.     set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  317.     if (%forecast.type == si) {
  318.       if (%forecast.temp != N/A) { set %forecast.temp $round($calc((%forecast.temp - 32) / 1.8),0) }
  319.       if (%forecast.wc != N/A) { set %forecast.wc $round($calc((%forecast.wc - 32) / 1.8),0) }
  320.       if (%forecast.dp != N/A) { set %forecast.dp $round($calc((%forecast.dp - 32) / 1.8),0) }
  321.       if (%forecast.psi != N/A) { set %forecast.psi $round($calc($gettok(%forecast.psi,1,32) * 33.8653),0) hPA $gettok(%forecast.psi,3-,32) }
  322.       if (%forecast.wind != N/A) { set %forecast.wind $round($calc($gettok(%forecast.wind,1,109) * 1.61),1) $+ km/h $gettok(%forecast.wind,2-,32) }
  323.       if (%forecast.vis != N/A) { set %forecast.vis $round($calc(%forecast.vis * 1.61),1) }
  324.       set %weatherinfo $replace($replace($replace($replace($replace($replace($replace($replace($replace($replace($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format),#location, $+ %SecondaryC $+ %forecast.location $+  $+ %PrimaryC),#time, $+ %SecondaryC $+ %forecast.time $+  $+ %PrimaryC),#temp, $+ %SecondaryC $+ %forecast.temp $+ °C $+  $+ %PrimaryC),#wc, $+ %SecondaryC $+ %forecast.wc $+ °C $+  $+ %PrimaryC),#dp, $+ %SecondaryC $+ %forecast.dp $+ °C $+  $+ %PrimaryC),#hum, $+ %SecondaryC $+ %forecast.humidity $+  $+ %PrimaryC),#pressure, $+ %SecondaryC $+ %forecast.psi $+  $+ %PrimaryC),#cond, $+ %SecondaryC $+ %forecast.cond $+  $+ %PrimaryC),#wind, $+ %SecondaryC $+ %forecast.wind $+  $+ %PrimaryC),#vis, $+ %SecondaryC $+ %forecast.vis kilometers)
  325.     }
  326.     else set %weatherinfo $replace($replace($replace($replace($replace($replace($replace($replace($replace($replace($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format),#location, $+ %SecondaryC $+ %forecast.location $+  $+ %PrimaryC),#time, $+ %SecondaryC $+ %forecast.time $+  $+ %PrimaryC),#temp, $+ %SecondaryC $+ %forecast.temp $+ °F $+  $+ %PrimaryC),#wc, $+ %SecondaryC $+ %forecast.wc $+ °F $+  $+ %PrimaryC),#dp, $+ %SecondaryC $+ %forecast.dp $+ °F $+  $+ %PrimaryC),#hum, $+ %SecondaryC $+ %forecast.humidity $+  $+ %PrimaryC),#pressure, $+ %SecondaryC $+ %forecast.psi $+  $+ %PrimaryC),#cond, $+ %SecondaryC $+ %forecast.cond $+  $+ %PrimaryC),#wind, $+ %SecondaryC $+ %forecast.wind $+  $+ %PrimaryC),#vis, $+ %SecondaryC $+ %forecast.vis miles)
  327.     if (%weather.ctcp == $null && %weather.forecast == $null) {
  328.       if (%forecast.location == N/A || Search Results: isin %forecast.location) { msg %weather.chan  $+ %PrimaryC $+ Invalid location. Please try another location. | resetdata | halt }
  329.  
  330.       var %line.cnt 1
  331.       ; original token is 69
  332.       while (%line.cnt <= $gettok(%weatherinfo,0,167)) {
  333.         msg %weather.chan  $+ %PrimaryC $+ $gettok(%weatherinfo,%line.cnt,167)
  334.         inc %line.cnt
  335.       }
  336.  
  337.  
  338.       if (%forecast.adv) {
  339.         msg %weather.chan  $+ %PrimaryC $+ Active $iif($chr(44) isin %forecast.adv,Advisories:,Advisory:)  $+ %SecondaryC $+ %forecast.adv
  340.       }
  341.       if (!%Weather.Registered) { .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help  $+ %PrimaryC for commands. }
  342.       resetdata
  343.     }
  344.     elseif (%weather.forecast != $null) {
  345.       if (%forecast.location == N/A || Search Results: isin %forecast.location) { msg %weather.chan  $+ %PrimaryC $+ Invalid location. Please try another location. | resetdata | halt }
  346.       if (%forecast.type == si) {
  347.         if (%forecast.day1.temp != N/A) { set %forecast.day1.temp $round($calc((%forecast.day1.temp - 32) / 1.8),0) }
  348.         if (%forecast.day2.temp != N/A) { set %forecast.day2.temp $round($calc((%forecast.day2.temp - 32) / 1.8),0) }
  349.         if (%forecast.day3.temp != N/A) { set %forecast.day3.temp $round($calc((%forecast.day3.temp - 32) / 1.8),0) }
  350.         if (%forecast.day4.temp != N/A) { set %forecast.day4.temp $round($calc((%forecast.day4.temp - 32) / 1.8),0) }
  351.         if (%forecast.day5.temp != N/A) { set %forecast.day5.temp $round($calc((%forecast.day5.temp - 32) / 1.8),0) }
  352.         set %forecastinfo $replace($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format.forecast),#location, $+ %SecondaryC $+ %forecast.location $+  $+ %PrimaryC,#time, $+ %SecondaryC $+ %forecast.time $+  $+ %PrimaryC,#day1,%forecast.day1 $+  $+ %PrimaryC,#temp1, $+ %SecondaryC $+ %forecast.day1.temp $+ °C $+  $+ %PrimaryC,#cond1, $+ %SecondaryC $+ %forecast.day1.cond $+  $+ %PrimaryC,#day2,%forecast.day2 $+  $+ %PrimaryC,#temp2, $+ %SecondaryC $+ %forecast.day2.temp $+ °C $+  $+ %PrimaryC,#cond2, $+ %SecondaryC $+ %forecast.day2.cond $+  $+ %PrimaryC,#day3,%forecast.day3 $+  $+ %PrimaryC,#temp3, $+ %SecondaryC $+ %forecast.day3.temp $+ °C $+  $+ %PrimaryC,#cond3, $+ %SecondaryC $+ %forecast.day3.cond $+  $+ %PrimaryC)
  353.         set %forecastinfo $replace(%forecastinfo,#day4,%forecast.day4 $+  $+ %PrimaryC,#temp4, $+ %SecondaryC $+ %forecast.day4.temp $+ °C $+  $+ %PrimaryC,#cond4, $+ %SecondaryC $+ %forecast.day4.cond $+  $+ %PrimaryC,#day5,%forecast.day5 $+  $+ %PrimaryC,#temp5, $+ %SecondaryC $+ %forecast.day5.temp $+ °C $+  $+ %PrimaryC,#cond5, $+ %SecondaryC $+ %forecast.day5.cond $+  $+ %PrimaryC)
  354.         if (%forecast.day2 == N/A) { set %forecastinfo $deltok(%forecastinfo,-4-,44) }
  355.         elseif (%forecast.day3 == N/A) { set %forecastinfo $deltok(%forecastinfo,-3-,44) }
  356.         elseif (%forecast.day4 == N/A) { set %forecastinfo $deltok(%forecastinfo,-2-,44) }
  357.         elseif (%forecast.day5 == N/A) { set %forecastinfo $deltok(%forecastinfo,-1-,44) }
  358.       }
  359.       else {
  360.         set %forecastinfo $replace($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,Format.forecast),#location, $+ %SecondaryC $+ %forecast.location $+  $+ %PrimaryC,#time, $+ %SecondaryC $+ %forecast.time $+  $+ %PrimaryC,#day1,%forecast.day1 $+  $+ %PrimaryC,#temp1, $+ %SecondaryC $+ %forecast.day1.temp $+ °F $+  $+ %PrimaryC,#cond1, $+ %SecondaryC $+ %forecast.day1.cond $+  $+ %PrimaryC,#day2,%forecast.day2 $+  $+ %PrimaryC,#temp2, $+ %SecondaryC $+ %forecast.day2.temp $+ °F $+  $+ %PrimaryC,#cond2, $+ %SecondaryC $+ %forecast.day2.cond $+  $+ %PrimaryC,#day3,%forecast.day3 $+  $+ %PrimaryC,#temp3, $+ %SecondaryC $+ %forecast.day3.temp $+ °F $+  $+ %PrimaryC,#cond3, $+ %SecondaryC $+ %forecast.day3.cond $+  $+ %PrimaryC)
  361.         set %forecastinfo $replace(%forecastinfo,#day4,%forecast.day4 $+  $+ %PrimaryC,#temp4, $+ %SecondaryC $+ %forecast.day4.temp $+ °F $+  $+ %PrimaryC,#cond4, $+ %SecondaryC $+ %forecast.day4.cond $+  $+ %PrimaryC,#day5,%forecast.day5 $+  $+ %PrimaryC,#temp5, $+ %SecondaryC $+ %forecast.day5.temp $+ °F $+  $+ %PrimaryC,#cond5, $+ %SecondaryC $+ %forecast.day5.cond $+  $+ %PrimaryC)
  362.         if (%forecast.day2 == N/A) { set %forecastinfo $deltok(%forecastinfo,-4-,44) }
  363.         elseif (%forecast.day3 == N/A) { set %forecastinfo $deltok(%forecastinfo,-3-,44) }
  364.         elseif (%forecast.day4 == N/A) { set %forecastinfo $deltok(%forecastinfo,-2-,44) }
  365.         elseif (%forecast.day5 == N/A) { set %forecastinfo $deltok(%forecastinfo,-1-,44) }
  366.       }
  367.       var %line.cnt 1
  368.       ; original token is 69
  369.       while (%line.cnt <= $gettok(%forecastinfo,0,167)) {
  370.         msg %weather.chan  $+ %PrimaryC $+ $gettok(%forecastinfo,%line.cnt,167)
  371.         inc %line.cnt
  372.       }
  373.       if (%forecast.adv) {
  374.         msg %weather.chan  $+ %PrimaryC $+ Active $iif($chr(44) isin %forecast.adv,Advisories:,Advisory:)  $+ %SecondaryC $+ %forecast.adv
  375.       }
  376.       if (!%Weather.Registered) { .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help $+ %PrimaryC for commands. }
  377.       resetdata
  378.     }
  379.     else {
  380.       .timer 1 4 { sendctcp }
  381.     }
  382.     sockclose mysock
  383.     unset %weather.ctcp
  384.     unset %weather.forecast
  385.   }
  386. }
  387.  
  388. on *:sockread:historysock: {
  389.   if ($sockerr) {
  390.     echo -a Error.
  391.     halt
  392.   }
  393.   else {
  394.     var %temptext
  395.     sockread %temptext2
  396.     if (*<td class="indent"><span>Average Humidity</span></td> iswm %temptext2) {
  397.       set %avghum.cnt 1
  398.     }
  399.     if (*<td>* iswm %temptext2 && %avghum.cnt == 1) {
  400.       set %forecast.avghum $remove($htmlfree(%temptext2),$chr(9)) $+ %
  401.       if (%forecast.avghum == /b%) { set %forecast.avghum N/A }
  402.       unset %avghum.cnt
  403.     }
  404.     if (*<td class="indent"><span>Maximum Humidity</span></td> iswm %temptext2) {
  405.       set %maxhum.cnt 1
  406.     }
  407.     if (*<td>* iswm %temptext2 && %maxhum.cnt == 1) {
  408.       set %forecast.maxhum $remove($htmlfree(%temptext2),$chr(9)) $+ %
  409.       if (%forecast.maxhum == /b%) { set %forecast.maxhum N/A }
  410.       unset %maxhum.cnt
  411.     }
  412.     if (*<td class="indent"><span>Minimum Humidity</span></td> iswm %temptext2) {
  413.       set %minhum.cnt 1
  414.     }
  415.     if (*<td>* iswm %temptext2 && %minhum.cnt == 1) {
  416.       set %forecast.minhum $remove($htmlfree(%temptext2),$chr(9)) $+ %
  417.       if (%forecast.minhum == /b%) { set %forecast.minhum N/A }
  418.       unset %minhum.cnt
  419.     }
  420.     if (*</b>&nbsp;in</nobr> iswm %temptext2 && %precip.cnt == 3) {
  421.       set %forecast.precip.rec $gettok($gettok(%temptext2,3,62),1,60)
  422.       if (%forecast.precip.rec == $null) { set %forecast.precip.rec N/A }
  423.       sockread %temptext2
  424.       sockread %temptext2
  425.       sockread %temptext2
  426.       set %forecast.precip.rec.year $gettok($htmlfree(%temptext2,3,62),1,32)
  427.       if (%forecast.precip.rec == N/A) { unset %forecast.precip.rec.year }
  428.       unset %precip.cnt
  429.     }
  430.     if (*</b>&nbsp;in</nobr> iswm %temptext2 && %precip.cnt == 2) {
  431.       set %forecast.precip.avg $gettok($gettok(%temptext2,3,62),1,60)
  432.       if (%forecast.precip.avg == $null) { set %forecast.precip.avg N/A }
  433.       inc %precip.cnt
  434.     }
  435.     if (*</b>&nbsp;in</nobr> iswm %temptext2 && %precip.cnt == 1) {
  436.       set %forecast.precip.cur $gettok($gettok(%temptext2,3,62),1,60)
  437.       inc %precip.cnt
  438.     }
  439.     if (*<td class="indent"><span>Precipitation</span></td> iswm %temptext2) {
  440.       sockread %temptext2
  441.       sockread %temptext2
  442.       set %forecast.precip.cur $gettok($gettok(%temptext2,3,62),1,60)
  443.       if (%forecast.precip.cur == $null) {
  444.         set %forecast.precip.cur N/A
  445.         sockread %temptext2
  446.         sockread %temptext2
  447.         sockread %temptext2
  448.       }
  449.       else {
  450.         sockread %temptext2
  451.         sockread %temptext2
  452.         sockread %temptext2
  453.         sockread %temptext2
  454.         sockread %temptext2
  455.       }
  456.       set %forecast.precip.avg $gettok($gettok(%temptext2,3,62),1,60)
  457.       if (%forecast.precip.avg == $null) {
  458.         set %forecast.precip.avg N/A
  459.         sockread %temptext2
  460.         sockread %temptext2
  461.         sockread %temptext2
  462.       }
  463.       else {
  464.         sockread %temptext2
  465.         sockread %temptext2
  466.         sockread %temptext2
  467.         sockread %temptext2
  468.         sockread %temptext2
  469.       }
  470.       if (- !isin %temptext2 && %temptext2 != $null) {
  471.         set %forecast.precip.rec $gettok($gettok(%temptext2,3,62),1,60)
  472.         sockread %temptext2
  473.         sockread %temptext2
  474.         sockread %temptext2
  475.         set %forecast.precip.rec.year $gettok($htmlfree(%temptext2,3,62),1,32)
  476.       }
  477.     }
  478.     if (*<td class="indent"><span>Month to date precipitation</span></td> iswm %temptext2) {
  479.       sockread %temptext2
  480.       set %forecast.precip.cur.mtd $gettok($gettok(%temptext2,2,62),1,60)
  481.       if (%forecast.precip.cur.mtd == /td) { set %forecast.precip.cur.mtd N/A }
  482.       sockread %temptext2
  483.       set %forecast.precip.avg.mtd $gettok($gettok(%temptext2,2,62),1,60)
  484.       if (%forecast.precip.avg.mtd == /td) { set %forecast.precip.avg.mtd N/A }
  485.     }
  486.     if (*<td class="indent"><span>Year to date precipitation</span></td> iswm %temptext2) {
  487.       sockread %temptext2
  488.       set %forecast.precip.cur.ytd $gettok($gettok(%temptext2,2,62),1,60)
  489.       if (%forecast.precip.cur.ytd == /td) { set %forecast.precip.cur.ytd N/A }
  490.       sockread %temptext2
  491.       set %forecast.precip.avg.ytd $gettok($gettok(%temptext2,2,62),1,60)
  492.       if (%forecast.precip.avg.ytd == /td) { set %forecast.precip.avg.ytd N/A }
  493.     }
  494.     if (*<td class="indent"><span>Snow</span></td> iswm %temptext2) {
  495.       sockread %temptext2
  496.       sockread %temptext2
  497.       set %forecast.snow.cur $gettok($gettok(%temptext2,3,62),1,60)
  498.       if (%forecast.snow.cur == $null) {
  499.         set %forecast.snow.cur N/A
  500.         sockread %temptext2
  501.         sockread %temptext2
  502.         sockread %temptext2
  503.       }
  504.       else {
  505.         sockread %temptext2
  506.         sockread %temptext2
  507.         sockread %temptext2
  508.         sockread %temptext2
  509.         sockread %temptext2
  510.       }
  511.       set %forecast.snow.avg $gettok($gettok(%temptext2,3,62),1,60)
  512.       if (%forecast.snow.avg == $null) {
  513.         set %forecast.snow.avg N/A
  514.         sockread %temptext2
  515.         sockread %temptext2
  516.         sockread %temptext2
  517.       }
  518.       else {
  519.         sockread %temptext2
  520.         sockread %temptext2
  521.         sockread %temptext2
  522.         sockread %temptext2
  523.         sockread %temptext2
  524.       }
  525.       if (- !isin %temptext2 && %temptext2 != $null) {
  526.         set %forecast.snow.rec $gettok($gettok(%temptext2,3,62),1,60)
  527.         sockread %temptext2
  528.         sockread %temptext2
  529.         sockread %temptext2
  530.         set %forecast.snow.rec.year $gettok($htmlfree(%temptext2,3,62),1,32)
  531.       }
  532.       else { set %forecast.snow.rec N/A | set %forecast.snow.rec.year () }
  533.     }
  534.     if (*<td class="indent"><span>Month to date snowfall</span></td> iswm %temptext2) {
  535.       sockread %temptext2
  536.       set %forecast.snow.cur.mtd $gettok($gettok(%temptext2,2,62),1,60)
  537.       if (%forecast.snow.cur.mtd == /td) { set %forecast.snow.cur.mtd N/A }
  538.       sockread %temptext2
  539.       set %forecast.snow.avg.mtd $gettok($gettok(%temptext2,2,62),1,60)
  540.       if (%forecast.snow.avg.mtd == /td) { set %forecast.snow.avg.mtd N/A }
  541.     }
  542.     if (*<td class="indent"><span>Since 1 July snowfall</span></td> iswm %temptext2) {
  543.       sockread %temptext2
  544.       set %forecast.snow.cur.ytd $gettok($gettok(%temptext2,2,62),1,60)
  545.       if (%forecast.snow.cur.ytd == /td) { set %forecast.snow.cur.ytd N/A }
  546.       sockread %temptext2
  547.       set %forecast.snow.avg.ytd $gettok($gettok(%temptext2,2,62),1,60)
  548.       if (%forecast.snow.avg.ytd == /td) { set %forecast.snow.avg.ytd N/A }
  549.     }
  550.     if (*<td class="indent"><span>Snow Depth</span></td> iswm %temptext2) {
  551.       sockread %temptext2
  552.       sockread %temptext2
  553.       if (- !isin %temptext2) { set %forecast.snow.total $gettok($gettok(%temptext2,3,62),1,60) }
  554.     }
  555.     if (</BODY> iswm %temptext2) {
  556.       sockclose historysock
  557.     }
  558.   }
  559. }
  560.  
  561. on *:text:!weather *:#: {
  562.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllChans) == 1) {
  563.     goto display
  564.   }
  565.   set %cnt 1
  566.   while ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  567.     if ($chan == $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  568.       goto display
  569.     }
  570.     inc %cnt
  571.   }
  572.   halt
  573.   :display
  574.   set %daynum 1
  575.   set %daynum2 1
  576.   set %daynum3 1
  577.   if ($2 == help) { weatherhelp $nick | halt }
  578.   set %weather.chan $chan
  579.   set %weather.nick $nick
  580.   if ($hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  581.     set %Weather.Registered 1
  582.     set %Registration.Info $hget(WeatherRegistrations,$network $+ . $+ $nick)
  583.   }
  584.   if ($2 == -si) {
  585.     set %forecast.type si
  586.     var %weather.loc = $3-
  587.     if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  588.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  589.       set %weather.nick $3
  590.     }
  591.   }
  592.   elseif ($2 == -us) {
  593.     set %forecast.type us
  594.     var %weather.loc = $3-
  595.     if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  596.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  597.       set %weather.nick $3
  598.     }
  599.   }
  600.   elseif ($2 == -r) {
  601.     if (!$4) { WeatherRegisterHelp | return }
  602.     WeatherRegister $3-
  603.   }
  604.   else {
  605.     set %forecast.type $iif($gettok(%Registration.Info,1,32),$v1,$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,DefaultType))
  606.     var %weather.loc = $2-
  607.     if ($hget(WeatherRegistrations,$network $+ . $+ $2) && !$3) {
  608.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $2),2-,32)
  609.       set %weather.nick $2
  610.     }
  611.   }
  612.   if (($2 == -si || $2 == -us) && !$3) { return }
  613.   if ($2 != -r) { openmysock $replace(%weather.loc,$chr(32),$chr(37) $+ 20) }
  614.   unset %cnt
  615. }
  616.  
  617. on *:text:!weather *:?: {
  618.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllowQuery) == 1) {
  619.     set %daynum 1
  620.     set %daynum2 1
  621.     set %daynum3 1
  622.     if ($2 == help) { weatherhelp $nick | halt }
  623.     set %weather.chan $nick
  624.     set %weather.nick $nick
  625.     if ($hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  626.       set %Weather.Registered 1
  627.       set %Registration.Info $hget(WeatherRegistrations,$network $+ . $+ $nick)
  628.     }
  629.     if ($2 == -si) {
  630.       set %forecast.type si
  631.       var %weather.loc = $3-
  632.       if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  633.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  634.         set %weather.nick $3
  635.       }
  636.     }
  637.     elseif ($2 == -us) {
  638.       set %forecast.type us
  639.       var %weather.loc = $3-
  640.       if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  641.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  642.         set %weather.nick $3
  643.       }
  644.     }
  645.     elseif ($2 == -r) {
  646.       if (!$4) { WeatherRegisterHelp | return }
  647.       WeatherRegister $3-
  648.     }
  649.     else {
  650.       set %forecast.type $iif($gettok(%Registration.Info,1,32),$v1,$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,DefaultType))
  651.       var %weather.loc = $2-
  652.       if ($hget(WeatherRegistrations,$network $+ . $+ $2) && !$3) {
  653.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $2),2-,32)
  654.         set %weather.nick $2
  655.       }
  656.     }
  657.     if (($2 == -si || $2 == -us) && !$3) { return }
  658.     if ($2 != -r) { openmysock $replace(%weather.loc,$chr(32),$chr(37) $+ 20) }
  659.   }
  660. }
  661.  
  662. on *:text:!forecast *:#: {
  663.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllChans) == 1) {
  664.     goto display
  665.   }
  666.   set %cnt 1
  667.   while ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  668.     if ($chan == $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  669.       goto display
  670.     }
  671.     inc %cnt
  672.   }
  673.   halt
  674.   :display
  675.   set %daynum 1
  676.   set %daynum2 1
  677.   set %daynum3 1
  678.   set %weather.chan $chan
  679.   set %weather.nick $nick
  680.   set %weather.forecast 1
  681.   if ($hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  682.     set %Weather.Registered 1
  683.     set %Registration.Info $hget(WeatherRegistrations,$network $+ . $+ $nick)
  684.   }
  685.   if ($2 == -si) {
  686.     set %forecast.type si
  687.     var %weather.loc = $3-
  688.     if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  689.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  690.       set %weather.nick $3
  691.     }
  692.   }
  693.   elseif ($2 == -us) {
  694.     set %forecast.type us
  695.     var %weather.loc = $3-
  696.     if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  697.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  698.       set %weather.nick $3
  699.     }
  700.   }
  701.   else {
  702.     set %forecast.type $iif($gettok(%Registration.Info,1,32),$v1,$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,DefaultType))
  703.     var %weather.loc = $2-
  704.     if ($hget(WeatherRegistrations,$network $+ . $+ $2) && !$3) {
  705.       var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $2),2-,32)
  706.       set %weather.nick $2
  707.     }
  708.   }
  709.   if (($2 == -si || $2 == -us) && !$3) { return }
  710.   if ($2 != -r) { openmysock $replace(%weather.loc,$chr(32),$chr(37) $+ 20) }
  711.   unset %cnt
  712. }
  713.  
  714. on *:text:!forecast *:?: {
  715.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllowQuery) == 1) {
  716.     set %daynum 1
  717.     set %daynum2 1
  718.     set %daynum3 1
  719.     set %weather.chan $nick
  720.     set %weather.nick $nick
  721.     set %weather.forecast 1
  722.     if ($hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  723.       set %Weather.Registered 1
  724.       set %Registration.Info $hget(WeatherRegistrations,$network $+ . $+ $nick)
  725.     }
  726.     if ($2 == -si) {
  727.       set %forecast.type si
  728.       var %weather.loc = $3-
  729.       if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  730.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  731.         set %weather.nick $3
  732.       }
  733.     }
  734.     elseif ($2 == -us) {
  735.       set %forecast.type us
  736.       var %weather.loc = $3-
  737.       if ($hget(WeatherRegistrations,$network $+ . $+ $3) && !$4) {
  738.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $3),2-,32)
  739.         set %weather.nick $3
  740.       }
  741.     }
  742.     else {
  743.       set %forecast.type $iif($gettok(%Registration.Info,1,32),$v1,$readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,DefaultType))
  744.       var %weather.loc = $2-
  745.       if ($hget(WeatherRegistrations,$network $+ . $+ $2) && !$3) {
  746.         var %weather.loc = $gettok($hget(WeatherRegistrations,$network $+ . $+ $2),2-,32)
  747.         set %weather.nick $2
  748.       }
  749.     }
  750.     if (($2 == -si || $2 == -us) && !$3) { return }
  751.     if ($2 != -r) { openmysock $replace(%weather.loc,$chr(32),$chr(37) $+ 20) }
  752.   }
  753. }
  754.  
  755. ctcp *:weather *:*: {
  756.   haltdef
  757.   set %daynum 1
  758.   set %daynum2 1
  759.   set %daynum3 1
  760.   set %weather.ctcp 1
  761.   set %weather.chan $nick
  762.   set %forecast.type us
  763.   if ($2- == $null) { .notice $nick Please enter a location for weather | halt }
  764.   openmysock $2-
  765. }
  766.  
  767. alias -l htmlfree {
  768.   var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  769.   return %x
  770. }
  771.  
  772. alias weatherhelp {
  773.   set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  774.   set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  775.   msg $1  $+ %PrimaryC $+ IRC Weather HELP:
  776.   msg $1  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ -si/-us  $+ %PrimaryC $+  switches to view weather in International (SI) format (Celsius, kilometers, etc) or US format (Fahrenheit, miles, etc) if the bot doesn't show what you want. Example:  $+ %SecondaryC $+ !weather -si Paris, France
  777.   msg $1  $+ %SecondaryC $+ !weather ******  $+ %PrimaryC $+ - Get weather information for the ZIPCODE *or* CITY, STATE *or* CITY, COUNTRY displayed in the channel
  778.   .timer 1 1 msg $1  $+ %SecondaryC $+ /msg $me !weather ******  $+ %PrimaryC $+ - Get weather information for ZIPCODE *or* CITY, STATE *or* CITY, COUNTRY displayed in private message
  779.   .timer 1 1 msg $1  $+ %SecondaryC $+ !forecast ******  $+ %PrimaryC $+ and $+ %SecondaryC  /msg $me !forecast ******  $+ %PrimaryC $+ - Same as above, but get the 5-day forecast instead
  780.   .timer 1 2 msg $1  $+ %SecondaryC $+ !weather -r  $+ %PrimaryC $+ - Get help on how to register your nick so that you don't have to enter a location and -si/-us every time.
  781.   .timer 1 2 msg $1  $+ %PrimaryC $+ Get the GUI displayer for this script at http://www.KakkoiiTranslations.net/mircscripts/.  Trust me, you at least want to try it once!
  782. }
  783.  
  784. alias sendctcp {
  785.   .ctcp %weather.chan WeatherData : %forecast.location ~ %forecast.time ~ %forecast.temp  ~ %forecast.wc ~ %forecast.dp ~ %forecast.cond ~ %forecast.humidity ~ %forecast.psi ~ %forecast.wind ~ %forecast.vis miles ~ %forecast.uv ~ %forecast.day1 ~ %forecast.day2 ~ %forecast.day3 ~ %forecast.day4 ~ %forecast.day5 ~ %forecast.day1.temp ~ %forecast.day2.temp ~ %forecast.day3.temp ~ %forecast.day4.temp ~ %forecast.day5.temp ~ %forecast.day1.cond ~ %forecast.day2.cond ~ %forecast.day3.cond ~ %forecast.day4.cond ~ %forecast.day5.cond ~ %forecast.avgmax ~ %forecast.avgmin ~ %forecast.recmax ~ %forecast.recmaxyear ~ %forecast.recmin ~ %forecast.recminyear ~ %forecast.avghum ~ %forecast.maxhum ~ %forecast.minhum
  786.   .ctcp %weather.chan WeatherHistory : %forecast.precip.cur ~ %forecast.precip.avg ~ %forecast.precip.rec ~ %forecast.precip.rec.year ~ %forecast.precip.cur.mtd ~ %forecast.precip.avg.mtd ~ %forecast.precip.cur.ytd ~ %forecast.precip.avg.ytd ~ %forecast.snow.cur ~ %forecast.snow.avg ~ %forecast.snow.rec ~ %forecast.snow.rec.year ~ %forecast.snow.cur.mtd ~ %forecast.snow.avg.mtd ~ %forecast.snow.cur.ytd ~ %forecast.snow.avg.ytd ~ %forecast.snow.total ~ %forecast.adv
  787.   resetdata
  788. }
  789.  
  790. alias resetdata {
  791.   set %forecast.avghum N/A
  792.   set %forecast.maxhum N/A
  793.   set %forecast.minhum N/A
  794.   set %forecast.precip.cur N/A
  795.   set %forecast.precip.avg N/A
  796.   set %forecast.precip.rec N/A
  797.   set %forecast.precip.rec.year ()
  798.   set %forecast.precip.cur.mtd N/A
  799.   set %forecast.precip.avg.mtd N/A
  800.   set %forecast.precip.cur.ytd N/A
  801.   set %forecast.precip.avg.ytd N/A
  802.   set %forecast.snow.cur N/A
  803.   set %forecast.snow.avg N/A
  804.   set %forecast.snow.rec N/A
  805.   set %forecast.snow.rec.year ()
  806.   set %forecast.snow.cur.mtd N/A
  807.   set %forecast.snow.avg.mtd N/A
  808.   set %forecast.snow.cur.ytd N/A
  809.   set %forecast.snow.avg.ytd N/A
  810.   set %forecast.snow.total N/A
  811.   set %forecast.location N/A
  812.   set %forecast.time N/A
  813.   set %forecast.temp N/A
  814.   set %forecast.wc N/A
  815.   set %forecast.dp N/A
  816.   set %forecast.avgmax N/A
  817.   set %forecast.avgmin N/A
  818.   set %forecast.recmax N/A
  819.   set %forecast.recmaxyear ()
  820.   set %forecast.recmin N/A
  821.   set %forecast.recminyear ()
  822.   set %forecast.cond N/A
  823.   set %forecast.humidity N/A
  824.   set %forecast.psi N/A
  825.   set %forecast.wind N/A
  826.   set %forecast.vis N/A
  827.   set %forecast.uv N/A
  828.   set %forecast.day1 N/A
  829.   set %forecast.day2 N/A
  830.   set %forecast.day3 N/A
  831.   set %forecast.day4 N/A
  832.   set %forecast.day5 N/A
  833.   set %forecast.day1.temp N/A
  834.   set %forecast.day2.temp N/A
  835.   set %forecast.day3.temp N/A
  836.   set %forecast.day4.temp N/A
  837.   set %forecast.day5.temp N/A
  838.   set %forecast.day1.cond N/A
  839.   set %forecast.day2.cond N/A
  840.   set %forecast.day3.cond N/A
  841.   set %forecast.day4.cond N/A
  842.   set %forecast.day5.cond N/A
  843.   set %daynum 1
  844.   set %daynum2 1
  845.   set %daynum3 1
  846.   unset %forecast.code
  847.   unset %PrimaryC
  848.   unset %SecondaryC
  849.   unset %forecast.adv
  850.   unset %Weather.Registered
  851.   unset %Registration.Info
  852.   set %taC 0
  853. }
  854.  
  855. on *:text:!weather:#: {
  856.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllChans) == 1) {
  857.     goto display
  858.   }
  859.   set %cnt 1
  860.   while ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  861.     if ($chan == $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  862.       goto display
  863.     }
  864.     inc %cnt
  865.   }
  866.   halt
  867.   :display
  868.   set %weather.nick $nick
  869.   set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  870.   set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  871.   if (!$hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  872.     .notice %weather.nick  $+ %PrimaryC $+ Please enter a location for the weather.
  873.     .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help $+ %PrimaryC for commands.
  874.   }
  875.   else {
  876.     set %weather.chan $chan
  877.     var %Registration.Info = $hget(WeatherRegistrations,$network $+ . $+ $nick)
  878.     set %forecast.type $gettok(%Registration.Info,1,32)
  879.     set %Weather.Registered 1
  880.     openmysock $replace($gettok(%Registration.Info,2-,32),$chr(32),$chr(37) $+ 20)
  881.   }
  882.   unset %cnt
  883. }
  884.  
  885. on *:text:!weather:?: {
  886.   set %weather.nick $nick
  887.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllowQuery) == 1) {
  888.     set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  889.     set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  890.     if (!$hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  891.       .notice %weather.nick  $+ %PrimaryC $+ Please enter a location for the weather.
  892.       .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help $+ %PrimaryC for commands.
  893.     }
  894.     else {
  895.       set %weather.chan $nick
  896.       var %Registration.Info = $hget(WeatherRegistrations,$network $+ . $+ $nick)
  897.       set %forecast.type $gettok(%Registration.Info,1,32)
  898.       set %Weather.Registered 1
  899.       openmysock $replace($gettok(%Registration.Info,2-,32),$chr(32),$chr(37) $+ 20)
  900.     }
  901.   }
  902. }
  903.  
  904. on *:text:!forecast:#: {
  905.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllChans) == 1) {
  906.     goto display
  907.   }
  908.   set %cnt 1
  909.   while ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  910.     if ($chan == $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Channels,Channel $+ %cnt)) {
  911.       goto display
  912.     }
  913.     inc %cnt
  914.   }
  915.   halt
  916.   :display
  917.   set %weather.nick $nick
  918.   set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  919.   set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  920.   if (!$hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  921.     .notice %weather.nick  $+ %PrimaryC $+ Please enter a location for the forecast.
  922.     .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help $+ %PrimaryC for commands.
  923.   }
  924.   else {
  925.     set %weather.forecast 1
  926.     set %weather.chan $chan
  927.     var %Registration.Info = $hget(WeatherRegistrations,$network $+ . $+ $nick)
  928.     set %forecast.type $gettok(%Registration.Info,1,32)
  929.     set %Weather.Registered 1
  930.     openmysock $replace($gettok(%Registration.Info,2-,32),$chr(32),$chr(37) $+ 20)
  931.   }
  932.   unset %cnt
  933. }
  934.  
  935. on *:text:!forecast:?: {
  936.   set %weather.nick $nick
  937.   if ($readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,AllowQuery) == 1) {
  938.     set %PrimaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,PrimaryColor)
  939.     set %SecondaryC $readini(" $+ $scriptdir\IRCWeather.ini $+ ",Settings,SecondaryColor)
  940.     if (!$hget(WeatherRegistrations,$network $+ . $+ $nick)) {
  941.       .notice %weather.nick  $+ %PrimaryC $+ Please enter a location for the forecast.
  942.       .notice %weather.nick  $+ %PrimaryC $+ Use  $+ %SecondaryC $+ !weather help $+ %PrimaryC for commands.
  943.     }
  944.     else {
  945.       set %weather.forecast 1
  946.       set %weather.chan $nick
  947.       var %Registration.Info = $hget(WeatherRegistrations,$network $+ . $+ $nick)
  948.       set %forecast.type $gettok(%Registration.Info,1,32)
  949.       set %Weather.Registered 1
  950.       openmysock $replace($gettok(%Registration.Info,2-,32),$chr(32),$chr(37) $+ 20)
  951.     }
  952.   }
  953. }
  954.  
  955. alias WeatherRegister {
  956.   if (!$hget(WeatherRegistrations)) { WeatherRegistrationsHash }
  957.   if ($1 != us && $1 != si) { WeatherRegisterHelp | return }
  958.   hadd WeatherRegistrations $network $+ . $+ $nick $1 $2-
  959.   hsave WeatherRegistrations WeatherRegistrations.hsh
  960.   .notice $nick Your nick information has been registered.
  961. }
  962.  
  963. alias WeatherRegisterHelp {
  964.   .notice $nick IRCWeather Registration Help
  965.   .notice $nick To register your nick and location, use the following format:  03!weather -r si/us location - Replace "location" with a valid location and replace si/us with your preference of either si (Celsius) or us (Fahrenheit).  This will register the information for your CURRENT nickname only.  Note that registrations are not protected and anyone can change them.  If someone keeps changing yours, let the bot owner know.
  966. }
  967.  
  968. alias WeatherRegistrationsHash {
  969.   if (!$hget(WeatherRegistrations)) {
  970.     hmake WeatherRegistrations 100
  971.     if ($exists(WeatherRegistrations.hsh)) { hload WeatherRegistrations WeatherRegistrations.hsh }
  972.   }
  973. }
  974.  
  975. menu * {
  976.   IRCWeather
  977.   .Setup:/dialog -m WSetup WSetup
  978.   .Check for Updates:IWUpdate
  979.   .Download Server Version:.run http://www.kakkoiitranslations.net/mircscripts/IRCWeatherServer.rar
  980.   .Help:.run " $+ $scriptdirWeather.CHM $+ "
  981. }
  982.  
  983. ; ***************************** UPDATE SCRIPT ******************************
  984.  
  985. alias IWUpdate {
  986.   sockopen Update www.kakkoiitranslations.net 80
  987. }
  988.  
  989. on *:sockopen:Update: {
  990.   sockwrite -n $sockname GET /mircscripts/IRCWeather.html HTTP/1.0
  991.   sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  992.   sockwrite -n $sockname Host: www.kakkoiitranslations.net $+ $crlf $+ $crlf
  993.   sockwrite -n $sockname Accept-Language: en-us
  994.   sockwrite -n $sockname Accept-Encoding: gzip, deflate
  995.   sockwrite -n $sockname Accept: */*
  996. }
  997.  
  998. on *:sockread:Update: {
  999.   if ($sockerr) {
  1000.     echo -a Error.
  1001.     halt
  1002.   }
  1003.   else {
  1004.     var %updatetext
  1005.     sockread %updatetext
  1006.     if (*size:24.0pt'>IRC Weather* iswm %updatetext) {
  1007.       if ($gettok($gettok(%updatetext,3,32),1,60) == 1.25) {
  1008.         echo -a 10IRCWeather: You have the current version.
  1009.       }
  1010.       else {
  1011.         echo -a 10IRCWeather: An update (v $+ $gettok($gettok(%updatetext,3,32),1,60) $+ ) is available at http://www.KakkoiiTranslations.net/mircscripts/
  1012.       }
  1013.     }
  1014.     if (</BODY> iswm %updatetext) {
  1015.       sockclose update
  1016.     }
  1017.   }
  1018. }
Advertisement
Add Comment
Please, Sign In to add comment