From ebf0d1ef929bae26c1a21326fcf5ff313643365e Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Sun, 8 Dec 2019 15:45:03 +0300 Subject: [PATCH] fix nerfnow --- feeds/modules/nerfnow.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/feeds/modules/nerfnow.py b/feeds/modules/nerfnow.py index da53792..791a63f 100644 --- a/feeds/modules/nerfnow.py +++ b/feeds/modules/nerfnow.py @@ -3,6 +3,7 @@ from datetime import datetime import feedparser from telebot import TeleBot +from telegram.constants import MAX_CAPTION_LENGTH from feeds.models import FeedModuleConfig @@ -27,5 +28,9 @@ class NerfNowFeedModuleConfig(FeedModuleConfig): comment = CAPTION_NEWLINE_RE.sub('\n', CAPTION_RE.search(data).group(1)) comment = comment.replace('
', '') caption = '{}\n\n{}\n\n{}'.format(e['title'], comment, e['feedburner_origlink']) - bot.send_photo(chat_id, url, caption, parse_mode='html') + if len(caption) <= MAX_CAPTION_LENGTH: + bot.send_photo(chat_id, url, caption, parse_mode='html') + else: + m = bot.send_photo(chat_id, url) + bot.send_message(caption, parse_mode='html', reply_to_message_id=m.message_id) yield e['feedburner_origlink']