bot.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:hardmob_promo 作者: leandrotoledo 项目源码 文件源码
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!')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号