From a69008e1792083408a9e45c3490cb323f66afb77 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 30 Mar 2018 09:23:38 -0700 Subject: [PATCH] Send Telegram notification separately if caption is longer than 200 characters (Closes Tautulli/Tautulli-Issues#20) --- plexpy/notifiers.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 9e0e44b7..64d57d2e 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -3307,10 +3307,17 @@ class TELEGRAM(Notifier): if poster_content: poster_filename = 'poster_{}.jpg'.format(pretty_metadata.parameters['rating_key']) files = {'photo': (poster_filename, poster_content, 'image/jpeg')} - data['caption'] = text - return self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), - data=data, files=files) + if len(text) > 200: + data['disable_notification'] = True + else: + data['caption'] = text + + r = self.make_request('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), + data=data, files=files) + + if not data.pop('disable_notification', None): + return r data['text'] = text