Exemplo n.º 1
0
def load_modules(bot):
    defaults = ("autoresponder", "audio", "customcom", "downloader",
                "lockdown", "general", "image", "mod", "speedtest")

    try:
        registry = dataIO.load_json("data/projectpython/modules.json")
    except:
        registry = {}

    bot.load_extension('modules.owner')
    owner_module = bot.get_cog('Owner')
    if owner_module is None:
        print("The owner module is missing. It contains core function without "
              "which ProjectPython cannot function. Reinstall.")
        exit(1)

    if bot.settings._no_modules:
        bot.logger.debug("Skipping initial modules loading (--no-modules)")
        if not os.path.isfile("data/projectpython/modules.json"):
            dataIO.save_json("data/projectpython/modules.json", {})
        return

    failed = []
    extensions = owner_module._list_modules()

    if not registry:
        for ext in defaults:
            registry["modules." + ext] = True

    for extension in extensions:
        if extension.lower() == "modules.owner":
            continue
        to_load = registry.get(extension, False)
        if to_load:
            try:
                owner_module._load_module(extension)
            except Exception as e:
                print("{}: {}".format(e.__class__.__name__, str(e)))
                bot.logger.exception(e)
                failed.append(extension)
                registry[extension] = False

    dataIO.save_json("data/projectpython/modules.json", registry)

    if failed:
        print("\nFailed to load: {}\n".format(" ".join(failed)))
Exemplo n.º 2
0
def set_module(module, value):
    data = dataIO.load_json("data/projectpython/modules.json")
    data[module] = value
    dataIO.save_json("data/projectpython/modules.json", data)
Exemplo n.º 3
0
def check_files():
    f = os.path.join("data", "downloader", "repos.json")
    if not dataIO.is_valid_json(f):
        print("Creating default data/downloader/repos.json")
        dataIO.save_json(f, {})
Exemplo n.º 4
0
    "hometown": "Your city",

    "signature_title": "Username",
    "signature_desc": "From Selfbot",
    "signature_url": "http://google.com",
    "signature_colour": 0,
    "signature_field_name": "«Sometimes, i dream about cheese»",
    "signature_field_content": "Some text about cheese"
}

if not os.path.exists("data/SelfBot"):
    os.makedirs("data/SelfBot")

if not dataIO.is_valid_json("data/SelfBot/config.json"):
    print("<!>[ERROR] Incorrect or missing config.json\n<!> Recreating...")
    dataIO.save_json("data/SelfBot/config.json", def_config)

config = dataIO.load_json("data/SelfBot/config.json")

formatter = helpformat.CustomHelp(show_check_failure=False)

# Set's bot's description and prefixes in a list
description = config["description"] + "\n" + "Version: \"" + version + "\""


########################################################################################################################

class Bot(commands.Bot):
    def __init__(self):
        self.uptime = datetime.datetime.utcnow()  # Refreshed before login
        super().__init__(command_prefix=[config["prefix"]],
Exemplo n.º 5
0
 def save_repos(self):
     dataIO.save_json(self.file_path, self.repos)