From 930794c4143fe30c9c8b039aa015e22e7436429f Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 31 Oct 2019 10:26:00 +0000 Subject: [PATCH] don't assume we're in a channel when we're not (title.py) --- modules/title.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/title.py b/modules/title.py index 9179d279..66d5d44a 100644 --- a/modules/title.py +++ b/modules/title.py @@ -56,17 +56,20 @@ class Module(ModuleManager.BaseModule): except Exception as e: self.log.error("failed to get URL title: %s", [url], exc_info=True) return -1, None + if page.data.title: title = page.data.title.text.replace("\n", " ").replace( "\r", "").replace(" ", " ").strip() - if (channel.get_setting("auto-title-difference", True) and - not self._different(url, title)): - return -2, title - if channel.get_setting("title-shorten", False): - short_url = self.exports.get_one("shorturl")(server, url, - context=channel) - return page.code, "%s - %s" % (title, short_url) + if channel: + if (channel.get_setting("auto-title-difference", True) and + not self._different(url, title)): + return -2, title + + if channel.get_setting("title-shorten", False): + short_url = self.exports.get_one("shorturl")(server, url, + context=channel) + return page.code, "%s - %s" % (title, short_url) return page.code, title else: return -1, None @@ -119,7 +122,10 @@ class Module(ModuleManager.BaseModule): if not url: raise utils.EventError("No URL provided/found.") - code, title = self._get_title(event["server"], event["target"], url) + channel = None + if event["is_channel"]: + channel = event["target"] + code, title = self._get_title(event["server"], channel, url) if title: event["stdout"].write(title)