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']: