From 261ec9db60823e493af1afa4a1aa2f0befe99baa Mon Sep 17 00:00:00 2001 From: damned-me <62070968+damned-me@users.noreply.github.com> Date: Sat, 25 May 2024 01:53:47 +0200 Subject: [PATCH] fix: add support for relative links Changes to be committed: modified: octoprint_telegram/__init__.py --- octoprint_telegram/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index 24bca5f..c29100b 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -12,7 +12,7 @@ ) # dict of known notification messages from .emojiDict import telegramEmojiDict # dict of known emojis from babel.dates import format_date, format_datetime, format_time - +import urllib.parse bytes_reader_class = io.BytesIO @@ -2563,7 +2563,8 @@ def getUpdateMsgId(self, id): def take_image(self, snapshot_url=""): if snapshot_url == "": snapshot_url = self._settings.global_get(["webcam", "snapshot"]) - + if not urllib.parse.urlparse(snapshot_url).netloc: + snapshot_url = "http://localhost" + snapshot_url self._logger.debug("Snapshot URL: " + str(snapshot_url)) data = None if snapshot_url: @@ -2753,7 +2754,7 @@ def create_gif_new(self, chatID, sec=7, multicam_prof=0): if stream_url == 0: stream_url = self._settings.global_get(["webcam", "stream"]) - if "http" not in stream_url: + if not urllib.parse.urlparse(stream_url).netloc: stream_url = "http://localhost" + stream_url if sec == 0: