Backup #16

Merged
cswimr merged 41 commits from backup into main 2024-01-31 15:58:08 -05:00
Showing only changes of commit 7fa6cd5922 - Show all commits

View file

@ -10,6 +10,7 @@ import itertools
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import text_to_file
class Backup(commands.Cog): class Backup(commands.Cog):
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier.""" """A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
@ -34,10 +35,24 @@ class Backup(commands.Cog):
if downloader is None: if downloader is None:
await ctx.send(f"You do not have the `Downloader` cog loaded.\nPlease run `{ctx.prefix}load downloader` and try again.") await ctx.send(f"You do not have the `Downloader` cog loaded.\nPlease run `{ctx.prefix}load downloader` and try again.")
return return
all_repos = list(downloader._repo_manager.repos) all_repos = list(downloader._repo_manager.repos)
repos_list = [[f"{i.name}", i.url] for i in all_repos]
cogs = await downloader.installed_cogs() export_data = []
for cog, r in itertools.product(cogs, repos_list):
if cog.repo_name == list(r)[0]: for repo in all_repos:
r.append(cog.name) repo_dict = {
await ctx.send(json.dumps(repos_list, indent=4)) "name": repo.name,
"url": repo.url,
"cogs": []
}
cogs = await downloader.installed_cogs()
for cog in cogs:
if cog.repo_name == repo.name:
repo_dict["cogs"].append(cog.name)
export_data.append(repo_dict)
await ctx.send(file=text_to_file(json.dumps(export_data, indent=4), 'backup.json'))