From 3ac3111a8e4c1c0beb5b3139da9083ddea9298d7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 18 Oct 2012 07:30:21 +1300 Subject: [PATCH] Fixed rss.py up a bit with a 'cant read feed' message and error handling for the URL shortener --- plugins/rss.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/rss.py b/plugins/rss.py index 0b3ab05..e0fc734 100644 --- a/plugins/rss.py +++ b/plugins/rss.py @@ -1,4 +1,4 @@ -from util import hook, web, text +from util import hook, http, web, text @hook.command("feed") @@ -21,9 +21,16 @@ def rss(inp, say=None): query = "SELECT title, link FROM rss WHERE url=@feed LIMIT @limit" result = web.query(query, {"feed": feed, "limit": limit}) + + if not result.rows: + return "Could not find/read RSS feed." + for row in result.rows: title = text.truncate_str(row["title"], 100) - link = web.isgd(row["link"]) + try: + link = web.isgd(row["link"]) + except (web.ShortenError, http.HTTPError, http.URLError): + link = row["link"] say(u"{} - {}".format(title, link))