Skip to content
General IRCd

Weather Code

A TG007 community discussion started by Rashed.

Discussion 7 posts
Page 1 of 1
Open
Topic #16250 · 7 published posts · 1,786 views

I'm working for Buzzen script many codes of my old script doesn't work so i may need more help

 

this is weather code dosent work

i want it to work in buzzen and for all areas not only USA

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;; weather underground for mIRC ;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;by eqrunner ;;;;



/*

!w or !weather [zipcode|city,state|city,country|airport] will return current conditions.

!forecast [zipcode|city,state|city,country|airport] will give detailed 3 day forecast (for us)

!forecast5 [zipcode|city,state|city,country|airport] will send 5 day forecast to $nick that requested. (to prevent chan flooding)

!alerts [zipcode|city,state|city,country|airport] will tell you if there are any weather alerts in your area.

!alertinfo [zipcode|city,state|city,country|airport] will send $nick the detailed report of alerts in said area

!time [zipcode|city,state|city,country|airport] will return current time.



Notes from wunderground:

We don't support old style abbreviations like Conn. for Connecticut, use CT

If you are searching for an international city, try the name of the country or province

Don't use provinces for non-us cities (ie: Vancouver, BC)

Zipcodes only work in Canada, UK and the US

*/






on $*:text:/^[!](w|weather|forecast|forecast5|alert|alerts|alertinfo|alertsinfo|time)/Si:#: {

unset %wu_*

if ($2 == $null) { .notice $nick Please specify a location $1 [zipcode|city,state|city,country|airport] | halt }

set %wu_command $1

set %wu_address $replace($2-,$chr(32),$chr(43))

set %wu_nick $nick

set %wu_network $network

set %wu_chan $chan



if (%wu_command == !weather) || (%wu_command == !w) || (%wu_command == !time) {

set %wu_link $+(/auto/wui/geo/WXCurrentObXML/index.xml?query=,%wu_address)

set %wu_host api.wunderground.com

sockopen wunderground
%wu_host 80

}

if (%wu_command == !forecast) || (%wu_command == !forecast5) {

set %wu_link $+(/auto/wui/geo/ForecastXML/index.xml?query=,%wu_address)

set %wu_host www.wunderground.com

sockopen wunderground
%wu_host 80



}

if (%wu_command == !alert) set %wu_command !alerts

if (%wu_command == !alertsinfo) set %wu_command !alertinfo

if (%wu_command == !alerts) || (%wu_command == !alertinfo) {

;echo -s pass

set %wu_link $+(/auto/wui/geo/AlertsXML/index.xml?query=,%wu_address)

set %wu_host www.wunderground.com

sockopen wunderground
%wu_host 80

}



;echo -s LINK: %wu_link

}





on *:sockopen:wunderground: {



;sockwrite -n $sockname GET %wu_link XML/1.0

sockwrite -n $sockname GET %wu_link

sockwrite
-n $sockname Host: %wu_host

sockwrite
-n $sockname $crlf

}



on *:sockread:wunderground: {

sockread %wu_temp

;echo -s %wu_temp



if (%wu_command == !weather) || (%wu_command == !w) || (%wu_command == !time) {

; local info

if ( isin %wu_temp) && (%wu_full == $null) %wu_full = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_city == $null) %wu_city = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_state == $null) %wu_state = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_state_name == $null) %wu_state_name = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_country == $null) %wu_country = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_country_iso3166 == $null) %wu_country_iso3166 = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_zip == $null) %wu_zip = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_latitude == $null) %wu_latitude = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_longitude == $null) %wu_longitude = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_elevation == $null) %wu_elevation = $remove(%wu_temp,,,$chr(9))



if ( isin %wu_temp) %wu_local_time = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_local_time_rfc822 = $remove(%wu_temp,,,$chr(9))



; current weather

if ( isin %wu_temp) %wu_weather = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_temperature_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_temp_f = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_temp_c = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_relative_humidity = $remove(%wu_temp,,,$chr(9))



