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