This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

RSS news by demond

Support & discussion of released scripts, and announcements of new releases.
Post Reply
g
grrmisfit
Voice
Posts: 6
Joined: Sat Mar 29, 2008 4:24 pm

Post by grrmisfit »

anyone having issues with google news? im getting time outs over and over
T
Tommyken
Voice
Posts: 11
Joined: Wed Apr 09, 2008 1:11 pm

Post by Tommyken »

i got this problem
i took the examples like in the tcl file exists, but i recieved from every rss site i called

[19:49] <Tommyken>!news osnews
[19:49] -Elisaken- no news from osnews on #FTD.usenet

this is what it stands in the tcl file
set feeds(osnews:#chan1) {17 http://www.osnews.com/files/recent.rdf}

thx advanced for who can help

now its works, i don't get it. (above is fixed)
*
*
But how can i configurate that i can get maximum 10 posts showed ?
Z
Zerg
Halfop
Posts: 49
Joined: Sat May 20, 2006 10:03 am

only one command for news...

Post by Zerg »

hello,
can i use only one command?

!news newsinfo
!news newsinfo number

is the standard.

can i put it into a bind?

example:
bind - pub ?info !news newsinfo

that i can use only: ?info and ?info number

my tcl is very bad.
thx for help.
d
diven
Voice
Posts: 3
Joined: Mon Mar 30, 2009 12:10 pm

Re: CDATA Propblem from rssnews on the egghelp Archive

Post by diven »

Zerg wrote:
Alchera wrote:
Zerg wrote: Hello, i use version 2.2 (from tcl archive because the directlink is off) and have a side that display the CDATA in the channel.

<Kneipenwirt> Breaking news from <![CDATA[Bundesliga.de - Alle News]]> | <![CDATA[Immer am Ball. Mit Bundesliga.de]]>!
<Kneipenwirt> (1) Bundesliga: Mit "Schweini" und Ribery gegen die "Knappen"
<Kneipenwirt> Breaking news from <![CDATA[Bundesliga.de - Alle News]]> | <![CDATA[Immer am Ball. Mit Bundesliga.de]]>!
<Kneipenwirt> (1) International: Vogts-Nachfolger steht fest

from:

http://www.bundesliga.de/rss/de/rss_news.xml

thx for the great script.
And what exactly is your "problem"; nothing indicates any.
Hello,
the CDATA in the past from the bot is false. it issnt a correct news head info.

Kneipenwirt> Breaking news from <![CDATA[Bundesliga.de - Alle News]]> | <![CDATA[Immer am Ball. Mit Bundesliga.de]]>!

must be:
Breaking news from Bundesliga.de - Alle News | Immer am Ball. Mit Bundesliga.de!
I changed line 149 as follows:

Code: Select all

if {[regexp {(?i)<description><!\[CDATA\[(.*?)\]\]></description>} $data -> foo]}  {
Seems to be working so far...
B
Behemoth
Voice
Posts: 20
Joined: Mon May 19, 2008 7:23 am
Location: Mauritius
Contact:

Rss News by demond

Post by Behemoth »

Hi there

am having this in my PL

Tcl error [::rssnews::timer]: can't use non-numeric string as operand of "%"

can anyone help me out plz ?

and plz, i wanna knw if the bot gives the news on chan if !news BBC as for e.g

regards
Http://optix-pro.labrute.fr/
Http://ircaz.fr/

Losers Always Whine About Their Best, But Winners Go Home And F*** The Prom Queen!
User avatar
Thanhas
Op
Posts: 124
Joined: Sat Sep 02, 2006 11:14 am
Location: Ottawa, Canada

Post by Thanhas »

Nice TCL i appreciate

but th thing is when i load it my BOT is lagging badly may i know the Solution?
Thanks
D
Dreamxtreme
Voice
Posts: 4
Joined: Thu May 27, 2010 10:15 am

Post by Dreamxtreme »

Code: Select all

[15:10] rssnews-2.2: ERROR(failblog:#xtreme): timeout
[15:10] rssnews-2.2: ERROR(diggupcoming:#xtreme): timeout
[15:12] rssnews-2.2: ERROR(digg:#xtreme): timeout
I keep getting these errors even though the net works fine

Can anyone help thanks :D
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Post by Football »

Hey, I was wondering if anyone could modify the script so it will require a flag in order to work in a room. i mean: .chanset #channel +rssnews
Please?

Code: Select all

#######################################################################
#                                                                     #
# rssnews.tcl - RSS news announcer for eggdrop by demond@demond.net   #
#                                                                     #
#               this will announce the updated news from RSS feed(s), #
#               periodically polling the feed(s); supports multiple   #
#               channels/multiple feeds per channel; you only need to #
#               set up your feeds array, see below; secure (SSL) and  #
#               private (password-protected) feeds are also supported #
#                                                                     #
#        Usage: !news <feed name> [news index #] - from channel       # 
#               .rss <add|del|list> [name:#chan] - from partyline     #
#                                                                     #
#######################################################################

package require Tcl 8.3
package require eggdrop 1.6
package require http 2.0

namespace eval rssnews {

# set your feed(s) sources here: feed name, channel, poll frequency in mins, feed URL
set feeds(IMS:#football) {10 http://feeds.feedburner.com/imscouting/xhEv}

#set feeds(google:#chan2) {11 http://news.google.com/news?ned=us&topic=h&output=rss}
#
# if you have to use password-protected feed, set it up like this:
#
#set feeds(name3:#chan3) {13 http://some.site.com/feed username password}

# maximum number of announced new headlines
#
variable maxnew 5

# feed fetch timeout in seconds
#
variable timeout 20

# public trigger flood settings
#
variable pubflud 5:15

# support SSL feeds (requires TLS package)
#
variable usessl 0

# if usessl is 1, request/require valid certificate from server
#
variable reqcert yes:no

#######################################################################
# nothing to edit below

variable version "rssnews-2.2"

if {$usessl} {
	package require tls 1.5
	scan $reqcert {%[^:]:%s} r1 r2
	if {$r1 == "yes"} {set r1 1} {set r1 0}
	if {$r2 == "yes"} {set r2 1} {set r2 0}
	set ssl [list ::tls::socket -request $r1 -require $r2]
	::http::register https 443 $ssl
}

bind dcc  m rss   [namespace current]::rss
bind pub  - .news [namespace current]::news
bind time - *     [namespace current]::timer

putlog "$version by demond loaded"

proc timer {min hour day month year} {
	variable feeds
	if {[info exists feeds]} {
	set mins [expr [scan $min %d]+[scan $hour %d]*60]
	foreach {chanfeed settings} [array get feeds] {		
		if {$mins % [lindex $settings 0] == 0} {
			if {[llength $settings] > 2} {
				foreach {t url user pass} $settings {break} 
				fetch $url $chanfeed $user $pass
			} {
				foreach {t url} $settings {break}
				fetch $url $chanfeed
			}
		}
	}}
}

proc fetch {url chanfeed args} {
	variable timeout
	variable version; variable token
	set to [expr {$timeout * 1000}]
	set cmd [namespace current]::callback
	if {[llength $args] > 0} {
		foreach {user pass} $args {break}
		set hdr [list Authorization "Basic [b64en $user:$pass]"]
	} {	set hdr {}}
	::http::config -useragent "$version by demond"
	if {[catch {set t [::http::geturl $url -command $cmd -timeout $to -headers $hdr]} err]} {
		putlog "$version: ERROR($chanfeed): $err"
	} {
		set token($t) [list $url $chanfeed $args]
	}
}

proc callback {t} {
	variable version; variable token
	foreach {url chanfeed args} $token($t) {break}
	switch -exact [::http::status $t] {
	"timeout" {
		putlog "$version: ERROR($chanfeed): timeout"
	}
	"error" {
		putlog "$version: ERROR($chanfeed): [::http::error $t]"
	}
	"ok" {
		switch -glob [::http::ncode $t] {
		3* {
			upvar #0 $t state
			array set meta $state(meta)
			fetch $meta(Location) $chanfeed $args
		}
		200 {
			process [::http::data $t] $chanfeed
		}
		default {
			putlog "$version: ERROR($chanfeed): [::http::code $t]"
		}}
	}
	default {
		putlog "$version: ERROR($chanfeed): got EOF from socket"
	}}
	::http::cleanup $t
}

proc process {data chanfeed} {
	variable news; variable hash
	variable maxnew; variable source
	set idx 1; set count 0
	scan $chanfeed {%[^:]:%s} feed chan
	set news($chanfeed) {}; set source($chanfeed) ""
	if {[regexp {(?i)<title>(.*?)</title>} $data -> foo]} {
		append source($chanfeed) $foo
	}
	if {[regexp {(?i)<description>(.*?)</description>} $data -> foo]} {
		append source($chanfeed) " | $foo"
	}
	set infoline $source($chanfeed)
	regsub -all {(?i)<items.*?>.*?</items>} $data {} data
	foreach {foo item} [regexp -all -inline {(?i)<item.*?>(.*?)</item>} $data] {
		regexp {(?i)<title.*?>(.*?)</title>}  $item -> title
		regexp {(?i)<link.*?>(.*?)</link}     $item -> link
		regexp {(?i)<desc.*?>(.*?)</desc.*?>} $item -> descr
		if {![info exists title]} {set title "(none)"}
		if {![info exists link]}  {set link  "(none)"}
		if {![info exists descr]} {set descr "(none)"}
		strip title link descr
		if {[info exists hash($chanfeed)]} {
		if {[lsearch -exact $hash($chanfeed) [md5 $title]] == -1 && [botonchan $chan]} {
			if {![info exists header]} {
				if {$infoline == ""} {set header $feed} {set header $infoline} 
				#puthelp "privmsg $chan :\002Breaking news\002 from $header!"
			}
			if {$count < $maxnew} {
				puthelp "privmsg $chan :$feed (\00304$idx\003) $title"
				incr count
			} {
				lappend indices $idx
			}
		}}
		lappend news($chanfeed) [list $title $link $descr]
		lappend hashes [md5 $title]
		incr idx
	}
	if {[info exists indices] && [botonchan $chan]} {
		set count [llength $indices]
		set indices "(indices:4 [join $indices {1,4 }]1)"
		puthelp "privmsg $chan :(\00304$count\003) more $indices" 
	}
	set hash($chanfeed) $hashes
}

proc strip {args} {
	variable html
	foreach a $args {
		upvar $a x
		set amp {& &}
		set x [string map $amp $x]
		set x [string map $html $x]
		while {[regexp -indices {(&#[0-9]{1,3};)} $x -> idxs]} {
			set b [lindex $idxs 0]; set e [lindex $idxs 1]
			set num [string range $x [expr {$b+2}] [expr {$e-1}]]
			if {$num < 256} {
				set x [string replace $x $b $e [format %c $num]]
			}
		}
		regexp {(?i)<!\[CDATA\[(.*?)\]\]>}   $x ->    x
		regsub -all {(?i)</t[dr]><t[dr].*?>} $x { | } x
		regsub -all {(?i)(<p>|<br>|\n)}      $x { }   x
		regsub -all {<[^<]+?>}               $x {}    x
	}
}

proc rss {hand idx text} {
	variable feeds
	if {$text == ""} {
		putdcc $idx "Usage: .$::lastbind <add|del|list> \[name:#chan \[feed\]\]"
		return
	}
	set text [split $text]
	switch [lindex $text 0] {
		"list" {
			if {[info exists feeds]} {
			foreach {chanfeed settings} [array get feeds] {
				putdcc $idx "$chanfeed -> [join $settings]" 
			}}
		}
		"add" {
			if {[llength $text] < 4} {
				putdcc $idx "not enough add arguments"
				return
			}
			set chanfeed [lindex $text 1]
			if {[info exists feeds]} {
			set names [string tolower [array names feeds]]
			if {[lsearch -exact $names [string tolower $chanfeed]] != -1} {
				putdcc $idx "$chanfeed already exists"
				return
			}}
			set feeds($chanfeed) [lrange $text 2 end]
		}
		"del" {
			set chanfeed [lindex $text 1]
			if {[info exists feeds]} {
			set names [string tolower [array names feeds]]
			if {[lsearch -exact $names [string tolower $chanfeed]] == -1} {
				putdcc $idx "$chanfeed does not exist"
				return
			} {
				unset feeds($chanfeed) 
			}}
		}
		default {
			putdcc $idx "invalid sub-command"
			return
		}

	}
	return 1 
}

proc news {nick uhost hand chan text} {
	variable source
	variable news; variable feeds
	variable pcount; variable pubflud
	if {[info exists pcount]} {
		set n [lindex $pcount 1]; incr n
		set ts [lindex $pcount 0]
		set pcount [list $ts $n]
		scan $pubflud {%[^:]:%s} maxr maxt
		if {$n >= $maxr} {
			if {[unixtime] - $ts <= $maxt} {return}
			set n 1; set ts [unixtime]
		}
	} {
		set n 1; set ts [unixtime]
	}
	set pcount [list $ts $n]
	set num [lindex [split $text] 1]
	set feed [lindex [split $text] 0]
	if {$text == ""} {
		foreach {key value} [array get feeds] {
			scan $key {%[^:]:%s} name channel
			if {[string eq -noc $chan $channel]} {
				lappend names $name
			}
		}
		if {[info exists names]} {
			set names [join $names {, }]
			puthelp "privmsg $nick :feed(s) for $chan: $names"
			puthelp "privmsg $nick :type $::lastbind <feed> \[index#\]"
		} {
			puthelp "privmsg $nick :no feed(s) for $chan"
		}
		return 1
	}
	if {![info exists news($feed:$chan)]} {
		puthelp "privmsg $nick :no news from $feed on $chan"
		return 1
	}
	if {$num == ""} {
		set idx 1
		if {$source($feed:$chan) != ""} {
			set title $source($feed:$chan)
		} {
			set title [lindex $feeds($feed:$chan) 1]
		}
		puthelp "privmsg $nick :News source: $feed \002$title\002"
		foreach item $news($feed:$chan) {
			puthelp "privmsg $nick :(\00304$idx\003) [lindex $item 0]"
			incr idx
		}
		return 1
	} elseif {![string is integer $num]} {
		puthelp "privmsg $nick :news index must be number"
		return 1
	}
	if {$num < 1 || $num > [llength $news($feed:$chan)]} {
		puthelp "privmsg $nick :no such news index, try $::lastbind $feed"
		return 1
	} {
		set idx [expr {$num-1}]
		#puthelp "privmsg $chan :title (\00304$num\003)\: [lindex [lindex $news($feed:$chan) $idx] 0]"
		puthelp "privmsg $chan :description (\00304$num\003)\: [lindex [lindex $news($feed:$chan) $idx] 2]"
		puthelp "privmsg $chan :link (\00304$num\003)\: [lindex [lindex $news($feed:$chan) $idx] 1]"
		return 1
	}
}

# this proc courtesy of RS,
# from http://wiki.tcl.tk/775 
proc b64en str {
	binary scan $str B* bits
	switch [expr {[string length $bits]%6}] {
		0 {set tail ""}
		2 {append bits 0000; set tail ==}
		4 {append bits 00; set tail =}
	}
	return [string map {
		000000 A 000001 B 000010 C 000011 D 000100 E 000101 F
		000110 G 000111 H 001000 I 001001 J 001010 K 001011 L
		001100 M 001101 N 001110 O 001111 P 010000 Q 010001 R
		010010 S 010011 T 010100 U 010101 V 010110 W 010111 X
		011000 Y 011001 Z 011010 a 011011 b 011100 c 011101 d
		011110 e 011111 f 100000 g 100001 h 100010 i 100011 j
		100100 k 100101 l 100110 m 100111 n 101000 o 101001 p
		101010 q 101011 r 101100 s 101101 t 101110 u 101111 v
		110000 w 110001 x 110010 y 110011 z 110100 0 110101 1
		110110 2 110111 3 111000 4 111001 5 111010 6 111011 7
		111100 8 111101 9 111110 + 111111 /
	} $bits]$tail
}

variable html {
	"     \x22  &apos;     \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
}

}
Idling at #Football, Quakenet.
l
lee8oi
Halfop
Posts: 63
Joined: Sat Jun 04, 2011 2:05 pm
Location: Michigan,United States.
Contact:

I hacked this script up. Heres what i got.

Post by lee8oi »

I did some hacking on this script to make it more suitable for my purposes. Which includes tinyurl support, showing urls in announcements, and improved html/markup cleanup. This script hasn't been thoroughly tested but its been working for me just fine. Beware of encoding issues/etc and currently only basic RSS feeds are supported same as with the original script.

Heres the link to my hack of this script: https://github.com/lee8oi/drss/blob/master/drss.tcl

I hope this helps some of you guys posting in this thread.
V
VictorC
Voice
Posts: 1
Joined: Wed Feb 10, 2016 3:32 pm

Re: I hacked this script up. Heres what i got.

Post by VictorC »

lee8oi wrote:Beware of encoding issues
Hello, thank you for your work!
I have problems with encoding as you said... Any idea how it can be fixed?
This rss feed works ok, even with right encoding http://www.root.cz/rss/zpravicky/
This isnt http://www.novinky.cz/rss/
Thanks in advance for help.
VicC
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Post by roughnecks »

All I'm getting is this:

<~roughnecks> | .news ansa
no news from ansa on "#channel"

No feed in channel, no errors, nothing at all, can someone help?
Post Reply