status_rotation.py 文件源码

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

项目:apex-sigma-core 作者: lu-ci 项目源码 文件源码
def status_clockwork(ev):
    while True:
        if ev.bot.cfg.pref.status_rotation:
            if not status_cache:
                status_files = await ev.db[ev.db.db_cfg.database].StatusFiles.find().to_list(None)
                for status_file in status_files:
                    status_text = status_file.get('Text')
                    status_cache.append(status_text)
            if status_cache:
                status = status_cache.pop(secrets.randbelow(len(status_cache)))
                mode_roll = secrets.randbelow(10)
                if mode_roll == 0:
                    hgen = hashlib.new('md5')
                    hgen.update(status.encode('utf-8'))
                    digest = hgen.hexdigest()
                    max_end = abs(len(digest) - 10)
                    cut = secrets.randbelow(max_end)
                    cut_text = digest[cut:(cut + 10)]
                    status = random_capitalize(cut_text)
                game = discord.Game(name=status)
                try:
                    await ev.bot.change_presence(game=game)
                except discord.ConnectionClosed:
                    pass
        await asyncio.sleep(60)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号