bot.py 文件源码

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

项目:Dwarf 作者: Dwarf-Community 项目源码 文件源码
def main(loop=None):
    if loop is None:
        loop = asyncio.get_event_loop()

    bot = Bot(loop=loop, command_prefix=core.get_prefixes(), description=__doc__, pm_help=core.is_help_private())

    if not is_configured():
        initial_config()

    error = False
    error_message = ""
    try:
        loop.run_until_complete(run(bot))
    except discord.LoginFailure:
        error = True
        error_message = 'Invalid credentials'
        choice = input(strings.invalid_credentials)
        if choice.strip() == 'reset':
            base.delete_token()
        else:
            base.disable_restarting()
    except KeyboardInterrupt:
        base.disable_restarting()
        loop.run_until_complete(bot.logout())
    except Exception as e:
        error = True
        print(e)
        error_message = traceback.format_exc()
        base.disable_restarting()
        loop.run_until_complete(bot.logout())
    finally:
        if error:
            print(error_message)
        return bot
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号