main.py 文件源码

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

项目:ICO-Moderator 作者: Plenglin 项目源码 文件源码
def run_bot():

    is_running = True
    while is_running:

        try:
            main_logger.info('Starting bot...')
            client.loop.run_until_complete(client.start(token))  # Start the bot

        except KeyboardInterrupt:  # It has been stopped?

            client.loop.run_until_complete(client.logout())
            pending = asyncio.Task.all_tasks()
            gathered = asyncio.gather(*pending)
            try:
                gathered.cancel()
                client.loop.run_until_complete(gathered)
                gathered.exception()
            finally:
                is_running = False

        except discord.ConnectionClosed as e:  # We lost connection?

            main_logger.exception(e)
            main_logger.info('Retrying connection in 5 seconds...')
            time.sleep(5)

        finally:
            client.loop.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号