fix nerfnow

This commit is contained in:
bakatrouble 2019-12-08 15:45:03 +03:00
parent 506cb6b00f
commit ebf0d1ef92

View File

@ -3,6 +3,7 @@ from datetime import datetime
import feedparser import feedparser
from telebot import TeleBot from telebot import TeleBot
from telegram.constants import MAX_CAPTION_LENGTH
from feeds.models import FeedModuleConfig 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 = CAPTION_NEWLINE_RE.sub('\n', CAPTION_RE.search(data).group(1))
comment = comment.replace('<br />', '') comment = comment.replace('<br />', '')
caption = '<b>{}</b>\n\n{}\n\n{}'.format(e['title'], comment, e['feedburner_origlink']) caption = '<b>{}</b>\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'] yield e['feedburner_origlink']