embedbot.py 文件源码

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

项目:embedbot 作者: Luigimaster1 项目源码 文件源码
def update(ctx):
    await say(ctx.message, "Updating...")
    import platform
    try:
        from git import Repo
    except ImportError:
        await say(ctx.message, "Please install the module gitpython.".format(pip_os))
        return
    import shutil
    from distutils.dir_util import copy_tree
    import stat
    try:
        os.remove("oldconfig.json")
    except OSError:
        pass
    os.rename("config.json", "oldconfig.json")
    os.remove("embedbot.py") #lol r i p embedbot if this doesn't work r i p my work
    os.remove("README.md")
    os.remove("requirements.txt")
    repo_url = "https://www.github.com/Luigimaster1/embedbot.git"
    local_dir = "./tempupdate/"
    Repo.clone_from(repo_url, local_dir)
    def del_rw(action, name, exc):
        os.chmod(name, stat.S_IWRITE)
        os.remove(name)
    shutil.rmtree("./tempupdate/.git/", onerror=del_rw)
    copy_tree(local_dir, ".")
    shutil.rmtree("./tempupdate/", onerror=del_rw)
    os.remove("botinfo.json")
    await say(ctx.message, "The bot has been updated. Please restart the bot.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号