| View previous topic :: View next topic |
| Author |
Message |
Immow Voice
Joined: 24 Mar 2007 Posts: 3
|
Posted: Wed Mar 28, 2007 8:47 pm Post subject: RSS unicode problem [SOLVED] |
|
|
Hello,
I downloaded this script for Slennox's TCL archive. I contacted the person who wrote this script but he could not help me.
I tried searching the forum but found no clear answer.
For this reason I turn to you people and hope you can help me .
The problem is the bot gives wrong output for the RSS (strange symbols when a _ or ] is present)
Example: [KissSub]_Byousoku_5cm_Story 1_[A939AC1F].avi (<-- anime file that is not licensed so its legal).
I this has to do with unicode in the RSS feed.
The Windrop bot specifications:
version: 1.6.18
In lib folder there is: tcl8.4 folder
| Code: | namespace eval ::rss {
# --- namespace variable
namespace eval variable {
# string variable trigger {default}
variable trigger "!rss"
# string variable keyword {default}
variable keyword "rss"
# string variable flag
variable flag "nm|nm"
# integer variable botnick
# 0 = botnick keyword command text
# 1 = botnick command text
variable botnick 1
# integer variable update {default}
# 0 = no notify, if an update is available
# 1 = notify, if an update is available (only for bot owners)
variable update 1
# integer variable timer (must be greater or equal 15)
variable timer 15
# string variable skin (default skin)
variable skin "hey its newstime \[:counter: of :max:\] from :url: (:link:) - :title:"
# string variable database (no change need if rss.tcl is in the same directory like rss.db!)
variable database "[string range [info script] 0 end-7]rss.db"
# {{{ NOW don't change anything, if you aren't 100% sure what you are doing }}}
# {{{ NOW don't change anything, if you aren't 100% sure what you are doing }}}
# {{{ NOW don't change anything, if you aren't 100% sure what you are doing }}}
# {{{ NOW don't change anything, if you aren't 100% sure what you are doing }}}
# string variable up2date
variable up2date "http://stuff.christianhopf.de/script/index.php?script=rss"
# string variable regexp (for trigger)
variable regexp {[!|\?|.|-|²|\%|&|\*|:|\+|$|A-Z|a-z]}
# string variable author
variable author "2006 Christian 'chris' Hopf \002(\002#chris - www.christianhopf.de\002)\002"
# string variable version
variable version "v1.3.0.1"
# user defined
setudef str rss-skin
setudef int rss-timer
setudef int rss-counter
package require http
catch { unset ::rss } error
}
if { $::rss::variable::timer < 15 } {
set ::rss::variable::timer 15
}
if { [timerexists [list ::rss::getnewheadline]] == "" } {
timer $::rss::variable::timer [list ::rss::getnewheadline]
}
# binds
bind PUBM -|- {*} ::rss::pubm
bind MSGM -|- {*} ::rss::msgm
foreach time {12 15 19 00} {
bind TIME -|- "00 $time *" ::rss::up2date
}
# - void proc pubm {bind PUBM}
proc pubm { nickname hostname handle channel arguments } {
::rss::parse $nickname $hostname $handle $arguments $channel "pubm"
}
# - void proc msgm {bind MSGM}
proc msgm { nickname hostname handle arguments } {
::rss::parse $nickname $hostname $handle $arguments [lindex [split $arguments] 2] "msgm"
}
# - void proc up2date {bind TIME}
proc up2date { {args ""} } {
regexp -- {(.+) \| (.+) \| (.+) \| (.+) \| (.+)} [::rss::utilities::up2date] -> id name link version help
set publicversion [string map {"." ""} $version]
set scriptversion [string map {"v" "" "." ""} $::rss::variable::version]
if { $publicversion > $scriptversion } {
foreach owner [userlist n] {
if { [::rss::utilities::update $owner] && [hand2nick $owner] != "" } {
putserv "NOTICE [hand2nick $owner] :\002(\002\037rss\037\002)\002 a new version of your rss reader is available (v${version}). more infos at $help"
}
}
}
}
# - void proc parse
proc parse { nickname hostname handle arguments channel mode} {
global botnick rchannel lastparse lastchannel
set utrigger [::rss::utilities::trigger $handle]
set ukeyword [::rss::utilities::keyword $handle]
set rchannel $channel
if { $mode == "pubm" } {
if { $::rss::variable::botnick == 1 && [string equal -nocase $botnick [lindex [split $arguments] 0]] } {
set command [string tolower [lindex [split $arguments] 1]]
set arguments [join [lrange [split $arguments] 2 end]]
set lastparse "$botnick $command"
} elseif { $::rss::variable::botnick == 0 && [string equal -nocase $botnick [lindex [split $arguments] 0]] && [string equal -nocase $::rss::variable::keyword [lindex [split $arguments] 1]] } {
set command [string tolower [lindex [split $arguments] 2]]
set arguments [join [lrange [split $arguments] 3 end]]
set lastparse "$botnick $utrigger $command"
} elseif { [string equal -nocase $utrigger [lindex [split $arguments] 0]] } {
set command [string tolower [lindex [split $arguments] 1]]
set arguments [join [lrange [split $arguments] 2 end]]
set lastparse "$utrigger $command"
} else {
return
}
if {[string index [lindex [split $arguments] 0] 0] == "#" && [validchan [lindex [split $arguments] 0]]} {
set channel [lindex [split $arguments] 0]
set arguments [join [lrange [split $arguments] 1 end]]
}
} elseif { $mode == "msgm" } {
if { [string equal -nocase [lindex [split $arguments] 0] $ukeyword] } {
set command [lindex [split $arguments] 1]
set channel [lindex [split $arguments] 2]
set arguments [join [lrange [split $arguments] 3 end]]
set lastparse "$ukeyword $command"
} else {
return
}
} else {
return
}
if { ![matchattr $handle $::rss::variable::flag $channel] } {
return
} elseif {![info exists lastparse] || [llength [split $lastparse]] < 1} {
return
} elseif {(![info exists command] || [llength [split $command]] < 1)} {
return
} elseif { [info proc ::rss::command:$command] == "" } {
return
} elseif { ![validchan $channel] } {
if { $mode == "msgm" } {
putserv "PRIVMSG $nickname :\002(\002\037trigger\037\002)\002 you forgot the channel parameter!"
return
}
}
set lastchannel $channel
::rss::command:$command $nickname $hostname $handle $channel $arguments
}
# - void proc getnewheadline
proc getnewheadline { } {
global rss last update
::rss::utilities::init
foreach news [array names ::rss] {
set new($news) [join [::rss::utilities::reader $rss($news)]]
if { [llength [split $new($news)]] > 0 } {
set link($news) [lindex [split $new($news)] 0]
set title($news) [join [lrange [split $new($news)] 1 end]]
regexp {^http://(.*?)/.*} $link($news) -> url($news)
utimer 1 [list set update($news) "$link($news) $url($news) $title($news)"]
}
}
if { [timerexists [list ::rss::getnewheadline]] == "" } {
timer $::rss::variable::timer [list ::rss::getnewheadline]
}
if { [array size update] > 0 && [timerexists [list ::rss::queue]] == "" } {
utimer 20 [list ::rss::queue]
}
}
# - void proc queue
proc queue { } {
global update last
foreach news [array names update] {
set link [lindex [split $update($news)] 0]
set url [lindex [split $update($news)] 1]
set title [join [lrange [split $update($news)] 2 end]]
foreach channel [channels] {
if { [string match "*christianhopf.de*" $update($news)] && ![channel get $channel "rss-$news"] } {
channel set $channel "+rss-$news"
}
set maxnews 0
set count 0
foreach tocount [array names ::rss] {
set maxnews [expr $maxnews + [channel get $channel rss-${tocount}-news]]
}
if { [channel get $channel "rss-$news"] && (![info exists last($channel,$news)] || ![string equal -nocase $update($news) $last($channel,$news)]) } {
channel set $channel rss-${news}-news [set count [expr [channel get $channel rss-${news}-news] + 1]]
channel set $channel rss-counter [set maxnews [expr $maxnews + 1]]
if { [channel get $channel rss-skin] != "" } {
puthelp "PRIVMSG $channel :[string map "\":link:\" \"$link\" \":url:\" \"$url\" \":title:\" \"$title\" \":counter:\" \"$count\" \":max:\" \"$maxnews\"" [expr {([string match "*c*" [getchanmode $channel]]) ? "[stripcodes rcub [join [channel get $channel rss-skin]]]" : "[join [channel get $channel rss-skin]]"}]]"
} else {
puthelp "PRIVMSG $channel :[string map "\":link:\" \"$link\" \":url:\" \"$url\" \":title:\" \"$title\" \":counter:\" \"$count\" \":max:\" \"$maxnews\"" [expr {([string match "*c*" [getchanmode $channel]]) ? "[stripcodes rcub $::rss::variable::skin]" : "$::rss::variable::skin"}]]"
}
set last($channel,$news) $update($news)
}
}
unset update($news)
if { [array size ::update] > 0 && [timerexists [list ::rss::queue]] == "" } {
utimer 20 [list ::rss::queue]
}
return
}
}
if { ![string equal [md5 $::rss::variable::author] "011281e61b37fa84d5042e0d2ec3aec5"] } {
die "touching my copyright suxx :("
}
# - void proc add
proc command:add { nickname hostname handle channel arguments } {
global lastparse
if { ![matchattr $handle mn] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 you're not allowed to add rss feeds on this bot."
return
}
if { [llength $arguments] < 2 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 <\037handle\037> <\037rss link\037>"
return
}
if { [llength [::rss::utilities::reader [lindex [split $arguments] 1]]] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 Sorry, but your RSS Link isn't a valid RSS Link <:("
} elseif {[::rss::utilities::exists [lindex [split $arguments] 0] [lindex [split $arguments] 1]]} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS Activation OR Link does already appear in the database."
} elseif {[::rss::utilities::add [lindex [split $arguments] 0] [lindex [split $arguments] 1]]} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS feed successfully added to the database."
} else {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 error while adding rss feed to the database."
}
}
if { ![string equal "011281e61b37fa84d5042e0d2ec3aec5" [md5 $::rss::variable::author]] } {
die "dont touch teh [censored] copyright."
}
# - void proc remove
proc command:remove { nickname hostname handle channel arguments } {
global lastparse
if { ![matchattr $handle mn] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 you're not allowed to remove rss feeds on this bot."
return
}
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 <\037handle\037>"
return
}
if {![::rss::utilities::exists [lindex [split $arguments] 0]]} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS feed doesn't appear in the database."
} elseif {[::rss::utilities::remove [lindex [split $arguments] 0]]} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS feed successfully removed from the database."
} else {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 error while removing RSS feed from the database."
}
}
# - void proc skin
proc command:skin { nickname hostname handle channel arguments } {
global lastparse
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 <\037skin\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 variabl\037e\037\002:\002 :url: :link: :title: :counter: :max:"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 curren\037t\037\002:\002 [join [channel get $channel rss-skin]]"
return
}
channel set $channel rss-skin $arguments
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 successfully set new skin!"
}
# - void proc news
proc command:news { nickname hostname handle channel arguments } {
global lastparse rss
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 <\037handle\037> \037?number?\037"
return
}
if {![::rss::utilities::exists [lindex [split $arguments] 0]]} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS feed doesn't appear in the database."
} elseif {[llength [set result [::rss::utilities::reader $rss([lindex [split $arguments] 0]) [lindex [split $arguments] 1]]]] < 1} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 RSS feed seems to be down OR not valid."
} else {
foreach handler $result {
regsub -all {"} $handler "" handler
regsub -all {"} $handler "" handler
set link [lindex [split $handler] 0]
set title [join [lrange [split $handler] 1 end]]
regexp {^http://(.*?)/.*} $link -> url
if { [channel get $channel rss-skin] != "" } {
puthelp "PRIVMSG $channel :[string map "\":link:\" \"$link\" \":url:\" \"$url\" \":title:\" \"$title\" \":counter:\" \"[channel get $channel rss-[lindex [split $arguments] 0]-news]\" \":max:\" \"[channel get $channel rss-counter]\"" [expr {([string match "*c*" [getchanmode $channel]]) ? "[stripcodes rcub [join [channel get $channel rss-skin]]]" : "[join [channel get $channel rss-skin]]"}]]"
} else {
puthelp "PRIVMSG $channel :[string map "\":link:\" \"$link\" \":url:\" \"$url\" \":title:\" \"$title\" \":counter:\" \"[channel get $channel rss-[lindex [split $arguments] 0]-news]\" \":max:\" \"[channel get $channel rss-counter]\"" [expr {([string match "*c*" [getchanmode $channel]]) ? "[stripcodes rcub join $::rss::variable::skin]" : "$::rss::variable::skin"}]]"
}
}
}
}
# - void proc set
proc command:set { nickname hostname handle channel arguments } {
global lastparse rss
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 <\037handle\037> \037?enable|on?|?disable|off?\037"
set show [list]
foreach news [array names ::rss] {
lappend show "[expr {([channel get $channel "rss-$news"]) ? "\002(\002+\002)\002" : "\002(\002-\002)\002"}]$news"
if { [llength $show] == 5 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 [join $show ", "]"
set show [list]
}
}
if { [llength $show] == 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $show"
} elseif { [llength $show] > 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 [join $show ", "]"
}
return
}
set setudef [lindex [split $arguments] 0]
set status [string tolower [lindex [split $arguments] 1]]
if { ![::rss::utilities::exists $setudef] && ![string equal -nocase $setudef "all"] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 Your Activation name doesn't exist <:("
return
}
switch -- $status {
{enable} - {on} {
if { [string equal -nocase $setudef "all"] } {
foreach news [array names ::rss] {
channel set $channel "+rss-$news"
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 all [llength [array names ::rss]] rss feeds were \0033enabled\003."
} else {
channel set $channel +rss-$setudef
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $setudef was successfully \0033enabled\003."
}
}
{disable} - {off} {
if { [string equal -nocase $setudef "all"] } {
foreach news [array names ::rss] {
channel set $channel "-rss-$news"
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 all [llength [array names ::rss]] rss feeds were \0034disabled\003."
} else {
channel set $channel -rss-$setudef
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $setudef was successfully \0034disabled\003."
}
}
{default} {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $setudef is [expr {([channel get $channel "rss-$setudef"]) ? "\0033enabled\003" : "\0034disabled\003"}]."
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse \037?#channel?\037 $setudef \037?enable|on?|?disable|off?\037"
}
}
}
if { ![string equal "011281e61b37fa84d5042e0d2ec3aec5" [md5 $::rss::variable::author]] } {
die "you're a lamer :("
}
# - void proc show
proc command:show { nickname hostname handle channel arguments } {
global lastparse rss
set show [list]
foreach news [array names ::rss] {
lappend show "[expr {([channel get $channel "rss-$news"]) ? "\002(\002+\002)\002" : "\002(\002-\002)\002"}]$news"
if { [llength $show] == 5 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 [join $show ", "]"
set show [list]
}
}
if { [llength $show] == 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $show"
} elseif { [llength $show] > 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 [join $show ", "]"
}
}
# - void proc up2date?
proc command:up2date? { nickname hostname handle channel arguments } {
if {[info exists ::rssflood(protection_u)] && [expr [unixtime] - $::rssflood(protection_u)] < 120} {
return
}
set ::rssflood(protection_c) [unixtime]
regexp -- {(.+) \| (.+) \| (.+) \| (.+) \| (.+)} [::rss::utilities::up2date] -> id name link version help
set publicversion [string map {"." ""} $version]
set scriptversion [string map {"v" "" "." ""} $::rss::variable::version]
if { $publicversion > $scriptversion } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 ffs, your script is out of date <:( please update it to the new one v${version} ($help)"
} else {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your script is up to date :o)"
}
}
# - void proc contact
proc command:contact { nickname hostname handle channel arguments } {
if {[info exists ::rssflood(protection_c)] && [expr [unixtime] - $::rssflood(protection_c)] < 120} {
return
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 eMai\037l\037\002:\002 mail@dev.christianhopf.de - irc\002:\002 #chris at QuakeNet - web\002:\002 www.christianhopf.de"
set ::rssflood(protection_c) [unixtime]
}
# - void proc webhelp
proc command:webhelp { nickname hostname handle channel arguments } {
if {[info exists ::rssflood(protection_w)] && [expr [unixtime] - $::rssflood(protection_w)] < 120} {
return
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 webhelp\002:\002 http://www.christianhopf.de/?page_id=48"
set ::rssflood(protection_w) [unixtime]
}
# - void proc version
proc command:version { nickname hostname handle channel arguments } {
if {[info exists ::rssflood(protection_v)] && [expr [unixtime] - $::rssflood(protection_v)] < 120} {
return
}
if { [string match "*c*" [getchanmode $channel]] } {
putserv "PRIVMSG $channel :\001ACTION [stripcodes rcub "is running the rss reader $::rss::variable::version (c) $::rss::variable::author"]\001"
} else {
putserv "PRIVMSG $channel :\001ACTION is running the rss reader $::rss::variable::version \002(\002c\002)\002 $::rss::variable::author\001"
}
set ::rssflood(protection_v) [unixtime]
}
# - void proc trigger
proc command:trigger { nickname hostname handle channel arguments } {
global botnick botname lastparse
set trigger [::rss::utilities::trigger $handle]
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse <\037trigger\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your personal trigger is $trigger"
return
} elseif { [llength [set trigger [string map { " " "" } [join [regexp -all -inline "$::rss::variable::regexp" [split [lindex [split $arguments] 0]]]]]]] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your trigger has too many charactes which are not allowed as trigger"
return
}
setuser $handle XTRA rss-trigger $trigger
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your personal trigger is now: [getuser $handle XTRA rss-trigger]"
}
# - void proc keyword
proc command:keyword { nickname hostname handle channel arguments } {
global botnick botname lastparse
set keyword [::rss::utilities::keyword $handle]
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse <\037keyword\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your personal keyword is $keyword"
return
} elseif { ![regexp -nocase {^[a-z]{1,}$} [lindex [split $arguments] 0]] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 only alphabetical chars are allowed."
return
}
setuser $handle XTRA rss-keyword [lindex [split $arguments] 0]
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your personal keyword is now: [getuser $handle XTRA rss-keyword]"
}
# - void proc update
proc command:update { nickname hostname handle channel arguments } {
global botnick botname lastparse
set update [::rss::utilities::update $handle]
if { [llength $arguments] < 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 synta\037x\037\002:\002 $lastparse <\0371|0\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 currently update info is [expr {([getuser $handle XTRA rss-update]) ? "\0033enabled\003" : "\0034disabled\003"}]"
return
} elseif { ![string is int [lindex [split $arguments] 0]] && [lindex [split $arguments] 0] != 0 && [lindex [split $arguments] 0] != 1 } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 only 1 and 0 are as value allowed."
return
}
setuser $handle XTRA rss-update [lindex [split $arguments] 0]
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 your personal updater info is now: [expr {([getuser $handle XTRA rss-update]) ? "\0033enabled\003" : "\0034disabled\003"}]"
}
# - void proc help
proc command:help { nickname hostname handle channel arguments } {
::rss::command:userhelp $nickname $hostname $handle $channel $arguments
}
# - void proc showcommands
proc command:showcommands { nickname hostname handle channel arguments } {
::rss::command:userhelp $nickname $hostname $handle $channel $arguments
}
# - void proc commands
proc command:commands { nickname hostname handle channel arguments } {
::rss::command:userhelp $nickname $hostname $handle $channel $arguments
}
# - void proc userhelp
proc command:userhelp { nickname hostname handle channel arguments } {
set trigger [::rss::utilities::trigger $handle]
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 \037rss command overview\002\037:\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger news \037?#channel?\037 <\037handle\037> \037?number?\037"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger set \037?#channel?\037 <\037handle|all\037> \037?enable|on?\037|\037?disable|off?\037>"
if { [matchattr $handle mn] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger add <\037handle\037> <\037rss link\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger remove <\037handle\037>"
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger show \037?#channel?\037"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger skin \037?#channel?\037 <\037skin\037>"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger up2date?"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 \037user command overview\002\037:\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger trigger \037?trigger?\037 \002(\002personal trigger\002)\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger keyword \037?keyword?\037 \002(\002personal keyword\002)\002"
if { [matchattr $handle n] } {
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger update \037?1|0?\037 \002(\002personal update info (on/off))\002)\002"
}
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 \037author command overview\002\037:\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger webhelp"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger contact"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002 $trigger version \037?#channel?\037"
putserv "NOTICE $nickname :\002(\002\037rss\037\002)\002"
putserv "NOTICE $nickname :\002(\002\037rss\037\002) \037note\037:\002 \037?word?\037 -> optional AND <\037word\037> -> required"
}
# namespace eval utilities
namespace eval utilities {
# - void proc up2date
proc up2date { } {
set connection [http::config -useragent "Mozilla 4.0"]
if {[catch { set connection [http::geturl $::rss::variable::up2date -timeout 1000] } error]} {
putlog "\002(\002\037rss\037\002)\002 error while reading up2date site. \002(\002$error\002)\002"
return
}
set source [string trim [http::data $connection]]
http::cleanup $connection
foreach data [split $source "\n"] {
if { [regexp -- {^<input type='hidden' value='(.+)'>} $data -> result] } {
return $result
}
}
}
# - void proc reader
proc reader { url {number 1} } {
set count 0
set result [list]
if { ![string is int $number] || $number < 1} {
set number 1
}
set connection [http::config -useragent "Mozilla 4.0"]
if {[catch { set connection [http::geturl $url -timeout 2000] } error]} {
putlog "\002(\002\037rss\037\002)\002 error while reading rss at $url. \002(\002$error\002)\002"
return
}
set source [string trim [http::data $connection]]
http::cleanup $connection
foreach {item content} [regexp -all -inline {(?i)<item.*?>(.*?)</item>} $source] {
incr count
regsub -all "\n" $content "" content
regsub -all {"} $content "" content
regsub -all {"} $content "" content
regexp -- {(?i)<title.*?>(.*?)</title>} $content -> title
regexp -- {^.*<!\[CDATA\[(.*?)\]\]>$} $title -> title
regexp -- {(?i)<link.*?>(.*?)</link} $content -> link
regexp -- {^.*<!\[CDATA\[(.*?)\]\]>$} $link -> link
lappend result "[::rss::utilities::html2text $link] [::rss::utilities::html2text $title]"
if { $count == $number } {
return $result
}
}
return $result
}
# - void proc exists
proc exists { setudef {url ""} } {
if {[catch { set database [open $::rss::variable::database "r"] } error]} {
return 0
}
while {![eof $database]} {
if { [set line [gets $database]] != "" && ([string equal -nocase [lindex [split $line] 1] $url] || [string equal -nocase [lindex [split $line] 0] "rss-$setudef"]) } {
return 1
}
}
close $database
return 0
}
# - void proc add
proc add { setudef url } {
global rss
if {[catch { set database [open $::rss::variable::database "a"] } error]} {
return 0
}
puts $database "rss-$setudef $url"
setudef flag rss-$setudef
setudef int rss-${setudef}-news
set rss($setudef) $url
close $database
return 1
}
# - void proc remove
proc remove { setudef } {
global rss
if {[catch { set database [open $::rss::variable::database "r"] } error]} {
return 0
}
set refill [list]
while {![eof $database]} {
if {[set line [gets $database]] == "" } {
continue
}
if { [string equal -nocase [lindex [split $line] 0] "rss-$setudef"] } {
deludef flag "rss-$setudef"
deludef int rss-${setudef}-news
unset rss($setudef)
continue
}
lappend refill $line
}
close $database
set database [open $::rss::variable::database "w"]
foreach data_refill $refill {
puts $database $data_refill
}
close $database
return 1
}
# - void proc trigger
proc trigger { handle } {
set utrigger [getuser $handle XTRA rss-trigger]
if {[llength $utrigger] < 1 || ![validuser $handle]} {
set utrigger [join [string trim $::rss::variable::trigger]]
}
return $utrigger
}
# - void proc update
proc update { handle } {
set uupdate [getuser $handle XTRA rss-update]
if {[llength $uupdate] < 1 || ![validuser $handle]} {
set uupdate [join [string trim $::rss::variable::update]]
}
return $uupdate
}
# - void proc keyword
proc keyword { handle } {
set ukeyword [getuser $handle XTRA rss-keyword]
if {[llength $ukeyword] < 1 || ![validuser $handle]} {
set ukeyword [join [string trim $::rss::variable::keyword]]
}
return $ukeyword
}
# - void proc init
proc init { } {
global notloaded loaded rss
set notloaded 0
set loaded 0
catch { array unset rss } error
if {[catch { set database [open $::rss::variable::database "r"] } error]} {
return 0
}
while {![eof $database]} {
if {[set line [gets $database]] == "" } {
continue
}
if { [string equal -nocase [string range [lindex [split $line] 0] 0 3] "rss-"] } {
setudef flag [lindex [split $line] 0]
setudef int [lindex [split $line] 0]-news
set rss([string range [lindex [split $line] 0] 4 end]) [lindex [split $line] 1]
incr loaded
} else {
putlog "[lindex [split $line] 0] isnt a valid flag for ur RSS Reader <:("
incr notloaded
}
}
close $database
}
# - void proc html2text
proc html2text { string } {
foreach {html text} [list {…} {...} {ß} {ß} {ä} {ä} { } { } {ü} {ü} {"} {\x22} {'} {\x27} {&} {\x26} {<} {\x3C} {>} {\x3E} { } {\x20} {¡} {\xA1} {¤} {\xA4} {¢} {\xA2} {£} {\xA3} {¥} {\xA5} {¦} {\xA6} {§} {\xA7} {¨} {\xA8} {©} {\xA9} {ª} {\xAA} {«} {\xAB} {¬} {\xAC} {­} {\xAD} {®} {\xAE} {¯} {\xAF} {°} {\xB0} {±} {\xB1} {²} {\xB2} {³} {\xB3} {´} {\xB4} {µ} {\xB5} {¶} {\xB6} {·} {\xB7} {¸} {\xB8} {¹} {\xB9} {º} {\xBA} {»} {\xBB} {¼} {\xBC} {½} {\xBD} {¾} {\xBE} {¿} {\xBF} {×} {\xD7} {÷} {\xF7} {À} {\xC0} {Á} {\xC1} {Â} {\xC2} {Ã} {\xC3} {Ä} {\xC4} {Å} {\xC5} {Æ} {\xC6} {Ç} {\xC7} {È} {\xC8} {É} {\xC9} {Ê} {\xCA} {Ë} {\xCB} {Ì} {\xCC} {Í} {\xCD} {Î} {\xCE} {Ï} {\xCF} {Ð} {\xD0} {Ñ} {\xD1} {Ò} {\xD2} {Ó} {\xD3} {Ô} {\xD4} {Õ} {\xD5} {Ö} {\xD6} {Ø} {\xD8} {Ù} {\xD9} {Ú} {\xDA} {Û} {\xDB} {Ü} {\xDC} {Ý} {\xDD} {Þ} {\xDE} {ß} {\xDF} {à} {\xE0} {á} {\xE1} {â} {\xE2} {ã} {\xE3} {ä} {\xE4} {å} {\xE5} {æ} {\xE6} {ç} {\xE7} {è} {\xE8} {é} {\xE9} {ê} {\xEA} {ë} {\xEB} {ì} {\xEC} {í} {\xED} {î} {\xEE} {ï} {\xEF} {ð} {\xF0} {ñ} {\xF1} {ò} {\xF2} {ó} {\xF3} {ô} {\xF4} {õ} {\xF5} {ö} {\xF6} {ø} {\xF8} {ù} {\xF9} {ú} {\xFA} {û} {\xFB} {ü} {\xFC} {ý} {\xFD} {þ} {\xFE} {ÿ} {\xFF}] {
set string [string map "\"$html\" \"$text\"" $string]
}
return $string
}
}
# load existing rss
::rss::utilities::init
# log
putlog "rss reader version <${::rss::variable::version}> (c) $::rss::variable::author successfully loaded ..."
putlog "rss database has $::loaded RSS feeds and $::notloaded RSS feeds are failed"
} |
I have very little understand of TCL so don't expect too much of me 
Last edited by Immow on Tue Apr 03, 2007 11:00 am; edited 1 time in total |
|
| Back to top |
|
 |
smash Halfop
Joined: 31 Jul 2006 Posts: 45
|
Posted: Wed Mar 28, 2007 10:10 pm Post subject: |
|
|
# string variable author
variable author "2006 Christian 'chris' Hopf \002(\002#chris - www.christianhopf.de\002)\002"
i use this script and it works ok for me!
you can find chris on irc.quakenet.org #chris
try asking chris for help with the script hes a nice chap.  _________________ quakenet #fraguk www.fraguk.com
hosting 113 scripts @ this time! |
|
| Back to top |
|
 |
Immow Voice
Joined: 24 Mar 2007 Posts: 3
|
Posted: Thu Mar 29, 2007 4:25 am Post subject: |
|
|
I downloaded this script for Slennox's TCL archive. I contacted the person who wrote this script but he could not help me.
I know he is nice but he could not find a solution.
Is there no way to just remove the "" symbols from the output? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|