expiration_clock.py 文件源码

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

项目:apex-sigma-core 作者: lu-ci 项目源码 文件源码
def cycler(ev):
    poll_coll = ev.db[ev.db.db_cfg.database].ShadowPolls
    while True:
        now = arrow.utcnow().timestamp
        poll_files = await poll_coll.find({'settings.expires': {'$lt': now}, 'settings.active': True}).to_list(None)
        for poll_file in poll_files:
            poll_id = poll_file['id']
            poll_file['settings'].update({'active': False})
            await ev.db[ev.db.db_cfg.database].ShadowPolls.update_one({'id': poll_id}, {'$set': poll_file})
            author = discord.utils.find(lambda x: x.id == poll_file['origin']['author'], ev.bot.get_all_members())
            if author:
                response = discord.Embed(color=0xff3333, title=f'? Your poll {poll_file["id"]} has expired.')
                try:
                    await author.send(embed=response)
                except discord.Forbidden:
                    pass
        await asyncio.sleep(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号