Snippets
  • Uploaded By: entropy
  • Added: 1 year ago
  • Updated: Never
  • mIRC Version: v7.55+
  • Hits: 1,100
  • Size: 3.92KB
  • Downloads: 57
  • Review By: westor



RSS News Bot v1.2

CNN News feed site scrape. You can turn it On/Off (in popups).
You can add a channel/channels via popups.
You can add a network via popups too.

  
  1    0  Login to Vote.


Source Code:
  1. ; =================================================
  2. ; RSS News Bot v1.2 - by entropy 2020
  3. ; =================================================
  4.  
  5. menu channel,status,query,menubar {
  6. -
  7. RSS News Bot v1.2
  8. .$iif(%_rsschan && %_rssnet,Turn $iif($group(#rss).status == on,Off,On)) {
  9. $iif($group(#rss).status == on,.disable,.enable) #rss
  10. if ($group(#rss).status == off) {
  11. if ($network == %_rssnet) { .timerrss off }
  12. echo 4 -a * RSS Feed is now Off
  13. unset %_rsslast
  14. }
  15. else {
  16. if ($network == %_rssnet) { newnews | .timerrss 0 600 newnews }
  17. echo 4 -a * RSS Feed is now On
  18. }
  19. }
  20. .-
  21. .Network $chr(9) %_rssnet { %_rssnet = $input(Network for RSS?,5) }
  22. .Channel(s) $chr(9) %_rsschan { %_rsschan = $input(Channel for RSS? $+ $crlf $+ Or for multiple channels $+ $chr(44) seperated with comma $+ $crlf $+ And for all channels: $chr(35),5) }
  23. .-
  24. .Unload { .unload -rs $qt($script) }
  25. -
  26. }
  27.  
  28. on *:unload:{ unset %_rssnet %_rsschan %_rsslast | .timerrss off | echo 4 -a * RSS News feed is now unloaded! }
  29.  
  30. #rss off
  31. on *:join:%_rsschan:{ if ($network == %_rssnet && $nick == $me) { newnews | .timerrss 0 600 newnews } }
  32. on *:kick:%_rsschan:{ if ($network == %_rssnet && $knick == $me) { .timerrss off } }
  33. on *:part:%_rsschan:{ if ($network == %_rssnet && $nick == $me) { .timerrss off } }
  34. on *:quit:{ if ($network == %_rssnet && $nick == $me) { .timerrss off } }
  35. #rss end
  36.  
  37. alias -l newnews {
  38. sockclose news
  39. sockopen news rss.cnn.com 80
  40. }
  41. on *:sockopen:news:{
  42. if ($sockerr) { return }
  43. sockwrite -n $sockname GET http://rss.cnn.com/rss/cnn_topstories.rss HTTP/1.1
  44. sockwrite -n $sockname Host: rss.cnn.com
  45. sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
  46. sockwrite -n $sockname Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  47. sockwrite -n $sockname Accept-Language: en-US,en;q=0.5
  48. sockwrite -n $sockname $str($crlf,2)
  49. }
  50. on *:sockread:news:{
  51. if ($sockerr) { return }
  52. var %a
  53. sockread -f %a
  54. tokenize 32 $replace(%a,<,$+($chr(32),<),>,$+(>,$chr(32)))
  55.  
  56. if (* href="http://pubsubhubbub.appspot.com/" * iswm $1-) {
  57.  
  58. var %a = $findtok($1-,href="http://pubsubhubbub.appspot.com/",1,32), %b = $findtok($1-,medium="image",1,32)
  59. var %string = $gettok($1-,$+(%a,-,%b),32)
  60. %string = $remove($replace(%string,href="http://pubsubhubbub.appspot.com/" /> <item> <title>,$c,]]> </title> <link>,$chr(32) $c),<![CDATA[)
  61.  
  62. var %a = $findtok($1-,<pubDate>,1,32), %b = $findtok($1-,</pubDate>,1,32)
  63. var %pubdate = $nohtml($gettok($1-,$+(%a,-,%b),32))
  64.  
  65. var %link = http://rss.cnn.com/rss/cnn_topstories
  66.  
  67. var %a = $findtok(%string,<title>,1,32), %b = $findtok(%string,</title>,1,32)
  68. var %title = $gettok($remove($nohtml($gettok(%string,$+(%a,-,%b),32)),]]>),1,9679)
  69.  
  70. var %a = $findtok(%string,<description>,1,32), %b = $findtok(%string,</description>,1,32)
  71. var %desc = $remove($nohtml($gettok(%string,$+(%a,-,%b),32)),&lt;div class="feedflare"&gt;)
  72.  
  73. var %main = [News/World] $c Time: %pubdate $c Title: %title $iif(%desc !isnum,$c Description: %desc) $c Link: %link
  74. sockclose $sockname
  75.  
  76. if (%_rsslast != %title || !%_rsslast) {
  77. var %a = 1
  78. while ($scon(%a)) {
  79. scid $v1
  80. if ($network == %_rssnet) {
  81. var %x = 1, %y
  82. while ($chan(%x)) {
  83. %y = $v1
  84. if (%y == %_rsschan || $istok(%_rsschan,%y,44) || %_rsschan == $chr(35)) { msg %y %main }
  85. inc %x
  86. }
  87. break
  88. }
  89. inc %a
  90. }
  91. scid -r
  92. %_rsslast = %title
  93. }
  94. }
  95. }
  96. alias -l nohtml { return $regsubex($1, /<[^>]+(?:>|$)|^[^<>]+>/g,) }
  97. alias -l c { return $chr(9679) }


Comments (2)
July 19th, 2020 - By: westor
Admin
I think you have to rename the snippet as CNN RSS News Bot because it is only working for CNN
July 20th, 2020 - By: westor
Admin
Change this line (i think it breaks the code):

--> sockwrite -n $sockname GET http://rss.cnn.com/rss/cnn_topstories.rss HTTP/1.1

To:

--> sockwrite -n $sockname GET /rss/cnn_topstories.rss HTTP/1.1

Login to Comment.