pony

working weather

Apr 19th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.41 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;;;;;;;MSN WEATHER AND FORECAST CHECKER;;;;;;;;;;
  3. ;;;;;;;;;;;;;;;;;;;;;By Winz;;;;;;;;;;;;;;;;;;;;;;;
  4. ;;;;;;;;;;;;;;;;;;;;;;2019;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6. 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.
  7. }
  8. }
  9. on *:TEXT:*!whelp*:#: { set %whelp 1
  10. 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)
  11. 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
  12. 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)
  13. raw notice $chan $nick : %kfont If you need further help, ideas or suggestions please find ????
  14. unset %whelp
  15. }
  16. #weath off
  17. on *:TEXT:*!w*:#: { if (!w !isin $1) { halt }
  18. var %w $sstyle($1-) | tokenize 32 %w
  19. if ($sock(msn.weather.*)) { msg $chan %kfont A weather check is already in progress, please wait $nick (Y) | halt
  20. }
  21. 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
  22. }
  23. if (c isin $1) { set %msn.corf &weadegreetype=C
  24. }
  25. if ($2- !== $null) && ($read(wdb.txt, s, $nick) == $null) {
  26. set %wnick $nick
  27. set %wchan $chan
  28. write wdb.txt $nick $2- | msg $chan %kfont $nick $2- SAVED! Just type !w for your saved weather info. (H) | wcheck | halt
  29. }
  30. if ($2- !== $null) && ($read(wdb.txt, s, $nick) !== $null) { var %a $read(wdb.txt, s, $nick) | var %b $readn
  31. echo $chan %b
  32. set %wnick $nick
  33. set %wchan $chan
  34. write -l $+ %b wdb.txt $nick $2- | msg $chan %kfont $nick $2- Your weather info is updated. (H) | wcheck | halt
  35. }
  36. if ($2- == $null) && ($read(wdb.txt, s, $nick) == $null) {
  37. msg $chan %kfont $nick I do not have your location saved, please use !w location to save it. (Y) | halt
  38. }
  39. if ($2- == $null) && ($read(wdb.txt, s, $nick) !== $null) {
  40. set %wnick $nick
  41. set %wchan $chan
  42. wcheck
  43. }
  44. }
  45. alias wcheck {
  46. set %loca $read(wdb.txt, s, %wnick)
  47. sockopen msn.weather. $+ $rand(00000000,99999999) www.msn.com 80
  48. }
  49. on *:TEXT:*!fc*:#: { if (!fc !isin $1) { halt }
  50. var %w $sstyle($1-) | tokenize 32 %w
  51. 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
  52. }
  53. 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
  54. }
  55. if (cc isin $1) { set %msn.corf &weadegreetype=C | set %msn.ctf (CELSIUS)
  56. }
  57. if ($sock(msn.weather.*)) { msg $chan %kfont A weather check is already in progress, please wait $nick (Y) | halt
  58. }
  59. 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
  60. }
  61. set %loca $3-
  62. set %fcnum $remove($2,day)
  63. 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 }
  64. set %wnick $nick
  65. set %wchan $chan
  66. sockopen msn.forecast. $+ $rand(00000000,99999999) www.msn.com 80
  67. }
  68. on *:sockread:msn.weather.*: {
  69. ;window @ $+ $sockname
  70. if ($sockerr > 0) { echo 4 -a There was an error loading, please try again! | sockclose $sockname | return }
  71. :nextread
  72. sockread -fn %temp | /tokenize 32 %temp
  73. ;if (%temp !== $null) echo 9 @ $+ $sockname %temp
  74. if ($sockbr == 0) {
  75. return
  76. }
  77. if (%temp == $null) { %temp = - }
  78. ;echo 9 @ $+ $sockname %temp
  79. if (*h2*span* * iswm %temp) { set %msn.ci $htmlfree(%temp)
  80. }
  81. if (<span class="current" aria-label= isin %temp) { set %msn.cc $remove(%temp,<,span,class="current" aria-label=",",>,/)
  82. }
  83. if (<span>Feels Like</span> isin %temp) { set %msn.fl $htmlfree(%temp) }
  84. if (<span>Wind</span> isin %temp) { set %msn.wi $htmlfree(%temp) }
  85. if (<span>Barometer</span> isin %temp) { set %msn.bo $htmlfree(%temp) }
  86. if (<span>Visibility</span> isin %temp) { set %msn.vi $htmlfree(%temp) }
  87. if (<span>Humidity</span> isin %temp) { set %msn.hu $htmlfree(%temp) }
  88. if (<span>Dew Point</span> isin %temp) { set %msn.dp $htmlfree(%temp) }
  89. if (*?day*1" iswm %temp) { set %t 1 | goto nextread }
  90. if (%t == 1) && (%temp !== -) { set %msn.fc $remove(%temp,aria-label=",">) | unset %t }
  91. goto nextread
  92. }
  93. on *:sockclose:msn.weather.*: {
  94. if (cloudy isin %msn.cc) { set %msn.em (cl) }
  95. if (sunny isin %msn.cc) { set %msn.em (#) }
  96. if (fair isin %msn.cc) { set %msn.em (r)(#) }
  97. if (light rain isin %msn.cc) { set %msn.em (rn) }
  98. if (rain showers isin %msn.cc) { set %msn.em (rn)(um) }
  99. if (T-Storms isin %msn.cc) { set %msn.em (st) }
  100. if (clear isin %msn.cc) { set %msn.em (*) }
  101. if (partly sunny isin %msn.cc) { set %msn.em (cl)(#) }
  102. if (mostly sunny isin %msn.cc) { set %msn.em (#) }
  103. if (snow isin %msn.cc) { set %msn.em (**) }
  104. if (%msn.corf == $null) {
  105. MSG %wchan : %kfont %wnick Weather for: %msn.ci $+ , %msn.em $+ %msn.cc $+ %msn.em $+ , %msn.fl $+ , %msn.wi $+ , %msn.bo $+ , %msn.vi $&
  106. $+ , %msn.hu $+ , %msn.dp
  107. MSG %wchan : %kfont %msn.fc $+ .
  108. }
  109. if (%msn.corf !== $null) {
  110. MSG %wchan : %kfont %wnick Weather for: %msn.ci $+ (CELSIUS) , %msn.em $+ %msn.cc $+ %msn.em $+ , %msn.fl $+ , %msn.wi $+ , %msn.bo $+ , %msn.vi $&
  111. $+ , %msn.hu $+ , %msn.dp
  112. MSG %wchan : %kfont %msn.fc $+ .
  113. }
  114.  
  115. unset %msn.* | unset %t
  116. set -u5 %fp 1
  117. }
  118. ;on *:sockwrite:msn.weather.*: { echo 8 @ $+ $sockname % }
  119. on *:sockopen:msn.weather.*: {
  120. if ($sockerr) { echo -aci1 info * /MSNweather: socket error $+($chr(40),$sockerr,$chr(41)) | unset $+(%,$sockname,*) | return }
  121. ;window $+(@,$sockname)
  122. 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
  123. ;sockwrite -nt $sockname User-Agent: Android/OS
  124. sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0) Chrome/64.0.3282.140 Safari/537.36
  125. sockwrite -nt $sockname Vary: Accept-Encoding Header
  126. sockwrite -nt $sockname Accept-Language: en-US
  127. sockwrite -nt $sockname Accept: text/html
  128. sockwrite -nt $sockname Cache-Control: no-cache
  129. ;sockwrite -nt $sockname Upgrade-Insecure-Requests: 1
  130. ;sockwrite -nt $sockname Accept-Encoding: gzip, deflate
  131. sockwrite -nt $sockname Host: www.msn.com:443
  132. sockwrite -nt $sockname DNT: 1
  133. sockwrite -nt $sockname Connection: close
  134. sockwrite -n $sockname $str($crlf,2)
  135. }
  136. on *:sockopen:msn.forecast.*: {
  137. if ($sockerr) { echo -aci1 info * /MSNweather: socket error $+($chr(40),$sockerr,$chr(41)) | unset $+(%,$sockname,*) | return }
  138. ;window $+(@,$sockname)
  139. 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
  140. ;sockwrite -nt $sockname User-Agent: Android/OS
  141. sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0) Chrome/64.0.3282.140 Safari/537.36
  142. sockwrite -nt $sockname Vary: Accept-Encoding Header
  143. sockwrite -nt $sockname Accept-Language: en-US
  144. sockwrite -nt $sockname Accept: text/html
  145. sockwrite -nt $sockname Cache-Control: no-cache
  146. ;sockwrite -nt $sockname Upgrade-Insecure-Requests: 1
  147. ;sockwrite -nt $sockname Accept-Encoding: gzip, deflate
  148. sockwrite -nt $sockname Host: www.msn.com:443
  149. sockwrite -nt $sockname DNT: 1
  150. sockwrite -nt $sockname Connection: close
  151. sockwrite -n $sockname $str($crlf,2)
  152. }
  153.  
  154. on *:sockread:msn.forecast.*: {
  155. ;window @ $+ $sockname
  156. if ($sockerr > 0) { echo 4 -a There was an error loading, please try again! | sockclose $sockname | return }
  157. :nextread
  158. sockread -fn %temp | /tokenize 32 %temp
  159. ;if (%temp !== $null) echo 9 @ $+ $sockname %temp
  160. if ($sockbr == 0) {
  161. return
  162. }
  163. if (*h2*span* * iswm %temp) { set %msn.ci $htmlfree(%temp)
  164. }
  165. if (%temp == $null) { %temp = - | goto nextread }
  166. ;echo 9 @ $+ $sockname %temp
  167. if (*Daily Forecast* iswm %temp) { set %t 1 | goto nextread }
  168. if (%t <= %fcnum) {
  169. if (*?day* $+ %t $+ " iswm %temp) { var %s 1 | goto nextread }
  170. if (%s == 1) && (%temp !== -) { set %msn.fc $+ %t $remove(%temp,aria-label=",">,The forecast for) | inc %t 1 | unset %s }
  171. goto nextread
  172. }
  173. else { goto nextread
  174. }
  175. }
  176. on *:sockclose:msn.forecast.*: {
  177. if (cloudy isin %msn.fc $+ %t) { set %msn.em (cl) }
  178. if (sunny isin %msn.fc $+ %t) { set %msn.em (#) }
  179. if (fair isin %msn.fc $+ %t) { set %msn.em (r)(#) }
  180. if (light rain isin %msn.fc $+ %t) { set %msn.em (rn) }
  181. if (rain showers isin %msn.fc $+ %t) { set %msn.em (rn)(um) }
  182. if (T-Storms isin %msn.fc $+ %t) { set %msn.em (st) }
  183. if (clear isin %msn.fc $+ %t) { set %msn.em (*) }
  184. if (partly sunny isin %msn.fc $+ %t) { set %msn.em (cl)(#) }
  185. if (mostly sunny isin %msn.fc $+ %t) { set %msn.em (#) }
  186. if (snow isin %msn.fc $+ %t) { set %msn.em (**) }
  187. MSG %wchan : %kfont %wnick Weather Forecast for: %msn.ci $+ %msn.ctf $+ , %msn.fc1 $+ , %msn.fc2 $+ , %msn.fc3
  188. if (%msn.fc4 !== $null) {
  189. MSG %wchan : %kfont %msn.fc4 $+ , %msn.fc5 $+ , %msn.fc6
  190. }
  191. if (%msn.fc7 !== $null) {
  192. MSG %wchan : %kfont %msn.fc7 $+ , %msn.fc8 $+ , $+ %msn.fc9
  193. }
  194. .timerfc 1 3 unset %msn.* | .timerfc1 1 3 unset %fcnum | .timerfc2 1 3 unset %t
  195. set -u5 %fp 1
  196. }
  197.  
  198. alias sstyle { return $regsubex($1-, /\[(?:style\x20.*?|/style)\]/gi,$null) }
  199. alias -l htmlfree { if ($version > 6.47) {
  200. var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,;,&nbsp;, ), %x = $replace(%x,&#39;,',&amp;,&,&#176,$chr(176))
  201. return %x
  202. }
  203. if ($version < 6.47) {
  204. var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,;,&nbsp;, ), %x = $replace(%x,&#39;,',&amp;,&)
  205. return %x
  206. }
  207. }
  208. #weath end
Advertisement
Add Comment
Please, Sign In to add comment