Clean up Telegram send poster

This commit is contained in:
JonnyWong16 2020-09-26 19:03:24 -07:00
parent a8e0502b41
commit 2a4b48d0fa
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

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