Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;MSN WEATHER AND FORECAST CHECKER;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;By Winz;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;2019;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- on ^*:NOTICE:*:*: { if (notices turned off isin $rawmsg) && (%whelp == 1) { msg $chan %kfont $nick your User to User notices are off, you will need to enable them to view weather help, do this in Options (Where you set your font style/color) then try !whelp again.
- }
- }
- on *:TEXT:*!whelp*:#: { set %whelp 1
- raw notice $chan $nick : %kfont MSN Weather Help. Commands: !w - Gives you current conditions for your saved location with forecast for that day. Usage !w Location ie; !w Rainier Oregon, !w ZipCode, !w City Country (London United Kingdom)
- raw notice $chan $nick : %kfont Use !wc to get Celsius temperature. The first time you use !w Location or !wc Location, your location will be saved and you will only need to use !w or !wc
- raw notice $chan $nick : %kfont !fc or !fcc - Gives you X days forecast for your location (NOTE: Your Location is NOT saved for this yet...). Usage !fc Number Location ie; !fc 5 97048 will give you a 5 day forecast for zip 97048. !fcc 8 Rainier Oregon will give you an 8 Day forecast for that location in (CELSIUS)
- raw notice $chan $nick : %kfont If you need further help, ideas or suggestions please find ????
- unset %whelp
- }
- #weath off
- on *:TEXT:*!w*:#: { if (!w !isin $1) { halt }
- var %w $sstyle($1-) | tokenize 32 %w
- if ($sock(msn.weather.*)) { msg $chan %kfont A weather check is already in progress, please wait $nick (Y) | halt
- }
- if (%fp !== $null) { msg $chan %kfont I do not want to flood weather check, please wait $var(%fp,1).secs seconds to check again. Thanks (H)(Y) | halt
- }
- if (c isin $1) { set %msn.corf &weadegreetype=C
- }
- if ($2- !== $null) && ($read(wdb.txt, s, $nick) == $null) {
- set %wnick $nick
- set %wchan $chan
- write wdb.txt $nick $2- | msg $chan %kfont $nick $2- SAVED! Just type !w for your saved weather info. (H) | wcheck | halt
- }
- if ($2- !== $null) && ($read(wdb.txt, s, $nick) !== $null) { var %a $read(wdb.txt, s, $nick) | var %b $readn
- echo $chan %b
- set %wnick $nick
- set %wchan $chan
- write -l $+ %b wdb.txt $nick $2- | msg $chan %kfont $nick $2- Your weather info is updated. (H) | wcheck | halt
- }
- if ($2- == $null) && ($read(wdb.txt, s, $nick) == $null) {
- msg $chan %kfont $nick I do not have your location saved, please use !w location to save it. (Y) | halt
- }
- if ($2- == $null) && ($read(wdb.txt, s, $nick) !== $null) {
- set %wnick $nick
- set %wchan $chan
- wcheck
- }
- }
- alias wcheck {
- set %loca $read(wdb.txt, s, %wnick)
- sockopen msn.weather. $+ $rand(00000000,99999999) www.msn.com 80
- }
- on *:TEXT:*!fc*:#: { if (!fc !isin $1) { halt }
- var %w $sstyle($1-) | tokenize 32 %w
- if ($2 !isalnum) { msg $chan %kfont Please use !forecast 1-9day location, so !forecast 2day 97048 will give you today's forecast and tomorrows forecast for zip 97048 | halt
- }
- if ($3- == $null) { msg $chan %kfont You need to set a location $nick !forecast 1-9day location (ie.97048 or Rainier Oregon, Rainier, OR) | halt
- }
- if (cc isin $1) { set %msn.corf &weadegreetype=C | set %msn.ctf (CELSIUS)
- }
- if ($sock(msn.weather.*)) { msg $chan %kfont A weather check is already in progress, please wait $nick (Y) | halt
- }
- if (%fp !== $null) { msg $chan %kfont I do not want to flood weather check, please wait $var(%fp,1).secs seconds to check again. Thanks (H)(Y) | halt
- }
- set %loca $3-
- set %fcnum $remove($2,day)
- if (%fcnum > 9) { msg $chan %kfont Sorry $nick I can only give you a 9 day forecast, please enter day1-9. | unset %loca , %fcnum , %msn.* | halt }
- set %wnick $nick
- set %wchan $chan
- sockopen msn.forecast. $+ $rand(00000000,99999999) www.msn.com 80
- }
- on *:sockread:msn.weather.*: {
- ;window @ $+ $sockname
- if ($sockerr > 0) { echo 4 -a There was an error loading, please try again! | sockclose $sockname | return }
- :nextread
- sockread -fn %temp | /tokenize 32 %temp
- ;if (%temp !== $null) echo 9 @ $+ $sockname %temp
- if ($sockbr == 0) {
- return
- }
- if (%temp == $null) { %temp = - }
- ;echo 9 @ $+ $sockname %temp
- if (*h2*span* * iswm %temp) { set %msn.ci $htmlfree(%temp)
- }
- if (<span class="current" aria-label= isin %temp) { set %msn.cc $remove(%temp,<,span,class="current" aria-label=",",>,/)
- }
- if (<span>Feels Like</span> isin %temp) { set %msn.fl $htmlfree(%temp) }
- if (<span>Wind</span> isin %temp) { set %msn.wi $htmlfree(%temp) }
- if (<span>Barometer</span> isin %temp) { set %msn.bo $htmlfree(%temp) }
- if (<span>Visibility</span> isin %temp) { set %msn.vi $htmlfree(%temp) }
- if (<span>Humidity</span> isin %temp) { set %msn.hu $htmlfree(%temp) }
- if (<span>Dew Point</span> isin %temp) { set %msn.dp $htmlfree(%temp) }
- if (*?day*1" iswm %temp) { set %t 1 | goto nextread }
- if (%t == 1) && (%temp !== -) { set %msn.fc $remove(%temp,aria-label=",">) | unset %t }
- goto nextread
- }
- on *:sockclose:msn.weather.*: {
- if (cloudy isin %msn.cc) { set %msn.em (cl) }
- if (sunny isin %msn.cc) { set %msn.em (#) }
- if (fair isin %msn.cc) { set %msn.em (r)(#) }
- if (light rain isin %msn.cc) { set %msn.em (rn) }
- if (rain showers isin %msn.cc) { set %msn.em (rn)(um) }
- if (T-Storms isin %msn.cc) { set %msn.em (st) }
- if (clear isin %msn.cc) { set %msn.em (*) }
- if (partly sunny isin %msn.cc) { set %msn.em (cl)(#) }
- if (mostly sunny isin %msn.cc) { set %msn.em (#) }
- if (snow isin %msn.cc) { set %msn.em (**) }
- if (%msn.corf == $null) {
- MSG %wchan : %kfont %wnick Weather for: %msn.ci $+ , %msn.em $+ %msn.cc $+ %msn.em $+ , %msn.fl $+ , %msn.wi $+ , %msn.bo $+ , %msn.vi $&
- $+ , %msn.hu $+ , %msn.dp
- MSG %wchan : %kfont %msn.fc $+ .
- }
- if (%msn.corf !== $null) {
- MSG %wchan : %kfont %wnick Weather for: %msn.ci $+ (CELSIUS) , %msn.em $+ %msn.cc $+ %msn.em $+ , %msn.fl $+ , %msn.wi $+ , %msn.bo $+ , %msn.vi $&
- $+ , %msn.hu $+ , %msn.dp
- MSG %wchan : %kfont %msn.fc $+ .
- }
- unset %msn.* | unset %t
- set -u5 %fp 1
- }
- ;on *:sockwrite:msn.weather.*: { echo 8 @ $+ $sockname % }
- on *:sockopen:msn.weather.*: {
- if ($sockerr) { echo -aci1 info * /MSNweather: socket error $+($chr(40),$sockerr,$chr(41)) | unset $+(%,$sockname,*) | return }
- ;window $+(@,$sockname)
- sockwrite -nt $sockname GET /en-us/weather/today/ $+ $remove(%loca,$chr(32)) $+ /we-city?q= $+ $replace(%loca,$chr(32),$chr(45)) $+ &form=PRWLAS $+ %msn.corf HTTP/1.1
- ;sockwrite -nt $sockname User-Agent: Android/OS
- sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0) Chrome/64.0.3282.140 Safari/537.36
- sockwrite -nt $sockname Vary: Accept-Encoding Header
- sockwrite -nt $sockname Accept-Language: en-US
- sockwrite -nt $sockname Accept: text/html
- sockwrite -nt $sockname Cache-Control: no-cache
- ;sockwrite -nt $sockname Upgrade-Insecure-Requests: 1
- ;sockwrite -nt $sockname Accept-Encoding: gzip, deflate
- sockwrite -nt $sockname Host: www.msn.com:443
- sockwrite -nt $sockname DNT: 1
- sockwrite -nt $sockname Connection: close
- sockwrite -n $sockname $str($crlf,2)
- }
- on *:sockopen:msn.forecast.*: {
- if ($sockerr) { echo -aci1 info * /MSNweather: socket error $+($chr(40),$sockerr,$chr(41)) | unset $+(%,$sockname,*) | return }
- ;window $+(@,$sockname)
- sockwrite -nt $sockname GET /en-us/weather/today/ $+ $remove(%loca,$chr(32)) $+ /we-city?q= $+ $replace(%loca,$chr(32),$chr(45)) $+ &form=PRWLAS $+ %msn.corf HTTP/1.1
- ;sockwrite -nt $sockname User-Agent: Android/OS
- sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0) Chrome/64.0.3282.140 Safari/537.36
- sockwrite -nt $sockname Vary: Accept-Encoding Header
- sockwrite -nt $sockname Accept-Language: en-US
- sockwrite -nt $sockname Accept: text/html
- sockwrite -nt $sockname Cache-Control: no-cache
- ;sockwrite -nt $sockname Upgrade-Insecure-Requests: 1
- ;sockwrite -nt $sockname Accept-Encoding: gzip, deflate
- sockwrite -nt $sockname Host: www.msn.com:443
- sockwrite -nt $sockname DNT: 1
- sockwrite -nt $sockname Connection: close
- sockwrite -n $sockname $str($crlf,2)
- }
- on *:sockread:msn.forecast.*: {
- ;window @ $+ $sockname
- if ($sockerr > 0) { echo 4 -a There was an error loading, please try again! | sockclose $sockname | return }
- :nextread
- sockread -fn %temp | /tokenize 32 %temp
- ;if (%temp !== $null) echo 9 @ $+ $sockname %temp
- if ($sockbr == 0) {
- return
- }
- if (*h2*span* * iswm %temp) { set %msn.ci $htmlfree(%temp)
- }
- if (%temp == $null) { %temp = - | goto nextread }
- ;echo 9 @ $+ $sockname %temp
- if (*Daily Forecast* iswm %temp) { set %t 1 | goto nextread }
- if (%t <= %fcnum) {
- if (*?day* $+ %t $+ " iswm %temp) { var %s 1 | goto nextread }
- if (%s == 1) && (%temp !== -) { set %msn.fc $+ %t $remove(%temp,aria-label=",">,The forecast for) | inc %t 1 | unset %s }
- goto nextread
- }
- else { goto nextread
- }
- }
- on *:sockclose:msn.forecast.*: {
- if (cloudy isin %msn.fc $+ %t) { set %msn.em (cl) }
- if (sunny isin %msn.fc $+ %t) { set %msn.em (#) }
- if (fair isin %msn.fc $+ %t) { set %msn.em (r)(#) }
- if (light rain isin %msn.fc $+ %t) { set %msn.em (rn) }
- if (rain showers isin %msn.fc $+ %t) { set %msn.em (rn)(um) }
- if (T-Storms isin %msn.fc $+ %t) { set %msn.em (st) }
- if (clear isin %msn.fc $+ %t) { set %msn.em (*) }
- if (partly sunny isin %msn.fc $+ %t) { set %msn.em (cl)(#) }
- if (mostly sunny isin %msn.fc $+ %t) { set %msn.em (#) }
- if (snow isin %msn.fc $+ %t) { set %msn.em (**) }
- MSG %wchan : %kfont %wnick Weather Forecast for: %msn.ci $+ %msn.ctf $+ , %msn.fc1 $+ , %msn.fc2 $+ , %msn.fc3
- if (%msn.fc4 !== $null) {
- MSG %wchan : %kfont %msn.fc4 $+ , %msn.fc5 $+ , %msn.fc6
- }
- if (%msn.fc7 !== $null) {
- MSG %wchan : %kfont %msn.fc7 $+ , %msn.fc8 $+ , $+ %msn.fc9
- }
- .timerfc 1 3 unset %msn.* | .timerfc1 1 3 unset %fcnum | .timerfc2 1 3 unset %t
- set -u5 %fp 1
- }
- alias sstyle { return $regsubex($1-, /\[(?:style\x20.*?|/style)\]/gi,$null) }
- alias -l htmlfree { if ($version > 6.47) {
- var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,;, , ), %x = $replace(%x,',',&,&,°,$chr(176))
- return %x
- }
- if ($version < 6.47) {
- var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,;, , ), %x = $replace(%x,',',&,&)
- return %x
- }
- }
- #weath end
Advertisement
Add Comment
Please, Sign In to add comment