def main():
bot = Bot(environ.get('TOKEN'))
chat_id = environ.get('CHAT_ID')
post.updatedb()
new_posts = post.get_posts(sent_only=False)
if new_posts:
for p in new_posts:
try:
bot.sendMessage(chat_id=chat_id, text=p.text(), parse_mode='HTML')
post.mark_as_sent(p.uid)
except BadRequest:
logging.info('Bad post formatting: %d' % p.uid)
logger.info('%d new post(s) have been sent!' % len(new_posts))
else:
logger.info('No new posts at this time!')
评论列表
文章目录