From 92d5d7cc8a66d61d2334c0f4291b09bf1f53a5ec Mon Sep 17 00:00:00 2001 From: HerbertGao Date: Sun, 17 Aug 2025 01:00:57 +0800 Subject: [PATCH] feat: add icon field support for bark plugin (#1393) --- apprise/plugins/bark.py | 22 +++++++++++++++++++++- tests/test_plugin_bark.py | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apprise/plugins/bark.py b/apprise/plugins/bark.py index a03ded7b..ea7dc554 100644 --- a/apprise/plugins/bark.py +++ b/apprise/plugins/bark.py @@ -209,6 +209,10 @@ class NotifyBark(NotifyBase): "default": True, "map_to": "include_image", }, + "icon": { + "name": _("Icon URL"), + "type": "string", + }, }, ) @@ -223,6 +227,7 @@ class NotifyBark(NotifyBase): click=None, badge=None, volume=None, + icon=None, **kwargs, ): """Initialize Notify Bark Object.""" @@ -301,6 +306,9 @@ class NotifyBark(NotifyBase): volume, ) + # Icon URL + self.icon = icon if isinstance(icon, str) else None + # Level self.level = ( None @@ -353,7 +361,10 @@ class NotifyBark(NotifyBase): None if not self.include_image else self.image_url(notify_type) ) - if image_url: + # Use custom icon if provided, otherwise use default image + if self.icon: + payload["icon"] = self.icon + elif image_url: payload["icon"] = image_url if self.sound: @@ -488,6 +499,9 @@ class NotifyBark(NotifyBase): if self.group: params["group"] = self.group + if self.icon: + params["icon"] = self.icon + # Extend our parameters params.update(self.url_parameters(privacy=privacy, *args, **kwargs)) @@ -588,4 +602,10 @@ class NotifyBark(NotifyBase): results["qsd"].get("image", True) ) + # Icon URL + if "icon" in results["qsd"] and results["qsd"]["icon"]: + results["icon"] = NotifyBark.unquote( + results["qsd"]["icon"].strip() + ) + return results diff --git a/tests/test_plugin_bark.py b/tests/test_plugin_bark.py index dba23e58..8895971a 100644 --- a/tests/test_plugin_bark.py +++ b/tests/test_plugin_bark.py @@ -240,6 +240,20 @@ apprise_url_tests = ( "test_requests_exceptions": True, }, ), + ( + "bark://192.168.0.6:8081/device_key/?icon=https://example.com/icon.png", + { + # set custom icon + "instance": NotifyBark, + }, + ), + ( + "bark://192.168.0.6:8081/device_key/?icon=https://example.com/icon.png&image=no", + { + # set custom icon and disable default image + "instance": NotifyBark, + }, + ), )