From 76ec0d26b4281d5a897fc03ec53197ac4ca4119a Mon Sep 17 00:00:00 2001 From: nemunaire Date: Tue, 13 Oct 2015 07:49:53 +0200 Subject: [PATCH] Modules: avoid unhandled exception in all_post --- modules/framalink.py | 4 +--- modules/reddit.py | 4 +--- modules/youtube-title.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/framalink.py b/modules/framalink.py index a556563..8b17cd8 100644 --- a/modules/framalink.py +++ b/modules/framalink.py @@ -79,7 +79,7 @@ def parselisten(msg): @hook("all_post") def parseresponse(msg): global LAST_URLS - try: + if hasattr(msg, "text") and msg.text: urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?[^ :]+)", msg.text) for url in urls: o = urlparse(url, "http") @@ -92,8 +92,6 @@ def parseresponse(msg): if recv not in LAST_URLS: LAST_URLS[recv] = list() LAST_URLS[recv].append(url) - except: - pass return msg diff --git a/modules/reddit.py b/modules/reddit.py index 53791ff..4c376d3 100644 --- a/modules/reddit.py +++ b/modules/reddit.py @@ -79,14 +79,12 @@ def parselisten(msg): def parseresponse(msg): global LAST_SUBS - try: + if hasattr(msg, "text") and msg.text: urls = re.findall("www.reddit.com(/\w/\w+/?)", msg.text) for url in urls: for recv in msg.receivers: if recv not in LAST_SUBS: LAST_SUBS[recv] = list() LAST_SUBS[recv].append(url) - except: - pass return msg diff --git a/modules/youtube-title.py b/modules/youtube-title.py index 93240b0..d4061b1 100644 --- a/modules/youtube-title.py +++ b/modules/youtube-title.py @@ -82,7 +82,7 @@ def parselisten(msg): @hook("all_post") def parseresponse(msg): global LAST_URLS - if hasattr(msg, "text"): + if hasattr(msg, "text") and msg.text: urls = re.findall("([a-zA-Z0-9+.-]+:(?://)?[^ :]+)", msg.text) for url in urls: o = urlparse(url)