; wind

if ( isin %wu_temp) %wu_wind_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_wind_dir = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_wind_degrees = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_wind_mph = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_wind_gust_mph = $remove(%wu_temp,,,$chr(9))



if ( isin %wu_temp) %wu_pressure_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_pressure_mb = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_pressure_in = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_dewpoint_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_dewpoint_f = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_dewpoint_c = $remove(%wu_temp,,,$chr(9))



if ( isin %wu_temp) %wu_heat_index_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_heat_index_f = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_heat_index_c = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_windchill_string = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_windchill_f = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_windchill_c = $remove(%wu_temp,,,$chr(9))



if ( isin %wu_temp) %wu_visibility_mi = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) %wu_visibility_km = $remove(%wu_temp,,,$chr(9))

}



if (%wu_command == !forecast) || (%wu_command == !forecast5) {

if ( isin %wu_temp) set %wu_period $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) set %wu_xtemp 1

if ( isin %wu_temp) set %wu_xtemp 2

if ( isin %wu_temp) set %wu_simpleforecast 1



if ( isin %wu_temp) && (%wu_period == 1) %wu_f1_title = $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) && (%wu_period == 1) %wu_f1_fcttext = $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) && (%wu_period == 2) %wu_f2_title = $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) && (%wu_period == 2) %wu_f2_fcttext = $remove(%wu_temp,,,$chr(9))



if (%wu_simpleforecast == 1) {

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_weekday) $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_conditions) $remove(%wu_temp,,,$chr(9))

if (%wu_xtemp == 1) {

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_highf) $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_highc) $remove(%wu_temp,,,$chr(9),$chr(32))

}

if (%wu_xtemp == 2) {

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_lowf) $remove(%wu_temp,,,$chr(9),$chr(32))

if ( isin %wu_temp) set $+(%,wu_P,%wu_period,_lowc) $remove(%wu_temp,,,$chr(9),$chr(32))

}

}

}

if (%wu_command == !alerts) || (%wu_command == !alertinfo) {

;echo -s %wu_temp

set -n %wu_ac <alert count="

if (%wu_ac isin %wu_temp) set -n %wu_a_count $remove(%wu_temp,,,$chr(32),$chr(9))

if ( isin %wu_temp) inc %wu_a_i

if ( isin %wu_temp) set $+(%,wu_a,%wu_a_i,_type) $remove(%wu_temp,,,$chr(9))

if ( isin %wu_temp) set $+(%,wu_a,%wu_a_i,_description) $remove(%wu_temp,,,$chr(9))

if (<date epoch isin %wu_temp) set $+(%,wu_a,%wu_a_i,_date) $right($remove(%wu_temp,,,$chr(9)),-12)

if (<expires epoch isin %wu_temp) set $+(%,wu_a,%wu_a_i,_expires) $right($remove(%wu_temp,,,$chr(9)),-10)

if ( isin %wu_temp) { set %wu_msg OFF | set $+(%,wu_a,%wu_a_i,_count) $(%wu_msg_c,2) | set %wu_msg_c 0 }

if (%wu_msg == ON) {

inc %wu_msg_gc

inc %wu_msg_c

set $+(%,wu_a,%wu_a_i,_message,%wu_msg_c) %wu_temp

}

if ( isin %wu_temp) { set %wu_msg ON }

}

}







on *:sockclose:wunderground: {

var %wu_space = $+($chr(45),$chr(124),$chr(45))

var %wu_spaceend = $+($chr(45),$chr(124))



if (%wu_command == !weather) || (%wu_command == !w) {

set %wu_present $remove(%wu_full,$chr(9),$chr(32),$chr(44))

if (%wu_present == $null) msg %wu_chan Location not found

if (%wu_present != $null) msg %wu_chan %wu_full $+ : %wu_weather and $+(%wu_temp_f,$chr(176),F,$chr(40),%wu_temp_c,$chr(176),C,$chr(41))

}

if (%wu_command == !time) {

msg %wu_chan %wu_full $+ : %wu_local_time

}

if (%wu_command == !forecast) || (%wu_command == !forecast5) {

if (%wu_f1_title != $null) {

var %wu_forecast1 $(%wu_f1_title $+ : %wu_f1_fcttext)

var %wu_forecast2 $(%wu_f2_title $+ : %wu_f2_fcttext)

if (%wu_f2_title != %wu_P2_weekday ) var %wu_forecast3 $(%wu_P2_weekday $+ : %wu_P2_conditions $+ . High: $+(%wu_P2_highf,$chr(176),F) $chr(47) $+(%wu_P2_highc,$chr(176),C) Low: $+(%wu_P2_lowf,$chr(176),F) $chr(47) $+(%wu_P2_lowc,$chr(176),C))

if (%wu_f2_title == %wu_P2_weekday ) var %wu_forecast3 $(%wu_P3_weekday $+ : %wu_P3_conditions $+ . High: $+(%wu_P3_highf,$chr(176),F) $chr(47) $+(%wu_P3_highc,$chr(176),C) Low: $+(%wu_P3_lowf,$chr(176),F) $chr(47) $+(%wu_P3_lowc,$chr(176),C))

.timer 1 0 msg %wu_chan %wu_address $+ : %wu_forecast1

.timer 1 1 msg %wu_chan %wu_forecast2 %wu_space %wu_forecast3 %wu_spaceend

}

if (%wu_f1_title == $null) {

var %wu_forecast1 $(%wu_P1_weekday $+ : %wu_P1_conditions $+ . High: $+(%wu_P1_highf,$chr(176),F,$chr(40),%wu_P1_highc,$chr(176),C,$chr(41)) Low: $+(%wu_P1_lowf,$chr(176),F,$chr(40),%wu_P1_lowc,$chr(176),C,$chr(41)))

var %wu_forecast2 $(%wu_P2_weekday $+ : %wu_P2_conditions $+ . High: $+(%wu_P2_highf,$chr(176),F,$chr(40),%wu_P2_highc,$chr(176),C,$chr(41)) Low: $+(%wu_P2_lowf,$chr(176),F,$chr(40),%wu_P2_lowc,$chr(176),C,$chr(41)))

var %wu_forecast3 $(%wu_P3_weekday $+ : %wu_P3_conditions $+ . High: $+(%wu_P3_highf,$chr(176),F,$chr(40),%wu_P3_highc,$chr(176),C,$chr(41)) Low: $+(%wu_P3_lowf,$chr(176),F,$chr(40),%wu_P3_lowc,$chr(176),C,$chr(41)))

.timer 1 0 msg %wu_chan %wu_address $+ : %wu_forecast1

.timer 1 1 msg %wu_chan %wu_forecast2 %wu_space %wu_forecast3

}

}



if (%wu_command == !forecast5) {

;.timer 1 0 .msg %wu_chan %wu_P1_weekday $+ : %wu_P1_conditions $+ . High: $+(%wu_P1_highf,$chr(176),F,$chr(40),%wu_P1_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P1_lowf,$chr(176),F,$chr(40),%wu_P1_lowc,$chr(176),C,$chr(41))

.timer 1 1 .msg %wu_nick Your forcast for %wu_address

.timer 1 2 .msg %wu_nick %wu_P1_weekday $+ : %wu_P1_conditions $+ . High: $+(%wu_P1_highf,$chr(176),F,$chr(40),%wu_P1_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P1_lowf,$chr(176),F,$chr(40),%wu_P1_lowc,$chr(176),C,$chr(41))

.timer 1 3 .msg %wu_nick %wu_P2_weekday $+ : %wu_P2_conditions $+ . High: $+(%wu_P2_highf,$chr(176),F,$chr(40),%wu_P2_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P2_lowf,$chr(176),F,$chr(40),%wu_P2_lowc,$chr(176),C,$chr(41))

.timer 1 4 .msg %wu_nick %wu_P3_weekday $+ : %wu_P3_conditions $+ . High: $+(%wu_P3_highf,$chr(176),F,$chr(40),%wu_P3_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P3_lowf,$chr(176),F,$chr(40),%wu_P3_lowc,$chr(176),C,$chr(41))

.timer 1 5 .msg %wu_nick %wu_P4_weekday $+ : %wu_P4_conditions $+ . High: $+(%wu_P4_highf,$chr(176),F,$chr(40),%wu_P4_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P4_lowf,$chr(176),F,$chr(40),%wu_P4_lowc,$chr(176),C,$chr(41))

.timer 1 6 .msg %wu_nick %wu_P5_weekday $+ : %wu_P5_conditions $+ . High: $+(%wu_P5_highf,$chr(176),F,$chr(40),%wu_P5_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P5_lowf,$chr(176),F,$chr(40),%wu_P5_lowc,$chr(176),C,$chr(41))

.timer 1 7 .msg %wu_nick %wu_P6_weekday $+ : %wu_P6_conditions $+ . High: $+(%wu_P6_highf,$chr(176),F,$chr(40),%wu_P6_highc,$chr(176),C,$chr(41)) - Low: $+(%wu_P6_lowf,$chr(176),F,$chr(40),%wu_P6_lowc,$chr(176),C,$chr(41))

}



if (%wu_command == !alerts) {

if (%wu_a_count == 0) msg %wu_chan %wu_address $+ : No Alerts

if (%wu_a_count > 0) {

msg %wu_chan %wu_address $+ : %wu_a_count Alerts

var %i 1

while (%i <= %wu_a_count) {

.timer 1 %i msg %wu_chan %wu_a_start $($+(%,wu_a,%i,_description),2) till $($+(%,wu_a,%i,_expires),2) %wu_a_end

inc %i

}

.timer 1 %i .notice %wu_nick use $chr(2) !alertinfo $chr(2) [zipcode|city,state|city,country|airport] for alert details

}

}

if (%wu_command == !alertinfo) {

if (%wu_a_count == 0) msg %wu_chan %wu_address $+ : No Alerts

if (%wu_a_count > 0) {

msg %wu_chan %wu_address $+ : %wu_a_count Alerts - See PM for details

.msg %wu_nick %wu_address $+ : %wu_a_count Alerts

var %i 1 , %i_gc 1

while (%i <= %wu_a_count) {

.timer 1 %i_gc .msg %wu_nick $chr(2) $($+(%,wu_a,%i,_description),2) $chr(2) from $($+(%,wu_a,%i,_date),2) till $($+(%,wu_a,%i,_expires),2)

var %i_msg 1

while (%i_msg <= $($+(%,wu_a,%i,_count),2)) {

.timer 1 %i_gc .msg %wu_nick $($+(%,wu_a,%i,_message,%i_msg),2)

inc %i_gc

inc %i_msg

}

inc %i

}

.timer 1 %i_gc .msg %wu_nick --------- End of Alerts -------

}

}





unset %wu_*

;echo -s End-------- of WU $time --------

}

here is one i made. it uses msg to send to channel. Some scripts may require sockwrite privmsg

weather.txt

Edited Jan 6, 2016 8:34 PM by err0r

Get information about ircWx here

Attachments 1 file

that one works but gives wrong data err0r

 

it gives -3 and i have 25

 

may be inverted !!

you can test results by putting in your query @ http://www.wunderground.com

 

it's possible it could be backwards if the site is pulling Celsius for you instead of Fahrenheit..

 

In that case it would need to be reversed as you said

 

Try this with C conversion instead

weather-c.txt

Edited Jan 6, 2016 8:34 PM by err0r

Get information about ircWx here

Attachments 1 file

When i Replace F to C all the code stop working

 

i check the weather , the result is inverted c is f and f is c

mmmmmmmmmm no

 

it was 38 F the code gives 3.8

and 15.7 C the code gives -15.7

 

problem in calculations

The C version works well , Thank You