From 2a4b48d0fa9eaced7e5d4e4939023f0f63fe0811 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Sat, 26 Sep 2020 19:03:24 -0700 Subject: [PATCH] Clean up Telegram send poster --- plexpy/notifiers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index e0f68089..2f25ff82 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -3406,21 +3406,21 @@ class TELEGRAM(Notifier): poster_filename = 'poster_{}.png'.format(pretty_metadata.parameters['rating_key']) files = {'photo': (poster_filename, poster_content, 'image/png')} - max_caption = len(text) - - if max_caption > 1024: + if len(text) > 1024: data['disable_notification'] = True - self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), - data=data, files=files) - data.pop('disable_notification') #This prevents from alerting with 2 sounds Telegram when the Silent Message is OFF: one alert for the photo and the second one for the text else: data['caption'] = text.encode('utf-8') if self.config['silent_notification']: data['disable_notification'] = True - self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), - data=data, files=files) + + self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), + data=data, files=files) + + if 'caption' in data: return + data.pop('disable_notification', None) + data['text'] = (text[:4093] + (text[4093:] and '...')).encode('utf-8') if self.config['disable_web_preview']: