diff options
-rwxr-xr-x | ircbot/contoller.py | 20 | ||||
-rw-r--r-- | ircbot/new_feeds | 33 | ||||
-rwxr-xr-x | ircbot/rssbot.py | 28 |
3 files changed, 61 insertions, 20 deletions
diff --git a/ircbot/contoller.py b/ircbot/contoller.py index 71d04536..9466343d 100755 --- a/ircbot/contoller.py +++ b/ircbot/contoller.py @@ -33,7 +33,11 @@ class NewsBot(irc.bot.SingleServerIRCBot): args_array = event.arguments[0].split() if args_array[0][:-1]==self.name: answer = self.read_message(args_array[1:]) - self.connection.privmsg(self.chan, answer) + self.send(answer) + + def send(self, string): + for line in string.split('\n'): + self.connection.privmsg(self.chan, line) def on_pubmsg(self, connection, event): @@ -63,7 +67,19 @@ class NewsBot(irc.bot.SingleServerIRCBot): return "bots saved to " + feedfile elif args[0] == 'caps': - return "add del save caps" + return "add del save caps list" + + elif args[0] == 'list': + output_buffer = '' + for bot in bots: + output_buffer += bot + ' url: ' + bots[bot].url + '\n' + return output_buffer + + elif args[0] == 'info': + if args[1] in bots: + return 'title: ' + bots[args[1]].feed.feed.title + '\n' + 'size: ' + len(bots[args[1]].feed.entries) + else: + return 'bot not found' else: return "unknown command" diff --git a/ircbot/new_feeds b/ircbot/new_feeds index cc3bad6f..767b59f2 100644 --- a/ircbot/new_feeds +++ b/ircbot/new_feeds @@ -1,7 +1,32 @@ +fvwm|http://freecode.com/projects/fvwm/releases.atom +aje|http://www.aljazeera.com/Services/Rss/?PostingId=2007731105943979989 +rt|http://rt.com/rss/news/ +anon|http://anoninsiders.net/feed/ +linuxinsider|http://www.linuxinsider.com/perl/syndication/rssfull.pl +antirez|http://antirez.com/rss +lisp|http://planet.lisp.org/rss20.xml +reddit_prog|http://reddit.com/r/programming/ +rawstory|http://www.rawstory.com/rs/feed/ fefe|http://blog.fefe.de/rss.xml +xkcd|https://xkcd.com/rss.xml +slashdot|http://rss.slashdot.org/Slashdot/slashdot +spiegel_top|http://www.spiegel.de/schlagzeilen/tops/index.rss +weechat|http://dev.weechat.org/feed/atom +spiegel_eil|http://www.spiegel.de/schlagzeilen/eilmeldungen/index.rss +reddit_sci|http://www.reddit.com/r/science/.rss +reuters|http://feeds.reuters.com/Reuters/worldNews HN|http://news.ycombinator.com/rss -lisp|http://planet.lisp.org/rss20.xml -LtU|http://lambda-the-ultimate.org/rss.xml -antirez|http://antirez.com/rss +reddit_tech|http://www.reddit.com/r/technology/.rss coinspotting|http://coinspotting.com/rss -xkcd|https://xkcd.com/rss.xml +ccc|http://www.ccc.de/rss/updates.rdf +archlinux|http://www.archlinux.org/feeds/news/ +reddit_consp|http://reddit.com/r/conspiracy/.rss +scmp|http://www.scmp.com/rss/91/feed +LtU|http://lambda-the-ultimate.org/rss.xml +reddit_world|http://www.reddit.com/r/worldnews/.rss +sec-db|http://feeds.security-database.com/SecurityDatabaseToolsWatch +exploitdb|http://www.exploit-db.com/rss.xml +heise|http://heise.de.feedsportal.com/c/35207/f/653902/index.rss +wp_world|http://feeds.washingtonpost.com/rss/rss_blogpost +ars|http://feeds.arstechnica.com/arstechnica/index?format=xml +golem|http://www.golem.de/rss.php?feed=RSS1.0 diff --git a/ircbot/rssbot.py b/ircbot/rssbot.py index 5d2beedc..008f9fa0 100755 --- a/ircbot/rssbot.py +++ b/ircbot/rssbot.py @@ -9,7 +9,6 @@ class RssBot(irc.bot.SingleServerIRCBot): def __init__(self, rss, name, server='ire', port=6667, chan='#news', timeout=60): irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], name, name) self.url = rss - self.feed = feedparser.parse(self.url) self.name = name self.server = server self.port = port @@ -18,33 +17,34 @@ class RssBot(irc.bot.SingleServerIRCBot): self.oldnews = [] self.sendqueue = [] self.loop = True - for entry in self.feed.entries: - try: - self.sendqueue.append(entry.title + " " + entry.link + " com: " + entry.comments) - except AttributeError: - self.sendqueue.append(entry.title + " " + entry.link) - - self.oldnews.append(entry.link) def start(self): - self.upd_thread = _thread.start_new_thread(self.updateloop, ()) + self.upd_loop = _thread.start_new_thread(self.updateloop, ()) self.bot = _thread.start_new_thread(irc.bot.SingleServerIRCBot.start, (self,)) - def stop(self): self.loop = False self.disconnect() def updateloop(self): + self.feed = feedparser.parse(self.url) + for entry in self.feed.entries: + #try: + # self.sendqueue.append(entry.title + " " + entry.link + " com: " + entry.comments) + #except AttributeError: + self.sendqueue.append(entry.title + " " + entry.link) + + self.oldnews.append(entry.link) + while self.loop: sleep(self.to) self.feed = feedparser.parse(self.url) for entry in self.feed.entries: if not entry.link in self.oldnews: - try: - self.send(entry.title + " " + entry.link + " com: " + entry.comments) - except AttributeError: - self.send(entry.title + " " + entry.link) + #try: + # self.send(entry.title + " " + entry.link + " com: " + entry.comments) + #except AttributeError: + self.send(entry.title + " " + entry.link) self.oldnews.append(entry.link) def sendall(self): |