Actually check auto-title
setting
This commit is contained in:
parent
66c3d26531
commit
e4bc57b3cc
1 changed files with 19 additions and 18 deletions
|
@ -51,26 +51,27 @@ class Module(ModuleManager.BaseModule):
|
||||||
:command: title
|
:command: title
|
||||||
:pattern-url: 1
|
:pattern-url: 1
|
||||||
"""
|
"""
|
||||||
url = event["match"].group(0)
|
if event["target"].get_setting("auto-title", False):
|
||||||
title = self._get_title(event["target"], event["match"].group(0))
|
url = event["match"].group(0)
|
||||||
|
title = self._get_title(event["target"], event["match"].group(0))
|
||||||
|
|
||||||
if title:
|
if title:
|
||||||
message = title
|
message = title
|
||||||
if event["target"].get_setting("auto-title-first", False):
|
if event["target"].get_setting("auto-title-first", False):
|
||||||
setting = "url-last-%s" % self._url_hash(url)
|
setting = "url-last-%s" % self._url_hash(url)
|
||||||
first_details = event["target"].get_setting(setting, None)
|
first_details = event["target"].get_setting(setting, None)
|
||||||
|
|
||||||
if first_details:
|
if first_details:
|
||||||
first_nickname, first_timestamp, _ = first_details
|
first_nickname, first_timestamp, _ = first_details
|
||||||
timestamp_parsed = utils.iso8601_parse(first_timestamp)
|
timestamp_parsed = utils.iso8601_parse(first_timestamp)
|
||||||
timestamp_human = utils.datetime_human(timestamp_parsed)
|
timestamp_human = utils.datetime_human(timestamp_parsed)
|
||||||
message = "%s (first posted by %s at %s)" % (title,
|
message = "%s (first posted by %s at %s)" % (title,
|
||||||
first_nickname, timestamp_human)
|
first_nickname, timestamp_human)
|
||||||
else:
|
else:
|
||||||
event["target"].set_setting(setting,
|
event["target"].set_setting(setting,
|
||||||
[event["user"].nickname, utils.iso8601_format_now(),
|
[event["user"].nickname, utils.iso8601_format_now(),
|
||||||
url])
|
url])
|
||||||
event["stdout"].write(message)
|
event["stdout"].write(message)
|
||||||
|
|
||||||
@utils.hook("received.command.t", alias_of="title")
|
@utils.hook("received.command.t", alias_of="title")
|
||||||
@utils.hook("received.command.title", usage="[URL]")
|
@utils.hook("received.command.title", usage="[URL]")
|
||||||
|
|
Loading…
Reference in a new issue