mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Downloader] Don't do 3rd party agreement without command args (#1821)
This commit is contained in:
parent
94a64d8fae
commit
e15815cd97
@ -1,9 +1,9 @@
|
||||
import asyncio
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from redbot.core import commands
|
||||
|
||||
__all__ = ["install_agreement"]
|
||||
__all__ = ["do_install_agreement"]
|
||||
|
||||
REPO_INSTALL_MSG = (
|
||||
"You're about to add a 3rd party repository. The creator of Red"
|
||||
@ -16,22 +16,13 @@ REPO_INSTALL_MSG = (
|
||||
)
|
||||
|
||||
|
||||
def install_agreement():
|
||||
async def pred(ctx: commands.Context):
|
||||
downloader = ctx.command.instance
|
||||
if downloader is None:
|
||||
return True
|
||||
elif downloader.already_agreed:
|
||||
return True
|
||||
elif ctx.invoked_subcommand is None or isinstance(ctx.invoked_subcommand, commands.Group):
|
||||
async def do_install_agreement(ctx: commands.Context):
|
||||
downloader = ctx.cog
|
||||
if downloader is None or downloader.already_agreed:
|
||||
return True
|
||||
|
||||
def does_agree(msg: discord.Message):
|
||||
return (
|
||||
ctx.author == msg.author
|
||||
and ctx.channel == msg.channel
|
||||
and msg.content == "I agree"
|
||||
)
|
||||
return ctx.author == msg.author and ctx.channel == msg.channel and msg.content == "I agree"
|
||||
|
||||
await ctx.send(REPO_INSTALL_MSG)
|
||||
|
||||
@ -43,5 +34,3 @@ def install_agreement():
|
||||
|
||||
downloader.already_agreed = True
|
||||
return True
|
||||
|
||||
return commands.check(pred)
|
||||
|
||||
@ -15,7 +15,7 @@ from redbot.core.utils.chat_formatting import box, pagify
|
||||
from redbot.core import commands
|
||||
|
||||
from redbot.core.bot import Red
|
||||
from .checks import install_agreement
|
||||
from .checks import do_install_agreement
|
||||
from .converters import InstalledCog
|
||||
from .errors import CloningError, ExistingGitRepo
|
||||
from .installable import Installable
|
||||
@ -214,7 +214,6 @@ class Downloader:
|
||||
await ctx.send_help()
|
||||
|
||||
@repo.command(name="add")
|
||||
@install_agreement()
|
||||
async def _repo_add(self, ctx, name: str, repo_url: str, branch: str = None):
|
||||
"""
|
||||
Add a new repo to Downloader.
|
||||
@ -222,6 +221,9 @@ class Downloader:
|
||||
Name can only contain characters A-z, numbers and underscore
|
||||
Branch will default to master if not specified
|
||||
"""
|
||||
agreed = await do_install_agreement(ctx)
|
||||
if not agreed:
|
||||
return
|
||||
try:
|
||||
# noinspection PyTypeChecker
|
||||
repo = await self._repo_manager.add_repo(name=name, url=repo_url, branch=branch)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user