Weather script for Eggdrop

By RaZ on Jul 13, 2011

Weather script for Eggdrop

<iRoc> !weather Jessore
<iB0T> Jessore, Bangladesh: Haze Temperature: 28°C Feels Like: 34°C Wind(km/h): 7
package require http 2.4
bind pub -!- !weather weather
proc weather {nick uhost hand chan text} {
    set weather(page) http://www.wunderground.com/cgi-bin/findweather/getForecast?query=
    set t [::http::geturl "$weather(page)$text" -timeout 30000]
    set data [::http::data $t]
    set text [lindex [split $text] 0] 
        ::http::cleanup $t

   set l [regexp -all -inline -- {<h1 id="locationName" class=".*?">(.*?)</h1>.*?<div id="curCond">(.*?)</div>.*?<div class="titleSubtle">Temperature</div>.*?<span class="nobr"><span class="b">(.*?)</span>(.*?)</span>.*?<span class="nobr"><span class="b">(.*?)</span>(.*?)</span>.*?<span id="windCompassSpeed" class=".*?" pwsid=".*?" pwsunit=".*?" pwsvariable=".*?" english="" metric="">(.*?)</span>} $data]

   foreach {black a b c d e f g} $l {

       set a [string trim $a " \n"]
       set b [string trim $b " \n"]
       set c [string trim $c " \n"]
       set d [string trim [string map {{&deg;} {} {&nbsp;} {} {\n} {}} $d]]
       set e [string trim $e " \n"]
       set f [string trim [string map {{&deg;} {} {&nbsp;} {} {\n} {}} $f]]
       set g [string trim $g " \n"]    

        putserv "PRIVMSG $chan :$a: $b Temperature: $c°$d Feels Like: $e°$f Wind(km/h): $g"
        return 0
    }
        putserv "privmsg $chan :Sorry, $text Location not found"

}

Comments

Sign in to comment.
fahadmehar   -  Oct 26, 2016

Tcl error [weather]: Illegal characters in URL path

 Respond  
TheWhistler   -  Aug 11, 2012

is there anyway to convert the C to F in the weather bot

 Respond  
chachin   -  Feb 20, 2012

do we have to do .chanset or somethign? what do we do if it dont work?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.