mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[i18n] Pass over bank, cleanup, customcom, dataconverter, downloader
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import asyncio
|
||||
|
||||
from redbot.core import commands
|
||||
from redbot.core.i18n import Translator
|
||||
from redbot.core.utils.predicates import MessagePredicate
|
||||
|
||||
__all__ = ["do_install_agreement"]
|
||||
|
||||
REPO_INSTALL_MSG = (
|
||||
T_ = Translator("DownloaderChecks", __file__)
|
||||
|
||||
_ = lambda s: s
|
||||
REPO_INSTALL_MSG = _(
|
||||
"You're about to add a 3rd party repository. The creator of Red"
|
||||
" and its community have no responsibility for any potential "
|
||||
"damage that the content of 3rd party repositories might cause."
|
||||
@@ -14,6 +18,7 @@ REPO_INSTALL_MSG = (
|
||||
"shown again until the next reboot.\n\nYou have **30** seconds"
|
||||
" to reply to this message."
|
||||
)
|
||||
_ = T_
|
||||
|
||||
|
||||
async def do_install_agreement(ctx: commands.Context):
|
||||
@@ -21,14 +26,14 @@ async def do_install_agreement(ctx: commands.Context):
|
||||
if downloader is None or downloader.already_agreed:
|
||||
return True
|
||||
|
||||
await ctx.send(REPO_INSTALL_MSG)
|
||||
await ctx.send(T_(REPO_INSTALL_MSG))
|
||||
|
||||
try:
|
||||
await ctx.bot.wait_for(
|
||||
"message", check=MessagePredicate.lower_equal_to("i agree", ctx), timeout=30
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.send("Your response has timed out, please try again.")
|
||||
await ctx.send(_("Your response has timed out, please try again."))
|
||||
return False
|
||||
|
||||
downloader.already_agreed = True
|
||||
|
||||
@@ -8,10 +8,10 @@ class InstalledCog(Installable):
|
||||
async def convert(cls, ctx: commands.Context, arg: str) -> Installable:
|
||||
downloader = ctx.bot.get_cog("Downloader")
|
||||
if downloader is None:
|
||||
raise commands.CommandError("Downloader not loaded.")
|
||||
raise commands.CommandError(_("No Downloader cog found."))
|
||||
|
||||
cog = discord.utils.get(await downloader.installed_cogs(), name=arg)
|
||||
if cog is None:
|
||||
raise commands.BadArgument("That cog is not installed")
|
||||
raise commands.BadArgument(_("That cog is not installed"))
|
||||
|
||||
return cog
|
||||
|
||||
@@ -8,7 +8,7 @@ from sys import path as syspath
|
||||
from typing import Tuple, Union, Iterable
|
||||
|
||||
import discord
|
||||
from redbot.core import checks, commands, Config
|
||||
from redbot.core import checks, commands, Config, checks, commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.data_manager import cog_data_path
|
||||
from redbot.core.i18n import Translator, cog_i18n
|
||||
@@ -193,9 +193,7 @@ class Downloader(commands.Cog):
|
||||
@commands.command()
|
||||
@checks.is_owner()
|
||||
async def pipinstall(self, ctx, *deps: str):
|
||||
"""
|
||||
Installs a group of dependencies using pip.
|
||||
"""
|
||||
"""Install a group of dependencies using pip."""
|
||||
repo = Repo("", "", "", Path.cwd(), loop=ctx.bot.loop)
|
||||
success = await repo.install_raw_requirements(deps, self.LIB_PATH)
|
||||
|
||||
@@ -212,18 +210,15 @@ class Downloader(commands.Cog):
|
||||
@commands.group()
|
||||
@checks.is_owner()
|
||||
async def repo(self, ctx):
|
||||
"""
|
||||
Command group for managing Downloader repos.
|
||||
"""
|
||||
"""Repo management commands."""
|
||||
pass
|
||||
|
||||
@repo.command(name="add")
|
||||
async def _repo_add(self, ctx, name: str, repo_url: str, branch: str = None):
|
||||
"""
|
||||
Add a new repo to Downloader.
|
||||
"""Add a new repo.
|
||||
|
||||
Name can only contain characters A-z, numbers and underscore
|
||||
Branch will default to master if not specified
|
||||
The name can only contain characters A-z, numbers and underscores.
|
||||
The branch will default to master if not specified.
|
||||
"""
|
||||
agreed = await do_install_agreement(ctx)
|
||||
if not agreed:
|
||||
@@ -246,11 +241,9 @@ class Downloader(commands.Cog):
|
||||
if repo.install_msg is not None:
|
||||
await ctx.send(repo.install_msg.replace("[p]", ctx.prefix))
|
||||
|
||||
@repo.command(name="delete")
|
||||
@repo.command(name="delete", aliases=["remove"])
|
||||
async def _repo_del(self, ctx, repo_name: Repo):
|
||||
"""
|
||||
Removes a repo from Downloader and its' files.
|
||||
"""
|
||||
"""Remove a repo and its files."""
|
||||
await self._repo_manager.delete_repo(repo_name.name)
|
||||
|
||||
await ctx.send(
|
||||
@@ -259,9 +252,7 @@ class Downloader(commands.Cog):
|
||||
|
||||
@repo.command(name="list")
|
||||
async def _repo_list(self, ctx):
|
||||
"""
|
||||
Lists all installed repos.
|
||||
"""
|
||||
"""List all installed repos."""
|
||||
repos = self._repo_manager.get_all_repo_names()
|
||||
repos = sorted(repos, key=str.lower)
|
||||
joined = _("Installed Repos:\n\n")
|
||||
@@ -274,11 +265,9 @@ class Downloader(commands.Cog):
|
||||
|
||||
@repo.command(name="info")
|
||||
async def _repo_info(self, ctx, repo_name: Repo):
|
||||
"""
|
||||
Lists information about a single repo
|
||||
"""
|
||||
"""Show information about a repo."""
|
||||
if repo_name is None:
|
||||
await ctx.send(_("There is no repo `{repo_name}`").format(repo_name=repo_name.name))
|
||||
await ctx.send(_("Repo `{repo_name}` not found.").format(repo_name=repo_name.name))
|
||||
return
|
||||
|
||||
msg = _("Information on {repo_name}:\n{description}").format(
|
||||
@@ -289,28 +278,24 @@ class Downloader(commands.Cog):
|
||||
@commands.group()
|
||||
@checks.is_owner()
|
||||
async def cog(self, ctx):
|
||||
"""
|
||||
Command group for managing installable Cogs.
|
||||
"""
|
||||
"""Cog installation management commands."""
|
||||
pass
|
||||
|
||||
@cog.command(name="install")
|
||||
async def _cog_install(self, ctx, repo_name: Repo, cog_name: str):
|
||||
"""
|
||||
Installs a cog from the given repo.
|
||||
"""
|
||||
cog = discord.utils.get(repo_name.available_cogs, name=cog_name) # type: Installable
|
||||
"""Install a cog from the given repo."""
|
||||
cog: Installable = discord.utils.get(repo_name.available_cogs, name=cog_name)
|
||||
if cog is None:
|
||||
await ctx.send(
|
||||
_(
|
||||
"Error, there is no cog by the name of `{cog_name}` in the `{repo_name}` repo."
|
||||
"Error: there is no cog by the name of `{cog_name}` in the `{repo_name}` repo."
|
||||
).format(cog_name=cog_name, repo_name=repo_name.name)
|
||||
)
|
||||
return
|
||||
elif cog.min_python_version > sys.version_info:
|
||||
await ctx.send(
|
||||
_("This cog requires at least python version {}, aborting install.").format(
|
||||
".".join([str(n) for n in cog.min_python_version])
|
||||
_("This cog requires at least python version {version}, aborting install.").format(
|
||||
version=".".join([str(n) for n in cog.min_python_version])
|
||||
)
|
||||
)
|
||||
return
|
||||
@@ -329,15 +314,16 @@ class Downloader(commands.Cog):
|
||||
|
||||
await repo_name.install_libraries(self.SHAREDLIB_PATH)
|
||||
|
||||
await ctx.send(_("`{cog_name}` cog successfully installed.").format(cog_name=cog_name))
|
||||
await ctx.send(_("Cog `{cog_name}` successfully installed.").format(cog_name=cog_name))
|
||||
if cog.install_msg is not None:
|
||||
await ctx.send(cog.install_msg.replace("[p]", ctx.prefix))
|
||||
|
||||
@cog.command(name="uninstall")
|
||||
async def _cog_uninstall(self, ctx, cog_name: InstalledCog):
|
||||
"""
|
||||
Allows you to uninstall cogs that were previously installed
|
||||
through Downloader.
|
||||
"""Uninstall a cog.
|
||||
|
||||
You may only uninstall cogs which were previously installed
|
||||
by Downloader.
|
||||
"""
|
||||
# noinspection PyUnresolvedReferences,PyProtectedMember
|
||||
real_name = cog_name.name
|
||||
@@ -348,7 +334,7 @@ class Downloader(commands.Cog):
|
||||
# noinspection PyTypeChecker
|
||||
await self._remove_from_installed(cog_name)
|
||||
await ctx.send(
|
||||
_("`{real_name}` was successfully removed.").format(real_name=real_name)
|
||||
_("Cog `{cog_name}` was successfully uninstalled.").format(cog_name=real_name)
|
||||
)
|
||||
else:
|
||||
await ctx.send(
|
||||
@@ -356,14 +342,14 @@ class Downloader(commands.Cog):
|
||||
"That cog was installed but can no longer"
|
||||
" be located. You may need to remove it's"
|
||||
" files manually if it is still usable."
|
||||
)
|
||||
" Also make sure you've unloaded the cog"
|
||||
" with `{prefix}unload {cog_name}`."
|
||||
).format(cog_name=real_name)
|
||||
)
|
||||
|
||||
@cog.command(name="update")
|
||||
async def _cog_update(self, ctx, cog_name: InstalledCog = None):
|
||||
"""
|
||||
Updates all cogs or one of your choosing.
|
||||
"""
|
||||
"""Update all cogs, or one of your choosing."""
|
||||
installed_cogs = set(await self.installed_cogs())
|
||||
|
||||
async with ctx.typing():
|
||||
@@ -426,9 +412,7 @@ class Downloader(commands.Cog):
|
||||
|
||||
@cog.command(name="list")
|
||||
async def _cog_list(self, ctx, repo_name: Repo):
|
||||
"""
|
||||
Lists all available cogs from a single repo.
|
||||
"""
|
||||
"""List all available cogs from a single repo."""
|
||||
installed = await self.installed_cogs()
|
||||
installed_str = ""
|
||||
if installed:
|
||||
@@ -453,9 +437,7 @@ class Downloader(commands.Cog):
|
||||
|
||||
@cog.command(name="info")
|
||||
async def _cog_info(self, ctx, repo_name: Repo, cog_name: str):
|
||||
"""
|
||||
Lists information about a single cog.
|
||||
"""
|
||||
"""List information about a single cog."""
|
||||
cog = discord.utils.get(repo_name.available_cogs, name=cog_name)
|
||||
if cog is None:
|
||||
await ctx.send(
|
||||
@@ -549,9 +531,9 @@ class Downloader(commands.Cog):
|
||||
|
||||
@commands.command()
|
||||
async def findcog(self, ctx: commands.Context, command_name: str):
|
||||
"""
|
||||
Figures out which cog a command comes from. Only works with loaded
|
||||
cogs.
|
||||
"""Find which cog a command comes from.
|
||||
|
||||
This will only work with loaded cogs.
|
||||
"""
|
||||
command = ctx.bot.all_commands.get(command_name)
|
||||
|
||||
|
||||
@@ -12,11 +12,15 @@ from typing import Tuple, MutableMapping, Union, Optional
|
||||
|
||||
from redbot.core import data_manager, commands
|
||||
from redbot.core.utils import safe_delete
|
||||
from redbot.core.i18n import Translator
|
||||
|
||||
from . import errors
|
||||
from .installable import Installable, InstallableType
|
||||
from .json_mixins import RepoJSONMixin
|
||||
from .log import log
|
||||
|
||||
_ = Translator("RepoManager", __file__)
|
||||
|
||||
|
||||
class Repo(RepoJSONMixin):
|
||||
GIT_CLONE = "git clone --recurse-submodules -b {branch} {url} {folder}"
|
||||
@@ -64,13 +68,15 @@ class Repo(RepoJSONMixin):
|
||||
async def convert(cls, ctx: commands.Context, argument: str):
|
||||
downloader_cog = ctx.bot.get_cog("Downloader")
|
||||
if downloader_cog is None:
|
||||
raise commands.CommandError("No Downloader cog found.")
|
||||
raise commands.CommandError(_("No Downloader cog found."))
|
||||
|
||||
# noinspection PyProtectedMember
|
||||
repo_manager = downloader_cog._repo_manager
|
||||
poss_repo = repo_manager.get_repo(argument)
|
||||
if poss_repo is None:
|
||||
raise commands.BadArgument("Repo by the name {} does not exist.".format(argument))
|
||||
raise commands.BadArgument(
|
||||
_('Repo by the name "{repo_name}" does not exist.').format(repo_name=argument)
|
||||
)
|
||||
return poss_repo
|
||||
|
||||
def _existing_git_repo(self) -> (bool, Path):
|
||||
|
||||
Reference in New Issue
Block a user