mirror of https://github.com/caronc/apprise
Added support for discord:// flags=<int> (#1409)
parent
dca2f7aad8
commit
548e99ac72
|
@ -183,6 +183,11 @@ class NotifyDiscord(NotifyBase):
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"default": True,
|
"default": True,
|
||||||
},
|
},
|
||||||
|
"flags": {
|
||||||
|
"name": _("Discord Flags"),
|
||||||
|
"type": "int",
|
||||||
|
"min": 0,
|
||||||
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"name": _("Include Image"),
|
"name": _("Include Image"),
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
@ -205,6 +210,7 @@ class NotifyDiscord(NotifyBase):
|
||||||
avatar_url=None,
|
avatar_url=None,
|
||||||
href=None,
|
href=None,
|
||||||
thread=None,
|
thread=None,
|
||||||
|
flags=None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""Initialize Discord Object."""
|
"""Initialize Discord Object."""
|
||||||
|
@ -258,6 +264,21 @@ class NotifyDiscord(NotifyBase):
|
||||||
# A URL to have the title link to
|
# A URL to have the title link to
|
||||||
self.href = href
|
self.href = href
|
||||||
|
|
||||||
|
# A URL to have the title link to
|
||||||
|
if flags:
|
||||||
|
try:
|
||||||
|
self.flags = int(flags)
|
||||||
|
if self.flags < NotifyDiscord.template_args["flags"]["min"]:
|
||||||
|
raise ValueError()
|
||||||
|
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
msg = "An invalid Discord flags setting " \
|
||||||
|
"({}) was specified.".format(flags)
|
||||||
|
self.logger.warning(msg)
|
||||||
|
raise TypeError(msg) from None
|
||||||
|
else:
|
||||||
|
self.flags = None
|
||||||
|
|
||||||
# For Tracking Purposes
|
# For Tracking Purposes
|
||||||
self.ratelimit_reset = datetime.now(timezone.utc).replace(tzinfo=None)
|
self.ratelimit_reset = datetime.now(timezone.utc).replace(tzinfo=None)
|
||||||
|
|
||||||
|
@ -284,6 +305,10 @@ class NotifyDiscord(NotifyBase):
|
||||||
"wait": self.tts is False,
|
"wait": self.tts is False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.flags:
|
||||||
|
# Set our flag if defined:
|
||||||
|
payload["flags"] = self.flags
|
||||||
|
|
||||||
# Acquire image_url
|
# Acquire image_url
|
||||||
image_url = self.image_url(notify_type)
|
image_url = self.image_url(notify_type)
|
||||||
|
|
||||||
|
@ -626,6 +651,9 @@ class NotifyDiscord(NotifyBase):
|
||||||
if self.avatar_url:
|
if self.avatar_url:
|
||||||
params["avatar_url"] = self.avatar_url
|
params["avatar_url"] = self.avatar_url
|
||||||
|
|
||||||
|
if self.flags:
|
||||||
|
params["flags"] = str(self.flags)
|
||||||
|
|
||||||
if self.href:
|
if self.href:
|
||||||
params["href"] = self.href
|
params["href"] = self.href
|
||||||
|
|
||||||
|
@ -718,6 +746,10 @@ class NotifyDiscord(NotifyBase):
|
||||||
# Alias to User
|
# Alias to User
|
||||||
results["user"] = NotifyDiscord.unquote(results["qsd"]["botname"])
|
results["user"] = NotifyDiscord.unquote(results["qsd"]["botname"])
|
||||||
|
|
||||||
|
if "flags" in results["qsd"]:
|
||||||
|
# Alias to User
|
||||||
|
results["flags"] = NotifyDiscord.unquote(results["qsd"]["flags"])
|
||||||
|
|
||||||
# Extract avatar url if it was specified
|
# Extract avatar url if it was specified
|
||||||
if "avatar_url" in results["qsd"]:
|
if "avatar_url" in results["qsd"]:
|
||||||
results["avatar_url"] = NotifyDiscord.unquote(
|
results["avatar_url"] = NotifyDiscord.unquote(
|
||||||
|
|
|
@ -165,6 +165,34 @@ apprise_url_tests = (
|
||||||
"requests_response_code": requests.codes.no_content,
|
"requests_response_code": requests.codes.no_content,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"discord://{}/{}?flags=1".format(
|
||||||
|
"i" * 24, "t" * 64
|
||||||
|
),
|
||||||
|
{
|
||||||
|
"instance": NotifyDiscord,
|
||||||
|
"requests_response_code": requests.codes.no_content,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"discord://{}/{}?flags=-1".format(
|
||||||
|
"i" * 24, "t" * 64
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# invalid flags specified (variation 1)
|
||||||
|
"instance": TypeError,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"discord://{}/{}?flags=invalid".format(
|
||||||
|
"i" * 24, "t" * 64
|
||||||
|
),
|
||||||
|
{
|
||||||
|
# invalid flags specified (variation 2)
|
||||||
|
"instance": TypeError,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
# different format support
|
# different format support
|
||||||
(
|
(
|
||||||
"discord://{}/{}?format=markdown".format("i" * 24, "t" * 64),
|
"discord://{}/{}?format=markdown".format("i" * 24, "t" * 64),
|
||||||
|
|
Loading…
Reference in New Issue