Top

Weather Script v2 (with Dialog)


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Jul 10, 2009
Last Updated  Jul 10, 2009
Tags  2  dialog  mirc  script  socket  v2  version  weather  weatherunderground  wunderground 

Introduction

New weather script I made using dialog. Retrieves more info than the last one...



Grab the Code

menu * {
  -
  Weather: wea
}
alias htmlfree {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
alias wea dialog -m wea wea
dialog wea {
  title "Weather Script"
  size -1 -1 334 356
  option pixels
  button "Close", 1, 259 321 65 25
  edit "", 2, 25 16 288 20  
  button "Search ZIP/Full Location", 3, 87 48 132 25
  box "Weather Forcast and Results", 4, 17 77 308 234
  text "", 5, 25 100 279 17
  text "", 15, 76 275 250 17, center
  text "", 6, 25 124 279 17
  text "", 7, 25 153 279 17
  text "", 8, 26 182 279 17
  text "", 9, 26 211 279 17
  text "", 10, 28 238 279 17
  text "", 13, 28 238 279 17
  text "", 11, 28 323 213 17
}
on *:sockopen:wea: {
  sockwrite -nt $sockname GET /cgi-bin/findweather/getForecast?query= $+ $replace(%wea.search,$chr(32),+) $+ &wuSelect=WEATHER HTTP/1.1
  sockwrite -nt $sockname Host: www.wunderground.com
  sockwrite -nt $sockname $crlf
}
on *:sockread:wea: {
  if (!$sockerr) {
    var %wea
    sockread %wea
    if (*<h1>*</h1>* iswm %wea) {
      hadd -m $sockname Title $htmlfree(%wea)
    }
    if (*<span class="nobr"><span class="b">*</span>&nbsp;&#176;F</span>* iswm %wea) { hadd $sockname Temp $replace($htmlfree(%wea),#176;,$+($chr(186),$chr(32))) }
    if (*style="font-size: 14px;">*</div>* iswm %wea) { hadd -m $sockname Condition $htmlfree(%wea) }
    if (*<nobr>*%</nobr><* iswm %wea) { tokenize 32 %wea | hadd -m $sockname Humidity $htmlfree(%wea) }
    if (*<span class="nobr"><span class="b">*</span>&nbsp;&deg;F</span>*  iswm %wea) { hadd -m $sockname Dewpoint $replace($htmlfree(%wea),&deg;,$chr(186) $+ $chr(32)) }
    if (*<span class="nobr"><span class="b">*</span>&nbsp;mph</span>* iswm %wea) { hadd -m $sockname Windspeed $replace($htmlfree(%wea),&nbsp;,$chr(32)) }
    if (*<b>*</b>&nbsp;in* iswm %wea) { hadd -m $sockname Pressure $replace($htmlfree(%wea),&nbsp;,$chr(32)) }
    if (*<b>*</b>* iswm %wea) { 
      hadd $sockname Clouds $htmlfree(%wea) 
      sockclose wea
      did -a wea 15 $iif(%wea.err != on,$hget(wea,Title),Error: Invalid/Nonspecific Search. Try again.)
      did -a wea 5 $iif(%wea.err != on,Tempurature: $hget(wea,Temp),$chr(32))
      did -a wea 6 $iif(%wea.err != on,Condition: $right($hget(wea,Condition),-2),$chr(32))
      did -a wea 7 $iif(%wea.err != on,Humidity: $right($hget(wea,Humidity),-2),$chr(32))
      did -a wea 8 $iif(%wea.err != on,Dew Point: $hget(wea,Dewpoint),$chr(32))
      did -a wea 9 $iif(%wea.err != on,Wind Speed: $hget(wea,Windspeed),$chr(32))
      did -a wea 10 $iif(%wea.err != on,Pressure: $hget(wea,Pressure),$chr(32))
      did -a wea 13 $iif(%wea.err != on,Clouds: $hget(wea,Clouds),$chr(32))
      did -a wea 11 $+($chr(77),$chr(97),$chr(100),$chr(101),$chr(32),$chr(98),$chr(121),$chr(32),$chr(84),$chr(104),$chr(101),$chr(78),$chr(105),$chr(116),$chr(101),$chr(108),$chr(121),$chr(102),$chr(101))
      unset %wea.*
    }
    if (Scroll down to view a list of all all cities isin %wea) { set %wea.err on | halt }
    if (Click on a column heading to sort this information isin %wea) { set %wea.err on | halt }
    if (There has been an error isin %wea) { set %wea.err on | halt }
  }
}
on *:dialog:wea:*:*: {
  if ($devent == sclick) {
    if ($did == 1) { dialog -x $dname $dname }
    else {
      if (!$sock(wea)) {
        $iif($did(2),set %wea.search $did(2),halt)
        sockopen wea www.wunderground.com 80
      }
    }
  }
}
 

Comments

  (7)  RSS
TheNitelyfe
Comments: 46
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 10, 2009 9:44 am
ALSO THANKS FOR DA HALP RYAN\
WorldDMT
Comments: 171
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 10, 2009 3:22 pm
if (*<nobr>*%</nobr><* iswm %wea) { tokenize 32 %wea | hadd -m $sockname Humidity $htmlfree(%wea) }

why did u put tokenize?

and where is %wea.err

if ($did == 1) { dialog -x $dname $dname } <= -x parameter is only for name so u can put only one $dname like this

if ($did == 1) dialog -x $dname

good job but u can also use sockmark instead hash tables
TheNitelyfe
Comments: 46
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 10, 2009 5:44 pm
About the tokenize part: I edited this crap like 20 times, and I realized I didn't need to tokenize :\ Forgot that part though.

Also I don't really like sockmark and aren't you the one always saying use hash tables? :p

%wea.err is set when you give a bad search and it doesn't return anything.

Updated
Trev
Comments: 12
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 10, 2009 10:58 pm
TheNitenoob lieks to tokenize ERRR'THING ok??

IF U READ TEH CODE CORRECTIVALY U CASN KLEARLY SEEE %WEA.ERR IS A VARYABLE???

-x IS GD IF U WUNT IT 2 LUK MOAR COOEL

ND HE DOESNT NO SOCKMARK TYVM NOOBCAKE.!
WorldDMT
Comments: 171
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 11, 2009 4:51 am
ok i see where %wea.err is set
TheNitelyfe
Comments: 46
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 11, 2009 11:44 pm
OMG WORLDDMT SAID MY SCRIPT IS GOOD

my life is now complete

:}}}}}}}}}}}}}}}}}}}}}}}
MichaelPaul
Comments: 1
 
mIRC Snippet:  Weather Script v2 (with Dialog)
Posted on Jul 14, 2009 10:17 am
Great job. Now if only it could take triggers from the channels and reply, as a bot.

ex:

!weather 12345 or !weather Sacramento, CA

Any plans for this?

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom