aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-10-31 10:26:00 +0000
committerGravatar jesopo2019-10-31 10:26:00 +0000
commit930794c4143fe30c9c8b039aa015e22e7436429f (patch)
tree1f2608b3e59231abe3c6b511b3da6fcb0214ce57
parentfix _line() related type hinting issues in IRCServer.py (diff)
signature
don't assume we're in a channel when we're not (title.py)
-rw-r--r--modules/title.py22
1 files 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)