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
评论列表
文章目录