## $Id: rssnews.tcl,v 1.401 2004/07/17 17:06:41 perpleXa Exp $ ## ## http://perpleXa.net | http://dev.perpleXa.net ## #perpleXa on QuakeNet ## (C) 2004 ## ## This script is approved to catch all valid RSS feeds. ## Default setup is to catch news from deviantART.com. ## If You have any suggestions or bugs please visit ## me on QuakeNet and tell me your wish/problem. ## ## Note: I will NOT make a version which supports ## several feeds at once. ## So please don't ask for it. ## ## I've made really huge changes in v1.4, which are not ## easy to track, if you find any bugs or stuff, which ## seems to make failures so notice me! ## ## Version History: ## ## 1.401 - 2004-07-17 ## ## - added: debug mode (makes it easier to track bugs) ## ## 1.400 - 2004-07-15 ## ## - improved: all regular expressions (regex). ## - changed: replaced all "string first" with regex. ## - changed: public triggers post to the channel, ## message triggers post private (due to many requests). ## - added: output layout on triggers can now be changed. ## ## 1.304 - 2004-07-13 ## ## - fixed: colors get removed on all chans if +c is set on just one of them. ## ## 1.303 - 2004-07-10 ## ## - fixed: file doesn't get closed, if there are news available. ## ## 1.302 - 2004-07-01 ## ## - fixed: sock doesn't get closed, if the limit is above the ## news items, which are included in the file. ## ## 1.301 - 2004-06-30 ## ## - improved: regex, which splits the url. ## - improved: file handling if the host is unreachable. ## - changed: default output design. ## - changed: all variables are now an array (rss). ## - added: a check if the directory exists, which is used by the file, ## it will be created, if it does not exist. ## - added: version history :P ## ## 1.2xx - 2004-06-xx ## ## - fixed: bug, which replaced every "&" in an url with ie. <link> ## - fixed: bug, which caused the script to brake, ## after it has checked the url once. ## - added: seperated triggers (message and public). ## ## 1.1xx - 2004-05-xx ## ## - improved: replaced setup for each part of the url with a unique one. ## - added: user defined layout. ## - added: auto remove of control codes if chanmode +c is set. ## ## 1.0xx - 2004-04-xx ## ## - Initial release, really buggy - never been public.. ## ################## ##### config ##### ## the location of the news ## in the format http://domain.com/file.xml:port ## note: port value is optional. set rss(feedurl) "http://hyperlinkextractor.free.fr/rssfiles/yahoo_france.xml" ## the file where the news are saved set rss(file) "scripts/dbase/rssnews" ## on which channels should the script be activated? ## "" is for all channels the bot is on. set rss(chans) "#Eelai" ## on which commands should the script trigger (setup public and message triggers)? set rss(pubtriggers) {$news} set rss(msgtriggers) {news} ## post news on channels? 1(yes)/0(no) set rss(newspost) "1" ## how many news should be posted on channels? set rss(newspostlimit) "5" ## how many news should be privmessaged on triggers? set rss(publimit) "5" set rss(msglimit) "10" ## define the layout ## you can use: <news> <link> ## for colors or control codes use: ## \002 bold ## \003 [00-15] colors ## \017 reset control codes ## \026 reverse ## \037 underline set rss(layout) "\002 Actualités - France :\017 <news> \00314\037<link>" ## Note: You can also use on triggered output. set rss(triggerlayout) "\002 Actualités - France :\017 <news> \00314\037<link>" ## Debug mode (to display status messages on the partyline) set rss(debug) "1" ##### end of config ##### ######################### foreach trigger [split $rss(pubtriggers) { }] {bind pub - $trigger pub_rss} foreach trigger [split $rss(msgtriggers) { }] {bind msg - $trigger msg_rss} catch {unset trigger} bind time - "?0 * * * *" rsscheck proc rsscheck {min hour day week year} { global rss set counter 0 if {$rss(newspost) == 1 } { regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(feedurl) tmp pro rss(url) rss(feed) tmp rss(port) if {$rss(port) == ""} {set rss(port) 80} if {$rss(debug) == 1} { putlog "RSS: searching news on $rss(url) (port: $rss(port))" } set rss(lastnews) "none" regexp -- {(\S+/)?} $rss(file) tmp rss(dir) if {$rss(dir) != ""} { if {![file isdirectory $rss(dir)]} { file mkdir $rss(dir) if {$rss(debug) == 1} { putlog "RSS: created directory: $rss(dir)" } } } if {[file exists $rss(file)]} { set temp [open "$rss(file)" r] set rss(lastnews) "[gets $temp]" if {$rss(lastnews) == ""} {set rss(lastnews) "none"} close $temp } if {[catch {set sock [socket $rss(url) $rss(port)]} sockerror]} { if {$rss(debug) == 1} { putlog "RSS: error: $sockerror" } return } else { set limit $rss(msglimit) if {$limit < $rss(newspostlimit)} {set limit $rss(newspostlimit)} if {$limit < $rss(publimit)} {set limit $rss(publimit)} set temp [open "$rss(file)" w+] puts $sock "GET $rss(feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { if {$counter == $limit} {break} set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring $bl 1]} if {[regexp -nocase -- {} $bl]} { regsub -all -- {} $rss(layout) $publisher rss(output) regsub -all -- {<news>} $rss(output) $newsline rss(output) regsub -all -- {<link>} $rss(output) $newslink rss(output) puts $temp "$rss(output)" set getfeed 0 ; incr counter } } } } close $sock ; close $temp ; set counter 0 set temp [open "$rss(file)" r] while {[eof $temp] != 1} { set rss(newline) [gets $temp] if {($rss(lastnews) $rss(newline)) || ($counter $rss(newspostlimit))} { if {$rss(debug) == 1} { putlog "RSS: No news found." } close $temp; return } incr counter foreach chan [channels] { if {$rss(chans) == ""} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(newline) "" rss(outline) } else { set rss(outline) $rss(newline) } putserv "PRIVMSG $chan :$rss(outline)" } else { if {[lsearch -exact [string tolower $rss(chans)] [string tolower $chan]] != -1} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(newline) "" rss(outline) } else { set rss(outline) $rss(newline) } putserv "PRIVMSG $chan :$rss(outline)" } } } } close $temp } } proc rssnews {target limit} { global rss regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(feedurl) tmp pro rss(url) rss(feed) tmp rss(port) if {$rss(port) == ""} {set rss(port) 80} if {[catch {set sock [socket $rss(url) $rss(port)] } sockerror]} { if {$rss(debug) == 1} { putlog "RSS: error: $sockerror" } return } else { puts $sock "GET $rss(feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring $bl 1]} if {[regexp -nocase -- {} $bl]} { set getfeed 0 ; incr counter regsub -all -- {} $rss(triggerlayout) $publisher rss(output) regsub -all -- {<news>} $rss(output) $newsline rss(output) regsub -all -- {<link>} $rss(output) $newslink rss(output) regsub -all -- {} $rss(output) $counter rss(output) putserv "PRIVMSG $target :$rss(output)" } } if {$counter == $limit} {break} } close $sock } } proc cleanstring {string method} { regsub -all -- {<.+?>} $string {} string ; regsub -all -- {\t} $string {} string if {($method == 1)} {regsub -all -- {\&} $string {\\\&} string} set string [string map { " " < < > > & & " " ' " ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß} $string] return $string } proc msg_rss {nick uhost hand arg} { global rss rssnews $nick $rss(msglimit) } proc pub_rss {nick uhost hand chan arg} { global rss if {([lsearch -exact [string tolower $rss(chans)] [string tolower $chan]] != -1) || ($rss(chans) == "")} { rssnews $chan $rss(publimit) } } putlog "Script loaded: RSS feed catcher. (C) 2004 perpleXa"
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question## ## met ici le thème du feed (ca aide quand on a bcp de feed) ## met ici l'url du site (ca aide quand on a bcp de feed) ## ## adresse rss du site set rss(001feedurl) "http://www.ton-fedd-rss" ## fichier de back-up set rss(001file) "scripts/news/rss-news-001" ## salon ou sont affiché les infos set rss(001chans) "#info" ## triggers reconnus ( 1er chan, 2e pv ) set rss(001pubtriggers) {/001} set rss(001msgtriggers) {manga} set rss(001newspost) "1" ## nombre de news postées en même temps set rss(001newspostlimit) "5" ## nombre de news postées en même temps quand un trigger est utilisé set rss(001publimit) "5" set rss(001msglimit) "10" ## Affichage de la news ## Les triggers possibles <news> <link> ## Les codes couleurs ## \002 gras ## \003 [00-15] couleurs ## \017 remise a zéro ## \026 reverse ## \037 souligné set rss(001layout) "\002 \0033,0\[\0031Titre de ta news\0033\] :\017\0031,0 <news> \00314<link>" set rss(001triggerlayout) "\002 \0033,0\[\0031Titre de ta news\0033\] :\017\0031,0 <news> \00314<link>" set rss(001debug) "1" ##### Pas toucher apres sinon ca marche plus ##### foreach trigger [split $rss(001pubtriggers) { }] {bind pub - $trigger pub_rss-001} foreach trigger [split $rss(001msgtriggers) { }] {bind msg - $trigger msg_rss-001} catch {unset trigger} bind time - "?0 * * * *" rsscheck-001 proc rsscheck-001 {min hour day week year} { global rss set counter 0 ## timer pour un nouveau scan du site (le 1 veut dire 10 minutes) if {$rss(001newspost) == 1 } { regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(001feedurl) tmp pro rss(001url) rss(001feed) tmp rss(001port) if {$rss(001port) == ""} {set rss(001port) 80} if {$rss(001debug) == 1} { putlog "RSS: searching news on $rss(001url) (port: $rss(001port))" } set rss(001lastnews) "none" regexp -- {(\S+/)?} $rss(001file) tmp rss(001dir) if {$rss(001dir) != ""} { if {![file isdirectory $rss(001dir)]} { file mkdir $rss(001dir) if {$rss(001debug) == 1} { putlog "RSS: created directory: $rss(001dir)" } } } if {[file exists $rss(001file)]} { set temp [open "$rss(001file)" r] set rss(001lastnews) "[gets $temp]" if {$rss(001lastnews) == ""} {set rss(001lastnews) "none"} close $temp } if {[catch {set sock [socket $rss(001url) $rss(001port)]} sockerror]} { if {$rss(001debug) == 1} { putlog "RSS: error: $sockerror" } return } else { set limit $rss(001msglimit) if {$limit < $rss(001newspostlimit)} {set limit $rss(001newspostlimit)} if {$limit < $rss(001publimit)} {set limit $rss(001publimit)} set temp [open "$rss(001file)" w+] puts $sock "GET $rss(001feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(001url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { if {$counter == $limit} {break} set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring-001 $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring-001 $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring-001 $bl 1]} if {[regexp -nocase -- {} $bl]} { regsub -all -- {} $rss(001layout) $publisher rss(001output) regsub -all -- {<news>} $rss(001output) $newsline rss(001output) regsub -all -- {<link>} $rss(001output) $newslink rss(001output) puts $temp "$rss(001output)" set getfeed 0 ; incr counter } } } } close $sock ; close $temp ; set counter 0 set temp [open "$rss(001file)" r] while {[eof $temp] != 1} { set rss(001newline) [gets $temp] if {($rss(001lastnews) $rss(001newline)) || ($counter $rss(001newspostlimit))} { if {$rss(001debug) == 1} { ## echo personalisé putlog "RSS 001 Plus de nouvelles news manga trouvées" } close $temp; return } incr counter foreach chan [channels] { if {$rss(001chans) == ""} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(001newline) "" rss(001outline) } else { set rss(001outline) $rss(001newline) } putserv "PRIVMSG $chan :$rss(001outline)" } else { if {[lsearch -exact [string tolower $rss(001chans)] [string tolower $chan]] != -1} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(001newline) "" rss(001outline) } else { set rss(001outline) $rss(001newline) } putserv "PRIVMSG $chan :$rss(001outline)" } } } } close $temp } } proc rssnews-001 {target limit} { global rss regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(001feedurl) tmp pro rss(001url) rss(001feed) tmp rss(001port) if {$rss(001port) == ""} {set rss(001port) 80} if {[catch {set sock [socket $rss(001url) $rss(001port)] } sockerror]} { if {$rss(001debug) == 1} { putlog "RSS: error: $sockerror" } return } else { puts $sock "GET $rss(001feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(001url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring-001 $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring-001 $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring-001 $bl 1]} if {[regexp -nocase -- {} $bl]} { set getfeed 0 ; incr counter regsub -all -- {} $rss(001triggerlayout) $publisher rss(001output) regsub -all -- {<news>} $rss(001output) $newsline rss(001output) regsub -all -- {<link>} $rss(001output) $newslink rss(001output) regsub -all -- {} $rss(001output) $counter rss(001output) putserv "PRIVMSG $target :$rss(001output)" } } if {$counter == $limit} {break} } close $sock } } proc cleanstring-001 {string method} { regsub -all -- {<.+?>} $string {} string ; regsub -all -- {\t} $string {} string if {($method == 1)} {regsub -all -- {\&} $string {\\\&} string} set string [string map { " " < < > > & & " " ' " ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß} $string] return $string } proc msg_rss-001 {nick uhost hand arg} { global rss rssnews-001 $nick $rss(001msglimit) } proc pub_rss-001 {nick uhost hand chan arg} { global rss if {([lsearch -exact [string tolower $rss(001chans)] [string tolower $chan]] != -1) || ($rss(001chans) == "")} { rssnews-001 $chan $rss(001publimit) } } putlog "RSS feed catcher by perpleXa - multi-feed-001 by Melchizedek Loaded"
################## ##### config ##### ## the location of the news ## in the format http://domain.com/file.xml:port ## note: port value is optional. set rss(001feedurl) "www.pcinpact.com/include/news.xml" ## the file where the news are saved set rss(001file) "scripts/rssnews-db-001" ## on which channels should the script be activated? ## "" is for all channels the bot is on. set rss(001chans) "#eggdrop" ## on which commands should the script trigger (setup public and message triggers)? set rss(001pubtriggers) {/001} set rss(001msgtriggers) {news} set rss(001newspost) "1" ## how many news should be posted on channels? set rss(001newspostlimit) "5" ## how many news should be privmessaged on triggers? set rss(001publimit) "5" set rss(001msglimit) "10" ## define the layout ## you can use: <news> <link> ## for colors or control codes use: ## \002 bold ## \003 [00-15] colors ## \017 reset control codes ## \026 reverse ## \037 underline set rss(001layout) "\002 PCinpacT:\017 <news> \00314\037<link>" ## Note: You can also use on triggered output. set rss(001triggerlayout) "\002 PcinpacT :\017 <news> \00314\037<link>" ## Debug mode (to display status messages on the partyline) set rss(001debug) "1" ##### end of config ##### ######################### foreach trigger [split $rss(001pubtriggers) { }] {bind pub - $trigger pub_rss-001} foreach trigger [split $rss(001msgtriggers) { }] {bind msg - $trigger msg_rss-001} catch {unset trigger} bind time - "?0 * * * *" rsscheck-001 proc rsscheck-001 {min hour day week year} { global rss set counter 0 if {$rss(001newspost) == 1 } { regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(001feedurl) tmp pro rss(001url) rss(001feed) tmp rss(001port) if {$rss(001port) == ""} {set rss(001port) 80} if {$rss(001debug) == 1} { putlog "RSS: searching news on $rss(001url) (port: $rss(001port))" } set rss(001lastnews) "none" regexp -- {(\S+/)?} $rss(001file) tmp rss(001dir) if {$rss(001dir) != ""} { if {![file isdirectory $rss(001dir)]} { file mkdir $rss(001dir) if {$rss(001debug) == 1} { putlog "RSS: created directory: $rss(001dir)" } } } if {[file exists $rss(001file)]} { set temp [open "$rss(001file)" r] set rss(001lastnews) "[gets $temp]" if {$rss(001lastnews) == ""} {set rss(001lastnews) "none"} close $temp } if {[catch {set sock [socket $rss(001url) $rss(001port)]} sockerror]} { if {$rss(001debug) == 1} { putlog "RSS: error: $sockerror" } return } else { set limit $rss(001msglimit) if {$limit < $rss(001newspostlimit)} {set limit $rss(001newspostlimit)} if {$limit < $rss(001publimit)} {set limit $rss(001publimit)} set temp [open "$rss(001file)" w+] puts $sock "GET $rss(001feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(001url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { if {$counter == $limit} {break} set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring $bl 1]} if {[regexp -nocase -- {} $bl]} { regsub -all -- {} $rss(001layout) $publisher rss(001output) regsub -all -- {<news>} $rss(001output) $newsline rss(001output) regsub -all -- {<link>} $rss(001output) $newslink rss(001output) puts $temp "$rss(001output)" set getfeed 0 ; incr counter } } } } close $sock ; close $temp ; set counter 0 set temp [open "$rss(001file)" r] while {[eof $temp] != 1} { set rss(001newline) [gets $temp]if {($rss(001lastnews) $rss(001newline)) || ($counter $rss(001newspostlimit))} { if {$rss(001debug) == 1} { putlog "RSS: No news found." } close $temp; return } incr counter foreach chan [channels] { if {$rss(001chans) == ""} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(001newline) "" rss(001outline) } else { set rss(001outline) $rss(001newline) } putserv "PRIVMSG $chan :$rss(001outline)" } else { if {[lsearch -exact [string tolower $rss(chans)] [string tolower $chan]] != -1} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(newline) "" rss(001outline) } else { set rss(001outline) $rss(001newline) } putserv "PRIVMSG $chan :$rss(001outline)" } } } } close $temp } } proc rssnews-001 {target limit} { global rss regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(001feedurl) tmp pro rss(001url) rss(001feed) tmp rss(001port) if {$rss(001port) == ""} {set rss(001port) 80} if {[catch {set sock [socket $rss(001url) $rss(001port)] } sockerror]} { if {$rss(001debug) == 1} { putlog "RSS: error: $sockerror" } return } else { puts $sock "GET $rss(001feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(001url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring $bl 1]} if {[regexp -nocase -- {} $bl]} { set getfeed 0 ; incr counter regsub -all -- {} $rss(001triggerlayout) $publisher rss(001output) regsub -all -- {<news>} $rss(001output) $newsline rss(001output) regsub -all -- {<link>} $rss(001output) $newslink rss(001output) regsub -all -- {} $rss(001output) $counter rss(001output) putserv "PRIVMSG $target :$rss(001output)" } } if {$counter == $limit} {break} } close $sock } } proc cleanstring-001 {string method} { regsub -all -- {<.+?>} $string {} string ; regsub -all -- {\t} $string {} string if {($method == 1)} {regsub -all -- {\&} $string {\\\&} string} set string [string map { " " < < > > & & " " ' " ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß} $string] return $string } proc msg_rss-001 {nick uhost hand arg} { global rss rssnews $nick $rss(001msglimit) } proc pub_rss-001 {nick uhost hand chan arg} { global rss if {([lsearch -exact [string tolower $rss(001chans)] [string tolower $chan]] != -1) || ($rss(001chans) == "")} { rssnews $chan $rss(001publimit) } }
## ## Titre la rubrique (ca aide pour se retrouver après) ## Adresse du site (ca aide pour se retrouver après) ## ## adresse rss du site set rss(000feedurl) "http://www.liberation.fr/rss.php" ## fichier de back-up set rss(000file) "scripts/news/rss-news-000" ## salon ou sont affiché les infos set rss(000chans) "#info" ## triggers reconnus ( 1er chan, 2e pv ) set rss(000pubtriggers) {/000} set rss(000msgtriggers) {news} set rss(000newspost) "1" ## nombre de news postées en même temps set rss(000newspostlimit) "5" ## nombre de news postées en même temps quand un trigger est utilisé set rss(000publimit) "5" set rss(000msglimit) "10" ## Affichage de la news ## Les triggers possibles <news> <link> ## Les codes couleurs ## \002 gras ## \003 [00-15] couleurs ## \017 remise a zéro ## \026 reverse ## \037 souligné set rss(000layout) "\002 \0037,0\[\0031Titre de la rubrique\0037\] :\017\0031,0 <news> \00314<link>" set rss(000triggerlayout) "\002 \0037,0\[\0031Titre de la rubrique\0037\] :\017\0031,0 <news> \00314<link>" set rss(000debug) "1" ##### Pas toucher apres sinon ca marche plus ##### foreach trigger [split $rss(000pubtriggers) { }] {bind pub - $trigger pub_rss-000} foreach trigger [split $rss(000msgtriggers) { }] {bind msg - $trigger msg_rss-000} catch {unset trigger} bind time - "?0 * * * *" rsscheck-000 proc rsscheck-000 {min hour day week year} { global rss set counter 0 ## timer pour un nouveau scan du site (le 1 veut dire 10 minutes) if {$rss(000newspost) == 1 } { regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(000feedurl) tmp pro rss(000url) rss(000feed) tmp rss(000port) if {$rss(000port) == ""} {set rss(000port) 80} if {$rss(000debug) == 1} { ## echo personalisé putlog "RSS: recherche de news sur $rss(000url) (port: $rss(000port))" } set rss(000lastnews) "none" regexp -- {(\S+/)?} $rss(000file) tmp rss(000dir) if {$rss(000dir) != ""} { if {![file isdirectory $rss(000dir)]} { file mkdir $rss(000dir) if {$rss(000debug) == 1} { putlog "RSS: created directory: $rss(000dir)" } } } if {[file exists $rss(000file)]} { set temp [open "$rss(000file)" r] set rss(000lastnews) "[gets $temp]" if {$rss(000lastnews) == ""} {set rss(000lastnews) "none"} close $temp } if {[catch {set sock [socket $rss(000url) $rss(000port)]} sockerror]} { if {$rss(000debug) == 1} { putlog "RSS: error: $sockerror" } return } else { set limit $rss(000msglimit) if {$limit < $rss(000newspostlimit)} {set limit $rss(000newspostlimit)} if {$limit < $rss(000publimit)} {set limit $rss(000publimit)} set temp [open "$rss(000file)" w+] puts $sock "GET $rss(000feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(000url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { if {$counter == $limit} {break} set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring-000 $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring-000 $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring-000 $bl 1]} if {[regexp -nocase -- {} $bl]} { regsub -all -- {} $rss(000layout) $publisher rss(000output) regsub -all -- {<news>} $rss(000output) $newsline rss(000output) regsub -all -- {<link>} $rss(000output) $newslink rss(000output) puts $temp "$rss(000output)" set getfeed 0 ; incr counter } } } } close $sock ; close $temp ; set counter 0 set temp [open "$rss(000file)" r] while {[eof $temp] != 1} { set rss(000newline) [gets $temp] if {($rss(000lastnews) $rss(000newline)) || ($counter $rss(000newspostlimit))} { if {$rss(000debug) == 1} { ## echo personalisé putlog "RSS 000 Plus de nouvelles news trouvées" } close $temp; return } incr counter foreach chan [channels] { if {$rss(000chans) == ""} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(000newline) "" rss(000outline) } else { set rss(000outline) $rss(000newline) } putserv "PRIVMSG $chan :$rss(000outline)" } else { if {[lsearch -exact [string tolower $rss(000chans)] [string tolower $chan]] != -1} { if {[regexp -- {c} [getchanmode $chan]]} { regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?|\002|\037|\017|\026|\006|\007} $rss(000newline) "" rss(000outline) } else { set rss(000outline) $rss(000newline) } putserv "PRIVMSG $chan :$rss(000outline)" } } } } close $temp } } proc rssnews-000 {target limit} { global rss regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.+?)(\:([0-9]+))?$} $rss(000feedurl) tmp pro rss(000url) rss(000feed) tmp rss(000port) if {$rss(000port) == ""} {set rss(000port) 80} if {[catch {set sock [socket $rss(000url) $rss(000port)] } sockerror]} { if {$rss(000debug) == 1} { putlog "RSS: error: $sockerror" } return } else { puts $sock "GET $rss(000feed) HTTP/1.1" puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" puts $sock "Host: $rss(000url)" puts $sock "" flush $sock set counter 0 ; set getfeed 0 while {(![eof $sock])} { set bl [gets $sock] if {[regexp -nocase -- {|} $bl]} {set getfeed 1} if {$getfeed == 0} { if {[regexp -nocase -- {<title>.+</title>} $bl]} {set publisher [cleanstring-000 $bl 1]} } elseif {$getfeed == 1} { if {[regexp -nocase -- {<link>.+</link>} $bl]} {set newslink [cleanstring-000 $bl 1]} if {[regexp -nocase -- {<title>.+</title>} $bl]} {set newsline [cleanstring-000 $bl 1]} if {[regexp -nocase -- {} $bl]} { set getfeed 0 ; incr counter regsub -all -- {} $rss(000triggerlayout) $publisher rss(000output) regsub -all -- {<news>} $rss(000output) $newsline rss(000output) regsub -all -- {<link>} $rss(000output) $newslink rss(000output) regsub -all -- {} $rss(000output) $counter rss(000output) putserv "PRIVMSG $target :$rss(000output)" } } if {$counter == $limit} {break} } close $sock } } proc cleanstring-000 {string method} { regsub -all -- {<.+?>} $string {} string ; regsub -all -- {\t} $string {} string if {($method == 1)} {regsub -all -- {\&} $string {\\\&} string} set string [string map { " " < < > > & & " " ' " ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß} $string] return $string } proc msg_rss-000 {nick uhost hand arg} { global rss rssnews-000 $nick $rss(000msglimit) } proc pub_rss-000 {nick uhost hand chan arg} { global rss if {([lsearch -exact [string tolower $rss(000chans)] [string tolower $chan]] != -1) || ($rss(000chans) == "")} { rssnews-000 $chan $rss(000publimit) } } putlog "RSS feed catcher by perpleXa - multi-feed-000 by Melchizedek Loaded"