alias -l weather { if (!%weather_.position) set %weather_.position 10 if (!%weather_.location) set %weather_.location RSXX0063 if (!%weather_.location2) set %weather_.location2 Moscow, Russia if (!%weather_.units) set %weather_.units m window -Bph +d @weather 0 0 150 25 dll $+(",$scriptdir,tbwin.dll") Attach @weather weatherplace $dll($+(",$scriptdir,tbwin.dll"), GetTBInfo, NOT_USED) dll $+(",$scriptdir,tbwin.dll") OnSize /weatherdraw2 if (!$weather.update) return window -a @weather if (%weather_.autoupd) .timerweather 0 1800 weather.update } alias weather.update { if (!$getweather) { weather.disable | var %temp $input(Failed to connect to the server,dow,Error!) | return 0 } weather.xml return 1 } alias weatherdraw { drawrect -nrf @weather $rgb(255,255,255) 1 0 0 500 25 var %temp var %temp2 if ($numtok($1-,32) == 2) { drawtext -n @weather 1 MS Sans Serif 18 $calc($pic($scriptdiricons\ $+ $2).width + 3) 4 $1 drawpic -n @weather 1 1 $+(",$scriptdiricons\,$2,") set %temp2 $calc($width($1,MS Sans Serif,18) + 6 + $pic($scriptdiricons\ $+ $2).width) set %cur.weather $1- } else { drawtext -n @weather 1 MS Sans Serif 18 3 4 N/A set %temp2 $calc($width(N/A,MS Sans Serif,18) + 6) unset %cur.weather } drawrect -nr @weather $rgb(shadow) 1 0 0 %temp2 25 drawline -nr @weather $rgb(face) 1 4 0 0 0 0 5 drawline -nr @weather $rgb(face) 1 2 1 1 1 1 3 drawline -nr @weather $rgb(shadow) 1 4 1 3 1 1 3 1 5 drawline -nr @weather $rgb(face) 1 $calc(%temp2 - 5) 0 $calc(%temp2 - 1) 0 $calc(%temp2 - 1) 5 drawline -nr @weather $rgb(face) 1 $calc(%temp2 - 3) 1 $calc(%temp2 - 2) 1 $calc(%temp2 - 2) 3 drawline -nr @weather $rgb(shadow) 1 $calc(%temp2 - 5) 1 $calc(%temp2 - 4) 1 $calc(%temp2 - 2) 3 $calc(%temp2 - 2) 5 drawline -nr @weather $rgb(face) 1 0 20 0 24 5 24 drawline -nr @weather $rgb(face) 1 1 22 1 23 3 23 drawline -nr @weather $rgb(shadow) 1 1 20 1 21 3 23 5 23 drawline -nr @weather $rgb(face) 1 $calc(%temp2 - 1) 20 $calc(%temp2 - 1) 24 $calc(%temp2 - 6) 24 drawline -nr @weather $rgb(face) 1 $calc(%temp2 - 2) 22 $calc(%temp2 - 2) 23 $calc(%temp2 - 4) 23 drawline -nr @weather $rgb(shadow) 1 $calc(%temp2 - 2) 20 $calc(%temp2 - 2) 21 $calc(%temp2 - 4) 23 $calc(%temp2 - 6) 23 weatherplace $dll($+(",$scriptdir,tbwin.dll"), GetTBInfo, NOT_USED) %temp2 drawdot @weather return 1 } alias getweather { return $download($+(",$scriptdir,weather.xml"), GET, http://xoap.weather.com/weather/local/ $+ %weather_.location $+ ?cc=*&prod=xoap&par=1018315462&key=5df01b6967eadd9c&unit= $+ %weather_.units, 2) } alias -l download { var %r = $(|,) return $false, %e = scon -r !echo $color(info) -a $!!download: Error - if (!$isid) %e this snippet can only be called as an identifier. %r if ($os isin 9598) %e this snippet requires Windows ME or higher. %r if ($version < 6) %e this snippet requires mIRC version 6.0 or higher. %r var %dir = $nofile($1), %file = $nopath($1), %method = $upper($2), %url = $3 var %bit = $4, %headers = $iif($2 == get,$5,$6), %postdata = " $+ $5", %res if (* !iswm %file) %e you must specify a file to save the data to. %r if (%file != $mkfn(%file)) %e file %file contains illegal characters. %r if (* !iswm %dir) %dir = $mircdir elseif (!$isdir(%dir)) %e no such folder %dir %r if (!$istok(get head post,$2,32)) %e method can only be GET, HEAD or POST. %r if (!$regex(%e,$3,/^\S+\.\S+\.\S+$/)) %e you didn't specify an url to download from. %r if ($2 != head) { if ($4 !isnum 1-3) %e bitmask should be a digit in range 1-3. %r if ($2 == post) && (* !iswm $5) %e you didn't specify any post data. %r if (%headers) && (!$regsub(%e,%headers,/(\S+?): (.+?)(?=\s?\n|$)/g,"\1" $chr(44) "\2",%headers)) { %e bad header syntax. Correct -> Label: value seperated by $!!lf's %r } } var %file = $+(",%dir,%file,"), %id = $+(@download,$ticks,$r(1111,9999),.vbs), %a = aline %id if (http://* !iswm $3) %url = http:// $+ $3 .comopen %id wscript.shell if ($comerr) %e could not open Wscript.Shell. %r write -c %file window -h %id %a on error resume next %a sub quit $lf set http = nothing : set ado = nothing : wscript.quit $lf end sub %a sub errmsg %a set fso = createobject("scripting.filesystemobject") %a set file = fso.createtextfile( %file ,true) %a file.write("Err number: " & err.number & " = " & err.description) : file.close %a set fso = nothing %a quit %a end sub %a arr = array("winhttp.winhttprequest.5.1","winhttp.winhttprequest","msxml2.serverxmlhttp","microsoft.xmlhttp") %a i = 0 $lf while i < 4 and not isobject(http) : set http = createobject(arr(i)) : i = i + 1 : wend %a if not isobject(http) then errmsg %a err.clear %a http.open $+(",%method,") , $+(",%url,") ,false %a http.setrequestheader "User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)" if (%headers) { tokenize 10 %headers | scon -r %a http.setrequestheader $* } if (%method == post) { %a http.setrequestheader "Content-Type","application/x-www-form-urlencoded" %a http.send %postdata } else %a http.send %a if err then errmsg %a set ado = createobject("adodb.stream") %a if not isobject(ado) then errmsg %a ado.open if (%bit != 2) { %a ado.type = 2 : ado.charset = "ascii" %a ado.writetext "HTTP/1.1 " & http.status & " " & http.statustext,1 %a ado.writetext http.getallresponseheaders,1 : ado.position = 0 } if (%bit != 1) %a ado.type = 1 : ado.read : ado.write http.responsebody %a ado.savetofile %file ,2 : ado.close : quit savebuf %id %id close -@ %id .comclose %id $com(%id,run,1,bstr*,%id,uint,0,bool,true) .remove %id %res = $read(%file,t,1) if (Err number:*=* iswm %res) || (!$file(%file)) %e $iif(%res,%res,no data could be retrieved) - %url %r return $true :error if ($com(%id)) .comclose %id if ($isfile(%id)) .remove %id if ($window(%id)) close -@ %id return $false } alias weather.xml { var %a = $dll($+(",$scriptdir,xml.dll"),create_parser,parseweather) if (%a != S_OK) { echo 6 Error - create_parser: %a | return 0 } dll $+(",$scriptdir,xml.dll") set_handler_chardata parseweather weather.data dll $+(",$scriptdir,xml.dll") set_handler_cdata parseweather weather.data dll $+(",$scriptdir,xml.dll") set_file parseweather $+(",$scriptdir,weather.xml") var %a = $dll($+(",$scriptdir,xml.dll"),parse_file,parseweather) if (%a != S_OK) { echo 6 Error - parse_file: %a } dll $+(",$scriptdir,xml.dll") free_parser parseweather if (!$weatherdraw($+(%weather.tmp,°,%weather.ut),%weather.icon $+ .gif)) { var %temp $input(Drawing Error,dow,Error!) | weather.disable | return 0 } unset %weather.* } alias weather.data { var %curelem $gettok($gettok($dll($scriptdirxml.dll,get_abspath,$1),-1,47),-1,58) var %curelem2 $gettok($gettok($dll($scriptdirxml.dll,get_abspath,$1),-2,47),-1,58) if (%curelem2 == head) { if (%curelem == ut) { set %weather.ut $2 } } elseif (%curelem2 == cc) { if (%curelem == tmp) { set %weather.tmp $2 } elseif (%curelem == icon) { set %weather.icon $2 } } } alias weatherplace { window @weather $calc($1 - $iif($3,$iif(%weather_.fromtype,$calc($3 + %weather_.position),$calc($1 - %weather_.position)),110)) $int($calc($calc($2 - 25) / 2)) $iif($3,$3,100) 25 } alias weatherdraw2 { if (!$weatherdraw($gettok(%cur.weather,1,32),$gettok(%cur.weather,2,32),$gettok(%cur.weather,3,32),$gettok(%cur.weather,4,32))) { var %temp $input(Drawing error,dow,Error!) | weather.disable } } dialog weather.calibration { title "Weather script position" size -1 -1 206 60 option pixels edit "", 1, 65 10 74 20, center button ">", 2, 150 10 44 20, flat button "<", 3, 10 10 44 20, flat radio "Left", 4, 10 40 75 14, radio "Right", 5, 150 40 75 14, text "From", 6, 90 39 35 24, } on 1:dialog:weather.calibration:init:*:{ if (!%weather_.position) set %weather_.position 10 did -o $dname 1 1 %weather_.position if (%weather_.fromtype) did -c $dname 5 else did -c $dname 4 } on 1:dialog:weather.calibration:sclick:*:{ if ($did == 2) { $iif(%weather_.fromtype,dec,inc) %weather_.position did -o $dname 1 1 %weather_.position weatherdraw2 } if ($did == 3) { $iif(%weather_.fromtype,inc,dec) %weather_.position did -o $dname 1 1 %weather_.position weatherdraw2 } if ($did == 4) { unset %weather_.fromtype weatherdraw2 } if ($did == 5) { set %weather_.fromtype 1 weatherdraw2 } } on 1:dialog:weather.calibration:edit:*:{ if ($did == 1) { set %weather_.position $did(1).text weatherdraw2 } } alias weather.search.xml { var %t $+(",$scriptdir,xml.dll") var %v parsesearch var %a = $dll(%t,create_parser,%v) if (%a != S_OK) { echo 6 Error - create_parser: %a | return 0 } dll %t set_handler_chardata %v weather.search.data dll %t set_handler_cdata %v weather.search.data dll %t set_handler_attribute %v weather.search.attribute dll %t set_handler_startelement %v weather.search.startelement dll %t set_file %v $+(",$scriptdir,search.xml") var %a = $dll(%t,parse_file,%v) if (%a != S_OK) { echo 6 Error - parse_file: %a } dll %t free_parser %v unset weather.* } alias weather.search.data { var %curelem $gettok($gettok($dll($scriptdirxml.dll,get_abspath,$1),-1,47),-1,58) if (%curelem == loc) { did -i weather.location 2 %weather.temp $2- did -i weather.location 8 %weather.temp %weather.temp2 inc %weather.temp } } alias weather.search.attribute { if ($2 == loc) { if ($3 == id) set %weather.temp2 $4- } } alias weather.search.hendelement { if ($2 == search) { } } alias weather.search.startelement { if ($2 == search) { did -r weather.location 2 did -r weather.location 8 set %weather.temp 1 } } dialog weather.location { title "Search Location" size -1 -1 328 238 option pixels edit "", 1, 10 20 125 20, list 2, 140 20 185 212, extsel hsbar vsbar button "Search", 3, 10 50 125 27, button "Set as default", 4, 10 160 125 27, disable button "Ok", 5, 10 206 60 27, ok icon 6, 10 83 120 70, $scriptdiricons\TWClogo_64px.gif, 0, button "Cancel", 7, 75 206 60 27, cancel list 8, 310 0 15 15, disable hide } on 1:dialog:weather.location:init:*:{ did -i $dname 1 1 %weather_.location2 did -t $dname 3 did -z $dname 2 } on 1:dialog:weather.location:sclick:*:{ if ($did == 2) { if ($did(2).seltext) did -e $dname 4 } if ($did == 3) { if (!$did(1).text) { var %a $input(There is no search request!,dow,Error) | halt } did -b $dname 3 if ($download($+(",$scriptdir,search.xml"), GET, http://xoap.weather.com/search/search?where= $+ $replace($did(1).text,$chr(32),$+($chr(37),20)), 2)) weather.search.xml did -e $dname 3 did -b $dname 4 } if ($did == 4) { set %weather.location $did(8,$did(2,1).sel).text set %weather.location2 $did(2,$did(2,1).sel).text did -i $dname 1 1 $did(2,$did(2,1).sel).text } if ($did == 5) { set %weather_.location %weather.location set %weather_.location2 %weather.location2 unset %weather.* if (!$weather.update) return } if ($did == 6) { run http://www.weather.com/?prod=xoap&par=1018315462 } if ($did == 7) { unset %weather.* } } menu @weather { %weather_.location2 :dialog -mn weather.location weather.location - Update:{ weather.update .timerweather off if (%weather_.autoupd) .timerweather 0 1800 weather.update } - Change position:dialog -mn weather.calibration weather.calibration Units .$iif(%weather_.units == s,$style(3)) Standart:{ set %weather_.units s | weather.update } .$iif(%weather_.units == m,$style(3)) Metric:{ set %weather_.units m | weather.update } $iif(%weather_.autoupd,$style(1)) Autoupdate: { if (%weather_.autoupd) unset %weather_.autoupd else { set %weather_.autoupd on | .timerweather 0 1800 weather.update } } $iif(%weather_.autorun,$style(1)) Autorun: { if (%weather_.autorun) unset %weather_.autorun else set %weather_.autorun on } - Disable weather bar:weather.disable } menu status,menubar { Weather .$iif($window(@weather),Disable,Enable) Weather bar:{ if (!$window(@weather)) weather else { window -c @weather | .timerweather* off } } .Unload script:unload -rs $scriptdirweather.mrc } on *:START:{ if (%weather_.autorun) weather } on *:LOAD:{ if ($version < 6.17) { var %temp $input(This script is for mIRC 6.17 only,ow,Erorr!) | unload -rs $scriptdirweather.mrc } set %weather_.fromtype 1 } on *:UNLOAD:{ unset %weather.* unset %weather_.* unset %cur.weather window -c @weather } alias -l weather.disable { window -c @weather .timerweather off }