don't assume we're in a channel when we're not (title.py)

This commit is contained in:
jesopo 2019-10-31 10:26:00 +00:00
parent 9958c9169d
commit 930794c414

View file

@ -56,9 +56,12 @@ class Module(ModuleManager.BaseModule):
except Exception as e: except Exception as e:
self.log.error("failed to get URL title: %s", [url], exc_info=True) self.log.error("failed to get URL title: %s", [url], exc_info=True)
return -1, None return -1, None
if page.data.title: if page.data.title:
title = page.data.title.text.replace("\n", " ").replace( title = page.data.title.text.replace("\n", " ").replace(
"\r", "").replace(" ", " ").strip() "\r", "").replace(" ", " ").strip()
if channel:
if (channel.get_setting("auto-title-difference", True) and if (channel.get_setting("auto-title-difference", True) and
not self._different(url, title)): not self._different(url, title)):
return -2, title return -2, title
@ -119,7 +122,10 @@ class Module(ModuleManager.BaseModule):
if not url: if not url:
raise utils.EventError("No URL provided/found.") 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: if title:
event["stdout"].write(title) event["stdout"].write(title)