First what is nor working well is the mode setting at the End of the Script +m-c
Well it just post that
21:55.08 .•• deckel sets #gulli mode -c+m
21:55.10 ( @deckel ) Erstellt von: gullinews
21:55.12 ( @deckel ) Geschrieben am 07. 07. 2008 um 15:57
21:55.15 .•• deckel sets #gulli mode -m+c
The URL ist missing URL and the Binding .last does not work too
Here is the Script
- Code: Select all
# - Namespace - #
namespace eval ::rss {
# - Packages - #
# Http
package require http
# - Settings - #
# Feed
variable feed http://board.gulli.com/syndicate/newsticker.rss
# Style (Variablen: :title: :link:)
variable style "\[\002Gulli:Board\002\] \037Titel\037 :title: (Forum::info:) \n\037:link:\037"
# Zum Replacen
variable rep {
\xa0 ¡ \xa1 ¢ \xa2 £ \xa3 ¤ \xa4
¥ \xa5 ¦ \xa6 § \xa7 ¨ \xa8 © \xa9
ª \xaa « \xab ¬ \xac \xad ® \xae
¯ \xaf ° \xb0 ± \xb1 ² \xb2 ³ \xb3
´ \xb4 ´ \xb4 µ \xb5 ¶ \xb6 · \xb7 ¸ \xb8
¹ \xb9 º \xba » \xbb ¼ \xbc ½ \xbd
¾ \xbe ¿ \xbf À \xc0 Á \xc1 Â \xc2
à \xc3 Ä \xc4 Å \xc5 Æ \xc6 Ç \xc7
È \xc8 É \xc9 Ê \xca Ë \xcb Ì \xcc
Í \xcd Î \xce Ï \xcf Ð \xd0 Ñ \xd1
Ò \xd2 Ó \xd3 Ô \xd4 Õ \xd5 Ö \xd6
× \xd7 Ø \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 ÷ \xf7 ø \xf8 ù \xf9
ú \xfa û \xfb ü \xfc ý \xfd þ \xfe
ÿ \xff ƒ \u192 ‘ \u391 ’ \u392 “ \u393
” \u394 • \u395 – \u396 — \u397 ˜ \u398
™ \u399 š \u39A › \u39B œ \u39C \u39D
ž \u39E Ÿ \u39F \u3A0 ¡ \u3A1 £ \u3A3
¤ \u3A4 ¥ \u3A5 ¦ \u3A6 § \u3A7 ¨ \u3A8
© \u3A9 ± \u3B1 ² \u3B2 ³ \u3B3 ´ \u3B4
µ \u3B5 ¶ \u3B6 · \u3B7 ¸ \u3B8 ¹ \u3B9
º \u3BA » \u3BB ¼ \u3BC ½ \u3BD ¾ \u3BE
¿ \u3BF À \u3C0 Á \u3C1 Â \u3C2 Ã \u3C3
Ä \u3C4 Å \u3C5 Æ \u3C6 Ç \u3C7 È \u3C8
É \u3C9 Ñ \u3D1 Ò \u3D2 Ö \u3D6
• \u2022 … \u2026 2 \u2032 3 \u2033
> \u203E D \u2044 \u2118 \u2111
\u211C ™ \u2122 5 \u2135 \u2190
‘ \u2191 ’ \u2192 “ \u2193 ” \u2194 µ \u21B5
Ð \u21D0 Ñ \u21D1 Ò \u21D2 Ó \u21D3 Ô \u21D4
ý \u2200 \u2202 \u2203 \u2205
\u2207 \u2208 \u2209
\u220B \u220F
\u2211 \u2212 \u2217 \u221A
\u221D \u221E \u2220 &and ;\u2227 ( \u2228
) \u2229 * \u222A + \u222B 4 \u2234 < \u223C
E \u2245 H \u2248 ` \u2260 a \u2261 d \u2264
e \u2265 ‚ \u2282 ƒ \u2283 „ \u2284 † \u2286
‡ \u2287 • \u2295 — \u2297 ¥ \u22A5
Å \u22C5 \u2308 \u2309
\u230A
\u230B ) \u2329 * \u232A Ê \u25CA
` \u2660 c \u2663 e \u2665 f \u2666
" \x22 & \x26 < \x3C > \x3E Œ \u152
œ \u153 Š \u160 š \u161 Ÿ \u178
ˆ \u2C6 ˜ \u2DC \u2002 \u2003 \u2009
\u200C
\u200D \u200E \u200F – \u2013
— \u2014 ‘ \u2018 ’ \u2019 ‚ \u201A
“ \u201C ” \u201D „ \u201E † \u2020
‡ \u2021 ‰ \u2030 ‹ \u2039 › \u203A
€ \u20AC ´ \xb4
ä \xe4 ü \xfc ö \xf6 & .. & \x26
}
# - Setudef - #
# Flag
# RSS
setudef flag rss
# - Binds - #
# Pub
# Admin
bind pub nm|nm ".gulli" ::rss::admin
# Time
# Check
bind time -|- "?5 *" ::rss::check
# - Procs - #
# Admin
proc admin { nick host hand chan arg } {
switch -- [string toupper [lindex $arg 0]] {
ON {
channel set $chan +rss
putserv "notice $nick :\[\002RSS\002\] ist jetzt \037aktiviert\037"
}
OFF {
channel set $chan -rss
putserv "notice $nick :\[\002RSS\002\] ist jetzt \037deaktiviert\037"
}
STATUS {
putserv "notice $nick :\[\002RSS\002\] ist immoment \037[string map {1 aktiviert 2 deaktiviert} [channel get $chan rss]]\037"
}
default {
if {![channel get $chan rss]} { return 0 }
foreach {link title} [array get ::rss::last] {
if {$title == ""} { continue }
::rss::send $chan $title $link
}
}
}
}
# Check
proc check { args } {
variable feed
set curr $feed
if {![info exists ::rss::last($curr)]} {
set ::rss::last($curr) ""
}
putlog "\[\002RSS\002\] Checking \037$curr\037"
if {[catch { set token [http::geturl $curr -timeout 5000]} error] == 1} {
putlog "$error"
} elseif {[http::status $token] == "ok"} {
set output [http::data $token]
} elseif {[http::status $token] == "timeout"} {
putlog "Timeout occurred"
} elseif {[http::status $token] == "error"} {
putlog [http::error $token]
return 0
}
http::cleanup $token
if {![info exists output]} { return 0 }
if {![regexp -nocase -- {<item>.*?<title>(.+?)</title>} $output -> title]} {
putlog "\[\002RSS\002\] Error! Nothing found at $curr"
return 0
}
# regexp -nocase -- {Zitat #([0-9]*)\s} $title -> id
# regsub -all -nocase -- {Zitat #[0-9]*\s-\s} $title "" title
regsub -all -nocase -- "\n" $title "" title
if {[string equal -nocase $::rss::last($curr) $title]} {
return 0
}
set ::rss::last($curr) $title
regexp -nocase -- {<item>.*?<link>(.+?)</link>.*?<description>(.+?)</description>} $output -> link description
set description [string range $description 9 end-3]
regexp -nocase -- {Forum:(.+?)\n} $description -> info
regsub -all -nocase -- {Forum:.+?\n} $description "" description
regsub -all -nocase -- {<br />} $description "\n" description
# set text [string map $::rss::rep $text]
if {![info exists link]} { set link $curr }
foreach chan [channels] {
if {[channel get $chan rss]} {
utimer 5 [list ::rss::send $chan $title $link $info $description]
}
}
}
# Send
proc send { chan title link { info "" } { text ""} } {
variable style
regsub -all -nocase -- :url: $style $link style
regsub -all -nocase -- :link: $style $link style
regsub -all -nocase -- :title: $style $title style
regsub -all -nocase -- :line: $style $title style
regsub -all -nocase -- :info: $style $info style
# regsub -all -nocase -- :id: $style $id style
puthelp "mode $chan -c+m"
puthelp "privmsg $chan :[join $style]"
foreach line [split $text \n] {
puthelp "privmsg $chan :$line"
}
puthelp "mode $chan +c-m"
}