builtin.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def import_(message: discord.Message, module: str, attr: str=None):
    """ Import the specified module. Specifying `attr` will act like `from attr import module`.

    If the given attribute starts with a colon :, the name for the module will be defined as
    whatever follows the colon character. If nothing follows, the last subcommand in the module
    is used.
    """
    try:
        name = import_module(module, attr)
    except ImportError:
        await client.say(message, "Unable to import `{}`.".format(module))
    except KeyError:
        await client.say(message, "Unable to import `{}` from `{}`.".format(attr, module))
    else:
        # There were no errors when importing, so we add the name to our startup imports
        lambda_config.data["imports"].append((module, attr))
        lambda_config.save()
        await client.say(message, "Imported and setup `{}` for import.".format(name))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号