işte kodları txt dosyasını atın ve tcl olarak kaydedin..
PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
# Eggdrop RSS Syndication # ----------------------- # Date: 2006-??-?? # Version: v0.3 beta 1 # Author(s): Andrew Scott < Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir. > # Website: http://labs.wizzer-it.com/ #
# # Start of Settings #
namespace eval ::rss-synd { variable rss
# the \'s are in the examples below use this one as a template. set rss(sabah) { "url" " Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir. style="color: #0000BB"><?...?> tags if {[string match {[!\?]*} $tmp(string)]} { continue }
# we should only ever encounter opening tags, if we hit a closing one somethings wrong. if {[string match {[/]*} $tmp(string)]} { putlog "\002Malformed Feed\002: Tag not open: \"<$tmp(string)>\" ([join $tmp(sindices) " => "])" continue }
set match [regexp -inline -- {(.[^ \/\n\r>]*)(?: |\n|\r\n|\r|)(.[^>]*|)} $tmp(string)] set tag(name) [lindex $match 1] set tag(data) ""
# get all of the tags attributes set tag(attrib) [list] if {[string length [lindex $match 2]] > 0} { set values [regexp -inline -all -- {(?:\s*|)(.[^=]*)="(.[^"]*)"} [lindex $match 2]] foreach {regmatch regtag regval} $values { lappend tag(attrib) $regtag $regval } }
# find the end tag of non-self-closing tags if {![regexp {/(\s*)$} [lindex $match 2]]} {
set loop 1 # loop to check we're finding the right closing tag while {$loop == 1} { set loop 0
# there is a tag with the same name inside the current one, find the next # closing tag. if {[regexp -indices -start $tptr -- "<[lindex $match 1]>" $data tindices]} { if {[lindex $tindices 0] < [lindex $tmp(eindices) 1]} { set loop 1 } }
}
catch {unset tptr tindices subdata}
# errors sometimes occure here, not sure why, but im guessing its caused by # downloading an incomplete feed. the problem has only occured for me # a couple of time and it was on the same feed. I didnt manage to trace # the problem properly. Its probably a good idea to create crash logging # for the parser so i can debug stuff properly. set subdata [string range $data [expr { [lindex $tmp(sindices) 1] + 1 }] [expr { [lindex $tmp(eindices) 0] - 1 }]]
if {[regexp -nocase -- {^(?:\s*)<!\[CDATA\[} $subdata]} { set cdata [regexp -inline -all -nocase -- {<!\[CDATA\[(.[^\]]*)\]\]>} $subdata]
set result [list] # recurse the data within the currently open tag if {![info exists cdata]} { set result [[namespace current]::xmlCreateList $subdata] }
catch {unset cdata}
# set the list data returned from the recursion we just performed if {[llength $result] > 0} { set tag(data) $result
# set the current data we have because were already at the end of a branch # (ie: the recursion didnt return any data) } else { set tag(data) $subdata }
}
lappend news [array get tag]
# reset the values set tmp(sindices) [list] set tmp(eindices) [list] }
return $news }
proc ::rss-synd::xmlGetInfo {data tags {element ""}} { set i 0
foreach {tdata} $data { array set tarray $tdata
if {[string match -nocase [lindex $tags 1] $tarray(name)]} { if {$i == [lindex $tags 0]} { if {[llength $tags] == 2} { if {[string length $element] > 0} { return $tarray($element) } else { return $tdata } } else { return [[namespace current]::xmlGetInfo $tarray(data) [lreplace $tags 0 1] $element] } } else { incr i } } }
if {[lindex $tags 0] == -1} { return $i } }
proc ::rss-synd::xmlJoinTags {args} { set list [list]
foreach tag $args { foreach item $tag { if {[string length $item] > 0} { lappend list $item } } }
return $list }
proc ::rss-synd::outputFeed {feedlist data {oldnews ""}} { array set feed $feedlist set msgs [list]
array set last[list "id" "" "title" "" "link" ""]
if {[string compare "" $oldnews] != 0} { if {[set oldfeedlist [[namespace current]::infoFeed [list] $oldnews]] == ""} { putlog "\002RSS Error\002: Invalid feed format ($feed(database))!" return }
array set oldfeed $oldfeedlist
set tmpp [[namespace current]::xmlJoinTags $oldfeed(tag-feed) $oldfeed(tag-list) 0 $oldfeed(tag-name)] set tmpd [[namespace current]::xmlGetInfo $oldnews $tmpp "data"]
if {[string compare "" $tmpd] == 0} { putlog "\002RSS Warning\002: Unable to compare current feed with the database, no relevant data found!" } else { array set last [[namespace current]::getCompareData $oldfeedlist $tmpd] } }
set path [[namespace current]::xmlJoinTags $feed(tag-feed) $feed(tag-list) -1 $feed(tag-name)] set count [[namespace current]::xmlGetInfo $data $path]
for {set i 0} {($i < $count) && ($i < $feed(announce-output))} {incr i} { set tmpp [[namespace current]::xmlJoinTags $feed(tag-feed) $feed(tag-list) $i $feed(tag-name)] set tmpd [[namespace current]::xmlGetInfo $data $tmpp "data"]
array set current [[namespace current]::getCompareData $feedlist $tmpd]
foreach msg $msgs { # chan can be a nick if run from a trigger with the right settings foreach chan $feed(channels) { if {([catch {botonchan $chan}] == 0) || ([[namespace current]::isChan $chan] == 0)} { if {($feed(type) == 1) || ($feed(type) == 3)} { putserv "NOTICE $chan :$msg" } else { putserv "PRIVMSG $chan :$msg" } } } } }
proc ::rss-synd::getCompareData {feedlist data} { array set feed $feedlist
if {[string compare -nocase [lindex $feed(tag-feed) 1] "feed"] == 0} { set list(title) [[namespace current]::xmlGetInfo $data[list 0 "title"] "data"] set list(id) [[namespace current]::xmlGetInfo $data[list 0 "id"] "data"] set list(link) "" array set tmp [[namespace current]::xmlGetInfo $data[list 0 "link"] "attrib"] catch {set list(link) $tmp(href)} unset tmp } else { set list(title) [[namespace current]::xmlGetInfo $data[list 0 "title"] "data"] set list(id) [[namespace current]::xmlGetInfo $data[list 0 "guid"] "data"] set list(link) [[namespace current]::xmlGetInfo $data[list 0 "link"] "data"] }
return [array get list] }
proc ::rss-synd::formatOutput {feedlist data current} { array set feed $feedlist set output $feed(output)
set eval 0 if {([info exists feed(evaluate-tcl)]) && ($feed(evaluate-tcl) == 1)} { set eval 1 }
set matches [regexp -inline -nocase -all -- {@@(.*?)@@} $output]
foreach {match tmpc} $matches { set tmpc [split $tmpc "!"] set index 0
set cookie [list] foreach piece $tmpc { set tmpp [regexp -nocase -inline -all -- {^(.*?)\((.*?)\)|(.*?)$} $piece]
# replace tag-item's index with the current article if {[string compare -nocase $feed(tag-name) [lindex $cookie 1]] == 0} { set cookie [[namespace current]::xmlJoinTags $feed(tag-list) [lreplace $cookie $index $index $current]] }
set cookie [[namespace current]::xmlJoinTags $feed(tag-feed) $cookie]