feat(backup): added the cog
This commit is contained in:
parent
fa7faec4c2
commit
abc9927dea
3 changed files with 61 additions and 0 deletions
5
backup/__init__.py
Normal file
5
backup/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from .backup import Backup
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Backup(bot))
|
43
backup/backup.py
Normal file
43
backup/backup.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# _____ _
|
||||||
|
# / ____| (_)
|
||||||
|
# | (___ ___ __ _ _____ ___ _ __ ___ _ __ ___ ___ _ __
|
||||||
|
# \___ \ / _ \/ _` / __\ \ /\ / / | '_ ` _ \| '_ ` _ \ / _ \ '__|
|
||||||
|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
||||||
|
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
||||||
|
|
||||||
|
import json
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
from redbot.core import commands
|
||||||
|
from redbot.core.bot import Red
|
||||||
|
|
||||||
|
class Backup(commands.Cog):
|
||||||
|
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
|
||||||
|
|
||||||
|
__author__ = "SeaswimmerTheFsh"
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
def __init__(self, bot: Red):
|
||||||
|
super().__init__()
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.group(autohelp=True)
|
||||||
|
@commands.is_owner()
|
||||||
|
async def backup(self, ctx: commands.Context):
|
||||||
|
"""Backup your installed cogs."""
|
||||||
|
|
||||||
|
@backup.command(name='export')
|
||||||
|
@commands.is_owner()
|
||||||
|
async def backup_export(self, ctx: commands.Context):
|
||||||
|
"""Export your installed repositories and cogs to a file."""
|
||||||
|
downloader = ctx.bot.get_cog("Downloader")
|
||||||
|
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.")
|
||||||
|
return
|
||||||
|
all_repos = list(downloader._repo_manager.repos)
|
||||||
|
repos_list = [[f"{i.name}", i.url] for i in all_repos]
|
||||||
|
cogs = await downloader.installed_cogs()
|
||||||
|
for cog, r in itertools.product(cogs, repos_list):
|
||||||
|
if cog.repo_name == list(r)[0]:
|
||||||
|
r.append(cog.name)
|
||||||
|
await ctx.send(json.dumps(repos_list, indent=4))
|
13
backup/info.json
Normal file
13
backup/info.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"author" : ["SeaswimmerTheFsh"],
|
||||||
|
"install_msg" : "Thank you for installing Backup!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||||
|
"name" : "Backup",
|
||||||
|
"short" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.",
|
||||||
|
"description" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.",
|
||||||
|
"end_user_data_statement" : "This cog does not store user information.",
|
||||||
|
"hidden": false,
|
||||||
|
"disabled": false,
|
||||||
|
"min_bot_version": "3.5.0",
|
||||||
|
"min_python_version": [3, 10, 0],
|
||||||
|
"tags": []
|
||||||
|
}
|
Loading…
Reference in a new issue