mirror of https://github.com/caronc/apprise
slack:// now has timestamp=yes/no kwarg support
parent
c00c36f8f8
commit
fb9f11bcaa
|
@ -271,6 +271,12 @@ class NotifySlack(NotifyBase):
|
|||
"to": {
|
||||
"alias_of": "targets",
|
||||
},
|
||||
"timestamp": {
|
||||
"name": _("Include Timestamp"),
|
||||
"type": "bool",
|
||||
"default": False,
|
||||
"map_to": "include_timestamp",
|
||||
},
|
||||
"token": {
|
||||
"name": _("Token"),
|
||||
"alias_of": ("access_token", "token_a", "token_b", "token_c"),
|
||||
|
@ -327,6 +333,7 @@ class NotifySlack(NotifyBase):
|
|||
targets=None,
|
||||
include_image=None,
|
||||
include_footer=None,
|
||||
include_timestamp=None,
|
||||
use_blocks=None,
|
||||
**kwargs,
|
||||
):
|
||||
|
@ -423,6 +430,11 @@ class NotifySlack(NotifyBase):
|
|||
self.template_args["footer"]["default"] \
|
||||
if include_footer is None else include_footer
|
||||
|
||||
self.include_timestamp = \
|
||||
self.template_args["timestamp"]["default"] \
|
||||
if include_timestamp is None and self.include_footer \
|
||||
else include_timestamp
|
||||
|
||||
return
|
||||
|
||||
def send(
|
||||
|
@ -572,10 +584,9 @@ class NotifySlack(NotifyBase):
|
|||
"title": title,
|
||||
"text": body,
|
||||
"color": self.color(notify_type),
|
||||
# Time
|
||||
"ts": time(),
|
||||
}],
|
||||
}
|
||||
|
||||
# Acquire our to-be footer icon if configured to do so
|
||||
image_url = (
|
||||
None if not self.include_image else self.image_url(notify_type)
|
||||
|
@ -592,6 +603,9 @@ class NotifySlack(NotifyBase):
|
|||
# Include the footer only if specified to do so
|
||||
payload["attachments"][0]["footer"] = self.app_id
|
||||
|
||||
if self.include_timestamp:
|
||||
# Timestamp
|
||||
payload["attachments"][0]["ts"] = time()
|
||||
if (
|
||||
attach
|
||||
and self.attachment_support
|
||||
|
@ -1115,6 +1129,7 @@ class NotifySlack(NotifyBase):
|
|||
params = {
|
||||
"image": "yes" if self.include_image else "no",
|
||||
"footer": "yes" if self.include_footer else "no",
|
||||
"timestamp": "yes" if self.include_timestamp else "no",
|
||||
"blocks": "yes" if self.use_blocks else "no",
|
||||
}
|
||||
|
||||
|
@ -1233,6 +1248,11 @@ class NotifySlack(NotifyBase):
|
|||
parse_bool(results["qsd"].get(
|
||||
"image", NotifySlack.template_args["image"]["default"]))
|
||||
|
||||
results["include_timestamp"] = \
|
||||
parse_bool(results["qsd"].get(
|
||||
"timestamp",
|
||||
NotifySlack.template_args["timestamp"]["default"]))
|
||||
|
||||
# Get Payload structure (use blocks?)
|
||||
if "blocks" in results["qsd"] and len(results["qsd"]["blocks"]):
|
||||
results["use_blocks"] = parse_bool(results["qsd"]["blocks"])
|
||||
|
|
|
@ -170,7 +170,9 @@ apprise_url_tests = (
|
|||
),
|
||||
# Test using a bot-token (also test footer set to no flag)
|
||||
(
|
||||
"slack://username@xoxb-1234-1234-abc124/#nuxref?footer=no",
|
||||
(
|
||||
"slack://username@xoxb-1234-1234-abc124/#nuxref?footer=no"
|
||||
"×tamp=yes"),
|
||||
{
|
||||
"instance": NotifySlack,
|
||||
"requests_response_text": {
|
||||
|
@ -183,7 +185,15 @@ apprise_url_tests = (
|
|||
(
|
||||
(
|
||||
"slack://?token=T1JJ3T3L2/A1BRTD4JD/TIiajkdnlazkcOXrIdevi7FQ/"
|
||||
"&to=#chan&blocks=yes&footer=yes"
|
||||
"&to=#chan&blocks=yes&footer=yes×tamp=no"
|
||||
),
|
||||
{"instance": NotifySlack, "requests_response_text": "ok"},
|
||||
),
|
||||
# Test blocks mode with timestamp
|
||||
(
|
||||
(
|
||||
"slack://?token=T1JJ3T3L2/A1BRTD4JD/TIiajkdnlazkcOXrIdevi7FQ/"
|
||||
"&to=#chan&blocks=yes&footer=yes×tamp=yes"
|
||||
),
|
||||
{"instance": NotifySlack, "requests_response_text": "ok"},
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue