Advertisement
Guest User

Untitled

a guest
Dec 4th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.64 KB | None | 0 0
  1.  
  2. ;==================================================
  3. ; RSS Poster
  4. ; by Cobi
  5. ;==================================================
  6. ; Commands:
  7. ; /rss Starts the rss poster (shortcut for /loadrsshist and /rsscfg)
  8. ; /addrss name host webfile channel count interval -- adds feed to rss.cfg (Implies /rsstimer)
  9. ; /showrss name host webfile channel count -- shows rss feed in channel (Implies /getrss and /parserss)
  10. ;
  11. ; ----- The following are internal commands and should only be used if messing around with the code. -----
  12. ; /loadrsshist Loads the history file so as not to post the same stuff over and over
  13. ; /closersshist Unloads the history file...
  14. ; /reloadrsshist Shortcut for /closersshist and /loadrsshist
  15. ; /rsscfg Loads rss.cfg file and parses it (Implies /rsstimer on every rss feed listed)
  16. ; /rsstimer name host webfile channel count interval starts a rss timer for the specified settings
  17. ; (Implies /showrss each interval)
  18. ; /getrss name host webfile file done -- downloades an rss feed then runs done when it is done (Implies /fixrss)
  19. ; /fixrss file -- fixes rss feed format. This is done automatically, and should only be done when debugging.
  20. ; /parserss file name channel count -- parses rss file and displays it in a channel
  21. ;
  22. ; Arguements:
  23. ; name = Name of feed (used for displaying purposes)
  24. ; host = Where to get the feed ( http://hostwebfile e.g. http://example.com/test.xml example.com is the host and /test.xml is the webfile.. )
  25. ; webfile = file on host
  26. ; file = local rss file
  27. ; channel = channel to show rss postings in
  28. ; count = how many rss posts to show at once
  29. ; interval = how often (in seconds) to show rss posts
  30. ; done = what to do when done downloading file
  31. ;
  32. ; Examples:
  33. ;
  34. ; Add a few rss feeds:
  35. ; /addrss mirc.net mirc.net /rss.php?type=news #rss 6 600
  36. ; /addrss SourceForge images.feedstermedia.com /feedcache/ostg/sourceforge/rss_sfnews.xml #rss 6 600
  37. ; /addrss NPR www.npr.org /rss/rss.php?topicId=1001 #rss 6 600
  38. ; /addrss Moreover p.moreover.com /page?o=rss002&c=Top%20stories&wiz=230176 #rss 6 600
  39. ; /addrss Copyright www.copyright.gov /rss.xml #rss 6 600
  40. ; /addrss podcastingnews www.podcastingnews.com /index.xml #rss 6 600
  41. ; /addrss Infoworld www.infoworld.com /rss/news.xml #rss 6 600
  42. ; /addrss BarkerJr.Net barkerjr.net /rss?c=2;f=5 #RSS 2 600
  43. ; /addrss Linux-Security www.linuxsecurity.com /static-content/linuxsecurity_hybrid.rdf #rss 6 600
  44. ; /addrss Planet-Source-Code www.planet-source-code.com /vb/channel/NewCode/channel.cdf #rss 6 600
  45. ; /addrss /. slashdot.org /rss/index.rss #rss 6 600
  46. ; /addrss ZDnet news.zdnet.com /2509-1_22-0-20.xml #rss 6 600
  47. ; /addrss IRC101 www.irc101.org /tier2.xml #rss 6 600
  48. ; /addrss MSDN msdn.microsoft.com /msdnmag/rss/recent.xml #rss 6 600
  49. ; /addrss Microsoft www.microsoft.com /communities/rss.aspx?&Title=Recent+Posts&CMTYSvcSource=MSCOMBlogPosts&CMTYRawShape=list&Params=%7eCMTYDataSvcParams%5e%7eArg+Name%3d'DateFormat'+Value%3d'MMM+d%2c+yyyy'%2f%5e%7e%2fCMTYDataSvcParams%5e&NumberOfItems=50 #rss 6 600
  50. ; /addrss &color;01,00W&color;00,01I&color;01,00R&color;00,01E&color;01,00D&color; wired.com /news/feeds/rss2/0,2610,,00.xml #rss 6 600
  51. ; /addrss RTCW ict.mcast.edu.mt /ictweb/davidmica/web/rss.xml #rss 6 600
  52. ; /addrss jaos software.jaos.org /cgi-bin/rss #rss 6 600
  53. ;
  54. ; Reload the config file:
  55. ; /rehashrss
  56. ;
  57. ; Edit the config file:
  58. ; /run notepad rss.cfg
  59. ;
  60. ; Load the config file and start posting news:
  61. ; /rss
  62. ;
  63. ; Contact:
  64. ; Cobi@winbots.org
  65. ; Cobi on Undernet (#phase, #rss, #game-trivia)
  66. ; Cobi on Winbots (#winbots)
  67. ; Cobi-Wan-Kenobi on Quakenet (#icechat)
  68. ; Cobi on SearchIRC Forums
  69. ; Winbots on UnrealIRCd Forums
  70. ; Cobi on mirc.net
  71. ;
  72. ; ChangeLog:
  73. ; v1.3 -- fixed memory bug
  74. ; v1.2 -- fixed the issue when the tags are not one word (<title blah>blah</title>)
  75. ; v1.1 -- fixed rss.performance issue
  76. ; v1.0 -- Initial Release
  77.  
  78. alias rss { loadrsshist | rsscfg }
  79. alias closersshist { window -c @rss.hist | window -c @rss.performance }
  80. alias reloadrsshist { closersshist | loadrsshist }
  81. alias rsscfg {
  82. var %time = $ticks
  83. var %lcv2 = 0
  84. var %lcv = 1
  85. var %lines = $lines(rss.cfg)
  86. unset %list
  87. while (%lcv <= %lines) {
  88. if ($read(rss.cfg,%lcv)) {
  89. bunset &line
  90. bset -t &line 1 $read(rss.cfg,%lcv)
  91. if ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,\<(.+)\>(.+)\<\/.+\>)) {
  92. bunset &rss. $+ $regml(RSS,1)
  93. bset -t &rss. $+ $regml(RSS,1) 1 $regml(RSS,2)
  94. }
  95. elseif ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,\<\/item\>)) {
  96. rsstimer $bvar(&rss.feed,1,$bvar(&rss.feed,0)).text $bvar(&rss.host,1,$bvar(&rss.host,0)).text $bvar(&rss.file,1,$bvar(&rss.file,0)).text $bvar(&rss.channel,1,$bvar(&rss.channel,0)).text $bvar(&rss.feeds,1,$bvar(&rss.feeds,0)).text $bvar(&rss.interval,1,$bvar(&rss.interval,0)).text
  97. set %list %list $replacex($bvar(&rss.feed,1,$bvar(&rss.feed,0)).text,&amp;,&,&quot;,",&nbsp;,$chr(32),&color;,,&bold;,,&underline,)
  98. bunset &line &rss.*
  99. inc %Lcv2
  100. }
  101. }
  102. inc %lcv
  103. }
  104. if ($window(@rss.performance)) {
  105. aline @rss.performance ---
  106. aline @rss.performance Parsed %lcv Config Lines ( $+ %lcv2 rss entries) (rss.cfg) in $calc(($ticks - %time)/1000) Seconds
  107. }
  108. }
  109. alias rsstimer {
  110. ;$1 = feed name
  111. ;$2 = host
  112. ;$3 = file
  113. ;$4 = channel
  114. ;$5 = max
  115. ;$6 = interval
  116. showrss $1 $2 $3 $4 $5
  117. .timerrss. $+ $1 0 $6 showrss $1 $2 $3 $4 $5
  118. }
  119. alias showrss {
  120. ;$1 = feed name
  121. ;$2 = host
  122. ;$3 = file
  123. ;$4 = channel
  124. ;$5 = max
  125. set %time. $+ $1 $ticks
  126. .remove " $+ $1 $+ .rss $+ "
  127. getrss $1 $2 $3 $replace($1 $+ .rss,$chr(32),_) parserss $replace($1 $+ .rss,$chr(32),_) $1 $4 $5
  128. }
  129. alias getrss {
  130. ;$1 = feed name
  131. ;$2 = host
  132. ;$3 = file
  133. ;$4 = save
  134. ;$5- = done
  135. set %rss. $+ $1 $+ .file $3
  136. set %rss. $+ $1 $+ .host $2
  137. set %rss. $+ $1 $+ .save $4
  138. set %rss. $+ $1 $+ .done $5-
  139. sockopen rss. $+ $1 $2 80
  140. }
  141. on *:SOCKOPEN:rss.*:{
  142. sockwrite -tn $sockname GET % [ $+ [ $sockname $+ .file ] ] HTTP/1.1
  143. sockwrite -tn $sockname Host: % [ $+ [ $sockname $+ .host ] ]
  144. sockwrite -tn $sockname Accept: *.*, */*
  145. sockwrite -tn $sockname Connection: close
  146. sockwrite -tn $sockname $crlf
  147. }
  148. on *:sockclose:rss.*:{ fixrss % [ $+ [ $sockname $+ .save ] ] | % [ $+ [ $sockname $+ .done ] ] | unset % $+ $sockname $+ .* }
  149. on *:sockread:rss.*:{
  150. if ($sockerr) { echo 1 -a ERROR | return }
  151. if (% [ $+ [ $sockname $+ .status ] ] != downloading) {
  152. var %1 | sockread %1 | tokenize 32 %1
  153. if ($1 == HTTP/1.1) { if ($2 != 200 && $2 != 206) { echo 1 -a ERROR } }
  154. elseif ($1 == Content-Range:) { set % [ $+ [ $sockname $+ .size ] ] $gettok($3,-1,47) }
  155. elseif ($1 == Content-Type:) { return }
  156. elseif (!$1) {
  157. set % [ $+ [ $sockname $+ .status ] ] Downloading
  158. return
  159. }
  160. }
  161. else {
  162. var %1 = % [ $+ [ $sockname $+ .save ] ]
  163. :sockread
  164. sockread &1
  165. if (!$sockbr) { return }
  166. bwrite $+(",%1,") -1 &1
  167. unset % [ $+ [ $sockname $+ .resume ] ]
  168. }
  169. }
  170.  
  171. alias fixrss {
  172. ;$1 = rss file
  173. var %file = $1
  174. bread $1 0 $file($1).size &file
  175. breplace &file 10 32 13 32
  176. write -c $1
  177. var %lcv = 1
  178. var %size = $bvar(&file,0)
  179. while (%lcv <= %size) {
  180. parserss2 $1 $bvar(&file,%lcv,500).text
  181. inc %lcv 500
  182. }
  183. }
  184.  
  185. alias parserss {
  186. ;$1 = rss file
  187. ;$2 = feed name
  188. ;$3 = channel
  189. ;$4 = max
  190. var %time = $ticks | var %lcv = 1 | var %lcv2 = 0 | var %lines = $file($1).size
  191. bread $1 0 %lines &file1
  192. while ((%lcv <= %lines) && (%lcv2 < $4)) { bunset &line | bcopy -c &line 1 &file1 %lcv $calc($iif($bfind(&file1,%lcv,$crlf),$bfind(&file1,%lcv,$crlf),$calc(%lines + 1)) - %lcv) | var %lcv = $calc($iif($bfind(&file1,%lcv,$crlf),$bfind(&file1,%lcv,$crlf),$calc(%lines + 1)) + 2)
  193. if (($bvar(&line,0) < 300) && ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,\<(.+)\>(.+)\<\/.+\>))) { if (($regml(RSS,1)) && ($regml(RSS,2))) { bunset &rss. $+ $gettok($regml(RSS,1),1,32) | bset -t &rss. $+ $gettok($regml(RSS,1),1,32) 1 $regml(RSS,2) } }
  194. elseif (($bvar(&line,0) < 300) && ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,\<\/item\>))) { checkalreadyrss $3 [[ $+ $2 $+ ]]  $+ $bvar(&rss.title,1,$bvar(&rss.title,0)).text $+  ( $bvar(&rss.link,1,$bvar(&rss.link,0)).text ) | inc %lcv2 | bunset &line &rss.* }
  195. }
  196. if ($window(@rss.performance)) {
  197. aline @rss.performance ---
  198. aline @rss.performance Parsed %lcv Bytes ( $+ %lcv2 rss entries) ( $+ $1 $+ ) in $calc(($ticks - %time)/1000) Seconds
  199. }
  200. if (%time. [ $+ [ $2 ] ]) { if ($window(@rss.performance)) {
  201. aline @rss.performance Downloaded and Parsed %lcv Bytes ( $+ %lcv2 rss entries) ( $+ $1 $+ ) in $calc(($ticks - %time. [ $+ [ $2 ] ] )/1000) Seconds } | unset %time. $+ $2 } }
  202.  
  203. alias addrss {
  204. ;$1 = feed name
  205. ;$2 = host
  206. ;$3 = file
  207. ;$4 = channel
  208. ;$5 = max
  209. ;$6 = interval
  210. write rss.cfg <item>
  211. write rss.cfg $chr(32) $+ $chr(32) $+ <feed> $+ $1 $+ </feed>
  212. write rss.cfg $chr(32) $+ $chr(32) $+ <host> $+ $2 $+ </host>
  213. write rss.cfg $chr(32) $+ $chr(32) $+ <file> $+ $3 $+ </file>
  214. write rss.cfg $chr(32) $+ $chr(32) $+ <channel> $+ $4 $+ </channel>
  215. write rss.cfg $chr(32) $+ $chr(32) $+ <feeds> $+ $5 $+ </feeds>
  216. write rss.cfg $chr(32) $+ $chr(32) $+ <interval> $+ $6 $+ </interval>
  217. write rss.cfg </item>
  218. rsstimer $1 $2 $3 $4 $5 $6
  219. }
  220. alias rehashrss {
  221. timerrss.* off
  222. rsscfg
  223. }
  224. alias rssoff {
  225. timerrss.* off
  226. closersshist
  227. }
  228. on 100:TEXT:!addrss * * * * * *:{ addrss $2 $3 $4 $5 $6 $7 }
  229. alias checkalreadyrss {
  230. if (sponsored isin $1-) { goto done }
  231. if ($file(rss.hist.tmp)) { .remove rss.hist.tmp }
  232. filter -ffc rss.hist rss.hist.tmp * $+ $strip($1-) $+ *
  233. if ($file(rss.hist.tmp)) { .remove rss.hist.tmp }
  234. if ($filtered > 0) { goto done }
  235. write rss.hist $strip($1-)
  236. ; if (!$window(@rss.hist)) { echo 4 -a $nopath($script) $+ : ERROR: no history loaded... (try /loadrsshist) | halt }
  237. ; aline @rss.hist $strip($1-)
  238. msg $replacex($1-,&amp;,&,&quot;,",&nbsp;,$chr(32),&color;,,&bold;,,&underline,)
  239. :done
  240. }
  241. alias loadrsshist {
  242. if (!$file(rss.hist).size) { write rss.hist History File }
  243. ; .window -k0lh @rss.hist
  244. ; .loadbuf @rss.hist rss.hist
  245. ; .window -k0 @rss.performance
  246. }
  247. alias parserss2 {
  248. ;$1 = File
  249. ;$2- = XML data
  250. var %file = $1
  251. ;[Code by FiberOPtics] Thanks.. :P
  252. var %a, %b = $regsub($2-,/(?<=>)(?=\s*<)/g,$lf,%a)
  253. tokenize 10 %a
  254. ;[/Code by FiberOPtics]
  255. var %lcv = 1
  256. while (%lcv <= $0) {
  257. bset -t &tmp $calc($bvar(&tmp,0) +1) $ [ $+ [ %lcv ] ] $+ $crlf
  258. inc %lcv
  259. }
  260. bwrite %file -1 $calc($bvar(&tmp,0) -2) &tmp
  261. bunset &tmp
  262. }
  263. on *:TEXT:!list:#:{ msg $chan I syndicate the following: | msg $chan %list }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement