egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help with rssnews
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Mon Sep 05, 2005 9:17 pm    Post subject: help with rssnews Reply with quote

My bot loads the script, I have it configured correctly but then it asks for trigger !rss and a number or a *. I want the script to scroll the headlines without having to use the trigger. When I use the trigger !rss * or !rss 17, it says "No news for channel."

Please help, demond! Crying or Very sad
Back to top
View user's profile Send private message
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Mon Sep 05, 2005 10:40 pm    Post subject: Reply with quote

Tried both versions, still the same result. PLEASE HELP!
Back to top
View user's profile Send private message
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Mon Sep 05, 2005 11:16 pm    Post subject: Reply with quote

Here's how it sits in my config:

Code:
#######################################################################
#                                                                     #
# 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, one feed per channel; you only need to set  #
#               the feeds array, see below                            #
#                                                                     #
#        Usage: !rss <news#|*> (read news# or * for headlines list)   #
#                                                                     #
#######################################################################

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

namespace eval rssnews {

# set your feed(s) sources here: channel, poll frequency in mins, feed URL
#
#set feeds(#katrina-news) {3 http://www.chron.com/rss/special/05/katrina/index.rss}
#set feeds(#katrina-news) {3 http://rss.nola.com/nola_localbreakingnews/index.rss}

variable version "rssnews-1.0"

variable timeout 20 ;# seconds

bind pub  - !rss [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]} {
   if {$min} {set min [string trimleft $min 0]}
   foreach {chan feed} [array get feeds] {
      if {$min && $min % [lindex $feed 0] == 0} {
         fetch [lindex $feed 1] $chan
      }
   }}
}

proc fetch {url chan} {
   variable timeout
   variable version; variable token
   set to [expr {$timeout * 1000}]
   set cmd [namespace current]::callback
   ::http::config -useragent "$version by demond"
   if {[catch {set t [::http::geturl $url -command $cmd -timeout $to]} err]} {
      putlog "$version: ERROR($chan): $err"
   } {
      set token($t) $chan
   }
}

proc callback {t} {
   variable version; variable token
   set chan $token($t)
   switch -exact [::http::status $t] {
   "timeout" {
      putlog "$version: ERROR($chan): timeout"
   }
   "error" {
      putlog "$version: ERROR($chan): [::http::error $t]"
   }
   "ok" {
      if {[::http::ncode $t] != 200} {
         putlog "$version: ERROR($chan): [::http::code $t]"
      } {
         process [::http::data $t] $chan
      }
   }
   default {
      putlog "$version: ERROR($chan): got EOF from socket"
   }}
   ::http::cleanup $t
}

proc process {data chan} {
   variable news; variable hash
   set idx 1; set news($chan) {}
   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)<description>(.*?)</description>} $item -> descr
      strip title descr
      if {[info exists hash($chan)]} {
      if {[lsearch -exact $hash($chan) [md5 $title]] == -1} {
         if {[botonchan $chan]} {
            puthelp "privmsg $chan :($idx) $title"
         }
      }}
      lappend news($chan) [list $title $link $descr]
      lappend hashes [md5 $title]
      incr idx
   }
   set hash($chan) $hashes
}

proc strip {args} {
   variable html
   foreach a $args {
      upvar $a x
      set amp {&amp; &}
      set x [string map $amp $x]
      set x [string map $html $x]
      regsub -all {<[^<]+?>} $x {} x
   }
}

proc news {nick uhost hand chan text} {
   variable news; variable feeds
   set num [lindex [split $text] 0]
   if {$num == ""} {
      puthelp "notice $nick :Usage: $::lastbind <news#|*>"
      return
   }
   if {$num != "*" && ![string is integer $num]} {
      puthelp "notice $nick :argument must be number or *"
      return
   }
   if {![info exists news($chan)]} {
      puthelp "notice $nick :no news for this channel"
      return
   }
   if {$num == "*"} {
      set idx 1
      puthelp "notice $nick :News source: [lindex $feeds($chan) 1]"
      foreach item $news($chan) {
         puthelp "notice $nick :($idx) [lindex $item 0]"
         incr idx
      }
      return 1
   } {
   if {$num < 1 || $num > [llength $news($chan)]} {
      puthelp "notice $nick :no such news index, try $::lastbind *"
   } {
      set idx [expr {$num-1}]
      puthelp "notice $nick :......title($num): [lindex [lindex $news($chan) $idx] 0]"
      puthelp "notice $nick :description($num): [lindex [lindex $news($chan) $idx] 2]"
      puthelp "notice $nick :.......link($num): [lindex [lindex $news($chan) $idx] 1]"
      return 1
   }}
}

variable html {
   &quot;     \x22  &apos;     \x27  &amp;      \x26  &lt;       \x3C
   &gt;       \x3E  &nbsp;     \x20  &iexcl;    \xA1  &curren;   \xA4
   &cent;     \xA2  &pound;    \xA3  &yen;      \xA5  &brvbar;   \xA6
   &sect;     \xA7  &uml;      \xA8  &copy;     \xA9  &ordf;     \xAA
   &laquo;    \xAB  &not;      \xAC  &shy;      \xAD  &reg;      \xAE
   &macr;     \xAF  &deg;      \xB0  &plusmn;   \xB1  &sup2;     \xB2
   &sup3;     \xB3  &acute;    \xB4  &micro;    \xB5  &para;     \xB6
   &middot;   \xB7  &cedil;    \xB8  &sup1;     \xB9  &ordm;     \xBA
   &raquo;    \xBB  &frac14;   \xBC  &frac12;   \xBD  &frac34;   \xBE
   &iquest;   \xBF  &times;    \xD7  &divide;   \xF7  &Agrave;   \xC0
   &Aacute;   \xC1  &Acirc;    \xC2  &Atilde;   \xC3  &Auml;     \xC4
   &Aring;    \xC5  &AElig;    \xC6  &Ccedil;   \xC7  &Egrave;   \xC8
   &Eacute;   \xC9  &Ecirc;    \xCA  &Euml;     \xCB  &Igrave;   \xCC
   &Iacute;   \xCD  &Icirc;    \xCE  &Iuml;     \xCF  &ETH;      \xD0
   &Ntilde;   \xD1  &Ograve;   \xD2  &Oacute;   \xD3  &Ocirc;    \xD4
   &Otilde;   \xD5  &Ouml;     \xD6  &Oslash;   \xD8  &Ugrave;   \xD9
   &Uacute;   \xDA  &Ucirc;    \xDB  &Uuml;     \xDC  &Yacute;   \xDD
   &THORN;    \xDE  &szlig;    \xDF  &agrave;   \xE0  &aacute;   \xE1
   &acirc;    \xE2  &atilde;   \xE3  &auml;     \xE4  &aring;    \xE5
   &aelig;    \xE6  &ccedil;   \xE7  &egrave;   \xE8  &eacute;   \xE9
   &ecirc;    \xEA  &euml;     \xEB  &igrave;   \xEC  &iacute;   \xED
   &icirc;    \xEE  &iuml;     \xEF  &eth;      \xF0  &ntilde;   \xF1
   &ograve;   \xF2  &oacute;   \xF3  &ocirc;    \xF4  &otilde;   \xF5
   &ouml;     \xF6  &oslash;   \xF8  &ugrave;   \xF9  &uacute;   \xFA
   &ucirc;    \xFB  &uuml;     \xFC  &yacute;   \xFD  &thorn;    \xFE
   &yuml;     \xFF  '      \x27  <p> \x20 <br> \x20 \n \x20
}

}

Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 12:00 am    Post subject: Reply with quote

this version is outdated, latest is 1.2, get it from the script archive or here

if by "scroll" you mean automatically announcing new headlines as they come, you got the right script, it does exactly that - but you need to configure your feed, see the header - remove those #'s in front of feeds() array
Back to top
View user's profile Send private message Visit poster's website
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 1:18 pm    Post subject: Reply with quote

Yes, that is what I mean. So I switched to the new script and took out the #'s like you said and it still says the same exact thing. It looks like this now:

Code:
#######################################################################
#                                                                     #
# 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, one feed per channel; you only need to set  #
#               the feeds array, see below                            #
#                                                                     #
#        Usage: !rss <news#|*> (read news# or * for headlines list)   #
#                                                                     #
#######################################################################

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

namespace eval rssnews {

# set your feed(s) sources here: channel, poll frequency in mins, feed URL

set feeds(#chan1) {3 http://www.chron.com/rss/special/05/katrina/index.rss}
set feeds(#chan2) {3 http://rss.nola.com/nola_localbreakingnews/index.rss}

# maximum number of announced new headlines
#
variable maxnew 5

# feed fetch timeout in seconds
#
variable timeout 20

# nothing to edit below

variable version "rssnews-1.2"

bind pub  - !rss [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]} {
   if {$min} {set min [string trimleft $min 0]}
   foreach {chan feed} [array get feeds] {
      if {$min && $min % [lindex $feed 0] == 0} {
         fetch [lindex $feed 1] $chan
      }
   }}
}

proc fetch {url chan} {
   variable timeout
   variable version; variable token
   set to [expr {$timeout * 1000}]
   set cmd [namespace current]::callback
   ::http::config -useragent "$version by demond"
   if {[catch {set t [::http::geturl $url -command $cmd -timeout $to]} err]} {
      putlog "$version: ERROR($chan): $err"
   } {
      set token($t) $chan
   }
}

proc callback {t} {
   variable version; variable token
   set chan $token($t)
   switch -exact [::http::status $t] {
   "timeout" {
      putlog "$version: ERROR($chan): timeout"
   }
   "error" {
      putlog "$version: ERROR($chan): [::http::error $t]"
   }
   "ok" {
      if {[::http::ncode $t] != 200} {
         putlog "$version: ERROR($chan): [::http::code $t]"
      } {
         process [::http::data $t] $chan
      }
   }
   default {
      putlog "$version: ERROR($chan): got EOF from socket"
   }}
   ::http::cleanup $t
}

proc process {data chan} {
   variable news; variable hash
   variable maxnew; variable source
   set idx 1; set count 0
   set news($chan) {}; set source($chan) ""
   if {[regexp {(?i)<title>(.*?)</title>} $data -> foo]} {
      append source($chan) $foo
   }
   if {[regexp {(?i)<description>(.*?)</description>} $data -> foo]} {
      append source($chan) " | $foo"
   }
   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)<description>(.*?)</description>} $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($chan)]} {
      if {[lsearch -exact $hash($chan) [md5 $title]] == -1 && [botonchan $chan]} {
         if {$count < $maxnew} {
            puthelp "privmsg $chan :($idx) $title"
            incr count
         } {
            lappend indices $idx
         }
      }}
      lappend news($chan) [list $title $link $descr]
      lappend hashes [md5 $title]
      incr idx
   }
   if {[info exists indices] && [botonchan $chan]} {
      set count [llength $indices]
      set indices "(indices: [join $indices {, }])"
      puthelp "privmsg $chan :...and $count more $indices"
   }
   set hash($chan) $hashes
}

