send_announcement.py 文件源码

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

项目:pockebot 作者: Fillll 项目源码 文件源码
def main(config, file_with_msg):
    with open(file_with_msg) as f:
        text_to_send = f.read()
    bot = telepot.Bot(config['telegram_token'])
    mongo = pymongo.MongoClient(host=config['mongo']['host'])
    people = mongo[config['mongo']['db']]['people']
    already_sent = mongo[config['mongo']['db']]['people_sent']
    cursor = people.find({})
    count = 0
    for record in cursor:
        print('>> {}'.format(count))
        print(record)
        if already_sent.find_one({'id': record['id']}) is None:
            already_sent.insert_one({'id': record['id']})
            send(bot, record['id'], text_to_send)
        count += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号