From e4bc57b3cc56a8965ed073a79baa30286d48d47f Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 19 May 2019 10:44:48 +0100 Subject: [PATCH] Actually check `auto-title` setting --- modules/title.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/title.py b/modules/title.py index 79a9e8ab..17be649b 100644 --- a/modules/title.py +++ b/modules/title.py @@ -51,26 +51,27 @@ class Module(ModuleManager.BaseModule): :command: title :pattern-url: 1 """ - url = event["match"].group(0) - title = self._get_title(event["target"], event["match"].group(0)) + if event["target"].get_setting("auto-title", False): + url = event["match"].group(0) + title = self._get_title(event["target"], event["match"].group(0)) - if title: - message = title - if event["target"].get_setting("auto-title-first", False): - setting = "url-last-%s" % self._url_hash(url) - first_details = event["target"].get_setting(setting, None) + if title: + message = title + if event["target"].get_setting("auto-title-first", False): + setting = "url-last-%s" % self._url_hash(url) + first_details = event["target"].get_setting(setting, None) - if first_details: - first_nickname, first_timestamp, _ = first_details - timestamp_parsed = utils.iso8601_parse(first_timestamp) - timestamp_human = utils.datetime_human(timestamp_parsed) - message = "%s (first posted by %s at %s)" % (title, - first_nickname, timestamp_human) - else: - event["target"].set_setting(setting, - [event["user"].nickname, utils.iso8601_format_now(), - url]) - event["stdout"].write(message) + if first_details: + first_nickname, first_timestamp, _ = first_details + timestamp_parsed = utils.iso8601_parse(first_timestamp) + timestamp_human = utils.datetime_human(timestamp_parsed) + message = "%s (first posted by %s at %s)" % (title, + first_nickname, timestamp_human) + else: + event["target"].set_setting(setting, + [event["user"].nickname, utils.iso8601_format_now(), + url]) + event["stdout"].write(message) @utils.hook("received.command.t", alias_of="title") @utils.hook("received.command.title", usage="[URL]")