proc strip {args} {
   variable html
   foreach a $args {
      upvar $a x
      set amp {&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 news {nick uhost hand chan text} {
   variable source
   variable news; variable feeds
   set num [lindex [split $text] 0]
   if {$num == ""} {
      puthelp "notice $nick :Usage: $::lastbind <news#|*>"
      return
   }
   if {$num != "*" && ![string is integer $num]} {
      puthelp "notice $nick :argument must be number or *"
      return
   }
   if {![info exists news($chan)]} {
      puthelp "notice $nick :no news for this channel"
      return
   }
   if {$num == "*"} {
      set idx 1
      if {$source($chan) != ""} {
         set title $source($chan)
      } {
         set title [lindex $feeds($chan) 1]
      }
      puthelp "notice $nick :News source: \002$title\002"
      foreach item $news($chan) {
         puthelp "notice $nick :($idx) [lindex $item 0]"
         incr idx
      }
      return 1
   } {
   if {$num < 1 || $num > [llength $news($chan)]} {
      puthelp "notice $nick :no such news index, try $::lastbind *"
   } {
      set idx [expr {$num-1}]
      puthelp "notice $nick :......title($num): [lindex [lindex $news($chan) $idx] 0]"
      puthelp "notice $nick :description($num): [lindex [lindex $news($chan) $idx] 2]"
      puthelp "notice $nick :.......link($num): [lindex [lindex $news($chan) $idx] 1]"
      return 1
   }}
}

variable html {
   &quot;     \x22  &apos;     \x27  &amp;      \x26  &lt;       \x3C
   &gt;       \x3E  &nbsp;     \x20  &iexcl;    \xA1  &curren;   \xA4
   &cent;     \xA2  &pound;    \xA3  &yen;      \xA5  &brvbar;   \xA6
   &sect;     \xA7  &uml;      \xA8  &copy;     \xA9  &ordf;     \xAA
   &laquo;    \xAB  &not;      \xAC  &shy;      \xAD  &reg;      \xAE
   &macr;     \xAF  &deg;      \xB0  &plusmn;   \xB1  &sup2;     \xB2
   &sup3;     \xB3  &acute;    \xB4  &micro;    \xB5  &para;     \xB6
   &middot;   \xB7  &cedil;    \xB8  &sup1;     \xB9  &ordm;     \xBA
   &raquo;    \xBB  &frac14;   \xBC  &frac12;   \xBD  &frac34;   \xBE
   &iquest;   \xBF  &times;    \xD7  &divide;   \xF7  &Agrave;   \xC0
   &Aacute;   \xC1  &Acirc;    \xC2  &Atilde;   \xC3  &Auml;     \xC4
   &Aring;    \xC5  &AElig;    \xC6  &Ccedil;   \xC7  &Egrave;   \xC8
   &Eacute;   \xC9  &Ecirc;    \xCA  &Euml;     \xCB  &Igrave;   \xCC
   &Iacute;   \xCD  &Icirc;    \xCE  &Iuml;     \xCF  &ETH;      \xD0
   &Ntilde;   \xD1  &Ograve;   \xD2  &Oacute;   \xD3  &Ocirc;    \xD4
   &Otilde;   \xD5  &Ouml;     \xD6  &Oslash;   \xD8  &Ugrave;   \xD9
   &Uacute;   \xDA  &Ucirc;    \xDB  &Uuml;     \xDC  &Yacute;   \xDD
   &THORN;    \xDE  &szlig;    \xDF  &agrave;   \xE0  &aacute;   \xE1
   &acirc;    \xE2  &atilde;   \xE3  &auml;     \xE4  &aring;    \xE5
   &aelig;    \xE6  &ccedil;   \xE7  &egrave;   \xE8  &eacute;   \xE9
   &ecirc;    \xEA  &euml;     \xEB  &igrave;   \xEC  &iacute;   \xED
   &icirc;    \xEE  &iuml;     \xEF  &eth;      \xF0  &ntilde;   \xF1
   &ograve;   \xF2  &oacute;   \xF3  &ocirc;    \xF4  &otilde;   \xF5
   &ouml;     \xF6  &oslash;   \xF8  &ugrave;   \xF9  &uacute;   \xFA
   &ucirc;    \xFB  &uuml;     \xFC  &yacute;   \xFD  &thorn;    \xFE
   &yuml;     \xFF
}

}
Back to top
View user's profile Send private message
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 1:20 pm    Post subject: Reply with quote

I also switched #chan1 and #chan2 to the channel I wanted it to appear in. Still nothing.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 2:31 pm    Post subject: Reply with quote

it works fine for me with your feeds

check the bot's log for errors
Back to top
View user's profile Send private message Visit poster's website
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 2:34 pm    Post subject: Reply with quote

The only error I get upon startup is:
USERFILE ALREADY EXISTS <drop the -m>

I don't think this has anything to do with the script. Although I could be wrong. In the bot's log, it says the script is loading fine. I have no idea what the problem is.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 2:35 pm    Post subject: Reply with quote

look for errors from the script, like that:
Code:

<(Bot> [14:35] rssnews-1.2: ERROR(#trivia): timeout
Back to top
View user's profile Send private message Visit poster's website
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 2:42 pm    Post subject: Reply with quote

Upon startup, it looks like this:

Code:
[11:33] rssnews 1.2 by demond loaded
[11:33] Userfile loaded, unpacking...
USERFILE ALREADY EXISTS <drop the -m>
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 2:46 pm    Post subject: Reply with quote

not upon startup, during the course of use (you do know what logfile is, don't you?)
Back to top
View user's profile Send private message Visit poster's website
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 2:54 pm    Post subject: Reply with quote

Since I really am a newbie at this, I think I have an idea. Which file in particular, though?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 2:56 pm    Post subject: Reply with quote

the one that you have specified in your config file
Back to top
View user's profile Send private message Visit poster's website
good
Voice


Joined: 05 Sep 2005
Posts: 27

PostPosted: Tue Sep 06, 2005 3:00 pm    Post subject: Reply with quote

I looked through all of the logfiles. I do not see any errors like that.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 3:07 pm    Post subject: Reply with quote

well then I can't help you further; it's not a problem with the script anyway

try with other RSS feeds
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber