Ford

Google Weather debug version

May 21st, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 10.36 KB | None | 0 0
  1. ;Google ToolBar Weather by Ford_Lawnmower irc.GeekShed.net #Script-Help
  2. alias GweatherTBInit {
  3.   ;Change %MyLocation to the location you want to monitor.
  4.   ;**Note** This does NOT accept airport codes. City,State-City,Country or ZipCode.
  5.   var %MyLocation Hamilton,Ohio
  6.   writeini GoogleWeatherTB.ini Settings Location %MyLocation
  7.   if ($exists($qt($mircdirGoogleWeatherTB/tbwin.dll))) {
  8.     if (!$readini(GoogleWeatherTB.ini,Settings,Left)) writeini GoogleWeatherTb.ini Settings Left 535
  9.     if (!$readini(GoogleWeatherTB.ini,Settings,Size)) writeini GoogleWeatherTb.ini Settings Size 50
  10.     window -ahBfp +d @GoogleWeather $readini(GoogleWeatherTB.ini,Settings,Left) 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
  11.     drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0
  12.     dll $tbwin Attach @GoogleWeather
  13.     dll $tbwin Select @GoogleWeather
  14.     dll $tbwin OnMouse dclick /dGetGoogleWeather
  15.     dll $tbwin OnMouse sclick /GoogleWeatherMove
  16.     window -ar @GoogleWeather
  17.     GetGoogleWeather Window 0 %MyLocation
  18.     .timerGoogleWeatherTB -o 0 100 GetGoogleWeather Window 0 %MyLocation
  19.   }
  20.   else Gettbwin.dll
  21. }
  22. alias -l tbwin return $qt($mircdirGoogleWeatherTB/tbwin.dll)
  23. alias dGetGoogleWeather {
  24.   if ($tbmouse(key) == 1) GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB.ini,Settings,Location)
  25.   else {
  26.     var %Left $calc($readini(GoogleWeatherTB.ini,Settings,Left) $iif($tbmouse(key) == 3,-,+) 10)
  27.     writeini GoogleWeatherTB.ini Settings Left %Left
  28.     window -r @GoogleWeather %Left 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
  29.   }
  30. }
  31. alias GoogleWeatherMove {
  32.   if ($tbmouse(key) != 1) {
  33.     var %Left $calc($readini(GoogleWeatherTB.ini,Settings,Left) $iif($tbmouse(key) == 3,-,+) 1)
  34.     writeini GoogleWeatherTB.ini Settings Left %Left
  35.     window -r @GoogleWeather %Left 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
  36.   }
  37. }
  38. alias tbmouse {
  39.   var %x = $dll($tbwin, GetMouse, NOT_USED)
  40.   var %z = x y key hover win
  41.   if ($findtok(%z, $1, 1, 32)) return $gettok(%x, $ifmatch, 32)
  42.   else return $null
  43. }
  44. on *:Start: {
  45.   if ($readini(GoogleWeatherTB.ini,Settings,Status) != Off) GweatherTBInit
  46. }
  47. alias -l GetGoogleWeather {
  48.   .sockclose QQG.o.o.gleWeatherTB
  49.   sockopen QQG.o.o.gleWeatherTB www.google.com 80
  50.   sockmark QQG.o.o.gleWeatherTB $1 $+(/ig/api?weather=,$urlencode($3-)) $2
  51. }
  52. On *:sockopen:QQG.o.o.gleWeatherTB: {
  53.   if (!$sockerr) {
  54.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.1
  55.     sockwrite -n $sockname User-Agent: Opera 9.6
  56.     sockwrite -n $sockname Host: $sock($sockname).addr
  57.     sockwrite -n $sockname $crlf
  58.   }
  59.   else { sockclose $sockname | return }
  60. }
  61. On *:sockread:QQG.o.o.gleWeatherTB: {
  62.   if ($sockerr) { sockclose $sockname | return }
  63.   else {
  64.     var %GoogleWeather | sockread %GoogleWeather
  65.     echo -gat - %GoogleWeather
  66.     var %OutputMethod $gettok($sock($sockname).mark,1,32)
  67.     if (<problem_cause data=""/> isin %GoogleWeather && %OutputMethod == Dialog) {
  68.       did -ra GoogleWeather 2 $did(GoogleWeather,28) :: No Data found for $did(GoogleWeather,28)
  69.     }
  70.     if ($regex(%GoogleWeather,/<city data="(.*?)"\/>/i) && %OutputMethod == Dialog) {
  71.       dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather
  72.       did -ra GoogleWeather 2 $regml(1) on $fulldate
  73.     }
  74.     if ($regex(%GoogleWeather,/<humidity data="[^:]*:(.*?)"\/>/i) && %OutputMethod == Dialog) {
  75.       did -ra GoogleWeather 32 $regml(1)
  76.     }
  77.     if ($regex(%GoogleWeather,/<wind_condition data="[^:]*:(.*?)"\/>/i) && %OutputMethod == Dialog) {
  78.       did -ra GoogleWeather 33 $regml(1)
  79.     }
  80.     if ($regex(%GoogleWeather,/<day_of_week data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
  81.       var %count 1
  82.       while (%count <= $regml(0)) {
  83.         did -ra GoogleWeather $calc(%count + 6) $regml(%count)
  84.         inc %count
  85.       }
  86.     }  
  87.     if ($regex(%GoogleWeather,/<low data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
  88.       var %count 1
  89.       while (%count <= $regml(0)) {
  90.         did -ra GoogleWeather $calc(%count + 14) $+(Low:,$regml(%count))
  91.         inc %count
  92.       }
  93.     }
  94.     if ($regex(%GoogleWeather,/<high data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
  95.       var %count 1
  96.       while (%count <= $regml(0)) {
  97.         did -ra GoogleWeather $calc(%count + 18) $+(High:,$regml(%count))
  98.         inc %count
  99.       }
  100.     }      
  101.     if ($regex(%GoogleWeather,/<condition data="(.*?)"\/>/gi)) {
  102.       if (%OutputMethod == Window) {
  103.         clear @GoogleWeather
  104.         writeini GoogleWeatherTB.ini Settings Size $calc(42 + ($len($regml(1)) * 8))
  105.         window -r @GoogleWeather $readini(GoogleWeatherTB.ini,Settings,Left) 0 $calc(42 + ($len($regml(1)) * 8)) 31
  106.         drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0          
  107.         drawtext -np @GoogleWeather 1 arial 12 42 0 $+($chr(2),$regml(1))
  108.       }
  109.       elseif (%OutputMethod == Dialog) {
  110.         did -ra GoogleWeather 31 $regml(1)
  111.         var %count 2
  112.         while (%count <= $regml(0)) {
  113.           did -ra GoogleWeather $calc(21 + %count) $regml(%count)
  114.           inc %count
  115.         }
  116.       }
  117.     }
  118.     if ($regex(%GoogleWeather,/<temp_f\sdata="(.*?)"\/>/)) {
  119.       if (%OutputMethod == Window) {
  120.         drawtext -np @GoogleWeather 1 arial 12 42 13 $+($chr(2),$regml(1),$chr(186))
  121.       }
  122.       elseif (%OutputMethod == Dialog) did -ra GoogleWeather 34 $+($regml(1),$chr(186))
  123.     }
  124.     if ($regex(%GoogleWeather,/<icon data="/ig/images/weather/(.*?)"\/>/gi)) {
  125.       GetGoogleWeatherIcon www.google.com $+(/ig/images/weather/,$regml(1)) GoogleWeatherTB $regml(1) %OutputMethod 0
  126.       drawdot @GoogleWeather
  127.       if (%OutputMethod == Dialog) {
  128.         var %c 2
  129.         while (%c <= $regml(0)) {
  130.           GetGoogleWeatherIcon www.google.com $+(/ig/images/weather/,$regml(%c)) GoogleWeatherTB $regml(%c) %OutputMethod %c
  131.           inc %c
  132.         }
  133.       }
  134.     }
  135.   }
  136. }
  137. alias -l GetGoogleWeatherIcon {
  138.   if ($isfile($qt($+($3,\,$4)))) {
  139.     if ($5 == Window) drawpic -ns @GoogleWeather 0 0 35 30 $+(GoogleWeatherTB/,$4)
  140.     elseif (($5 == Dialog)) did -g GoogleWeather $iif($6,$calc($6 + 9),3) $qt($+(GoogleWeatherTB/,$4))
  141.   }
  142.   else {
  143.     var %sockname $+(GetGoogleWeatherIcon,$ticks,$r(1,$ticks))
  144.     if (!$isdir($qt($3))) { mkdir $qt($3) }
  145.     sockopen %sockname $1 80
  146.     sockmark %sockname $1-
  147.   }
  148. }
  149. On *:sockopen:GetGoogleWeatherIcon*:{
  150.   sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0
  151.   sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf
  152. }
  153. On *:sockread:GetGoogleWeatherIcon*:{
  154.   if (!$gettok($sock($sockname).mark,7,32)) {
  155.     var %GetGoogleWeatherIcon | sockread %GetGoogleWeatherIcon
  156.     if (!%GetGoogleWeatherIcon) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }
  157.   }
  158.   else {
  159.     sockread &GetGoogleWeatherIcon
  160.     bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &GetGoogleWeatherIcon
  161.   }
  162. }
  163. On *:sockclose:GetGoogleWeatherIcon*:{
  164.   tokenize 32 $sock($sockname).mark
  165.   if ($exists($qt($+($3,/,$4)))) {
  166.     if ($5 == Window) {
  167.       drawpic -s @GoogleWeather 0 0 35 30 $qt($+($3,/,$4))
  168.     }
  169.     elseif ($5 == Dialog) {
  170.       if (!$6) did -g GoogleWeather 3 $qt($+($3,/,$4))
  171.       else did -g GoogleWeather $calc(9 + $6) $qt($+($3,/,$4))
  172.     }
  173.   }
  174. }
  175. alias -l Gettbwin.dll {
  176.   ;Downloads tbwin.dll v0.3 by dohcan
  177.   ;http://www.mircscripts.org/comments.php?cid=1206
  178.   echo -gat Downloading docking dll. Please wait.....
  179.   if ($isfile($qt(GoogleWeatherTB/tbwin.dll))) .remove $qt(GoogleWeatherTB/tbwin.dll)
  180.   if (!$isdir($qt(GoogleWeatherTB))) mkdir $qt(GoogleWeatherTB)
  181.   sockopen Gettbwin.dll fordlawnmower.googlecode.com 80
  182.   sockmark Gettbwin.dll fordlawnmower.googlecode.com /files/tbwin.dll GoogleWeatherTB tbwin.dll
  183. }
  184. On *:sockopen:Gettbwin.dll:{
  185.   sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0
  186.   sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf
  187. }
  188. On *:sockread:Gettbwin.dll:{
  189.   if (!$gettok($sock($sockname).mark,5,32)) {
  190.     var %Gettbwin.dll | sockread %Gettbwin.dll
  191.     if (!%Gettbwin.dll) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }
  192.   }
  193.   else {
  194.     sockread &Gettbwin.dll
  195.     bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &Gettbwin.dll
  196.   }
  197. }
  198. On *:sockclose:Gettbwin.dll:{
  199.   tokenize 32 $sock($sockname).mark
  200.   if ($exists($qt($+($3,/,$4)))) {
  201.     echo -gat Download complete.
  202.     GweatherTBInit
  203.   }
  204.   else echo -gat Error downloading tbwin.dll
  205. }
  206. alias -l urlencode return $replace($regsubex($1-,/([^a-z0-9\s])/ig,% $+ $base($asc(\t),10,16,2)),$chr(32),+)
  207. menu channel,status,menubar,@GoogleWeather {
  208.   -
  209.   Google Weather
  210.   .$iif($timer(GoogleWeatherTB),$style(3)) On:{
  211.     writeini GoogleWeatherTB.ini Settings Status On
  212.     GweatherTBInit
  213.   }
  214.   .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{
  215.     .timerGoogleWeatherTB off
  216.     window -c @GoogleWeather
  217.     writeini GoogleWeatherTB.ini Settings Status Off
  218.   }
  219.   .Dialogs:dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather
  220. }
  221. On *:dialog:GoogleWeather:Sclick:29: {
  222.   if ($did(28)) getgoogleweather dialog 0 $v1
  223. }
  224. dialog GoogleWeather {
  225.   title "Google Weather"
  226.   size -1 -1 232 129
  227.   option dbu
  228.   text "Current Weather for", 1, 5 2 52 8
  229.   text "", 2, 57 2 168 8
  230.   icon 3, 6 17 20 20
  231.   text "Condition:", 4, 34 14 27 8
  232.   text "Humidity:", 5, 34 24 27 8
  233.   text "Wind:", 6, 34 34 27 8
  234.   text "", 7, 9 54 54 8, center
  235.   text "", 8, 63 54 54 8, center
  236.   text "", 9, 117 54 54 8, center
  237.   text "", 10, 171 54 54 8, center
  238.   icon 11, 26 63 20 20
  239.   icon 12, 80 63 20 20
  240.   icon 13, 134 63 20 20
  241.   icon 14, 186 63 20 20
  242.   text "", 15, 9 87 25 8
  243.   text "", 16, 63 87 25 8
  244.   text "", 17, 117 87 25 8
  245.   text "", 18, 171 87 25 8
  246.   text "", 19, 34 87 29 8
  247.   text "", 20, 88 87 29 8
  248.   text "", 21, 142 87 29 8
  249.   text "", 22, 196 87 29 8
  250.   text "", 23, 9 96 54 16, center
  251.   text "", 24, 63 96 54 16, center
  252.   text "", 25, 117 96 54 16, center
  253.   text "", 26, 171 96 54 16, center
  254.   text "Location:", 27, 9 116 24 8
  255.   edit "", 28, 33 115 110 10, autohs
  256.   button "Check", 29, 148 114 37 12
  257.   button "Close", 30, 188 114 37 12, cancel
  258.   text "", 31, 61 14 164 8
  259.   text "", 32, 61 24 163 8
  260.   text "", 33, 61 34 163 8
  261.   text "", 34, 5 39 25 8, center
  262.   box "", 35, 170 49 54 64
  263.   box "", 36, 62 49 54 64
  264.   box "", 37, 116 49 54 64
  265.   box "", 38, 8 49 54 64
  266. }
Add Comment
Please, Sign In to add comment