[Downloader] Reworded disclaimer, show only once every session

This commit is contained in:
Twentysix 2017-01-31 15:54:40 +01:00
parent f2fc5330fa
commit 146d9df460

View File

@ -20,6 +20,13 @@ REPO_CLONE = 0x2
REPO_SAME = 0x4 REPO_SAME = 0x4
REPOS_LIST = "https://twentysix26.github.io/Red-Docs/red_cog_approved_repos/" REPOS_LIST = "https://twentysix26.github.io/Red-Docs/red_cog_approved_repos/"
DISCLAIMER = ("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."
"\nBy typing 'I agree' you declare to have read and understand "
"the above message. This message won't be shown again until the"
" next reboot.")
class UpdateError(Exception): class UpdateError(Exception):
pass pass
@ -38,6 +45,7 @@ class Downloader:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.disclaimer_accepted = False
self.path = "data/downloader/" self.path = "data/downloader/"
self.file_path = "data/downloader/repos.json" self.file_path = "data/downloader/repos.json"
# {name:{url,cog1:{installed},cog1:{installed}}} # {name:{url,cog1:{installed},cog1:{installed}}}
@ -69,24 +77,18 @@ class Downloader:
Warning: Adding 3RD Party Repositories is at your own Warning: Adding 3RD Party Repositories is at your own
Risk.""" Risk."""
await self.bot.say("Type 'I agree' to confirm " if not self.disclaimer_accepted:
"adding a 3rd party repo. This has the possibility" await self.bot.say(DISCLAIMER)
" of being harmful. You will not receive help " answer = await self.bot.wait_for_message(timeout=30,
"in Red - Discord Bot #support for any cogs " author=ctx.message.author)
"installed from this repo. If you do require " if answer is None:
"support you should contact the owner of this " await self.bot.say('Not adding repo.')
"repo.\n\nAgain, ANY repo you add is at YOUR" return
" discretion and the creator of Red has " elif "i agree" not in answer.content.lower():
"ABSOLUTELY ZERO responsibility to help if " await self.bot.say('Not adding repo.')
"something goes wrong.") return
answer = await self.bot.wait_for_message(timeout=15, else:
author=ctx.message.author) self.disclaimer_accepted = True
if answer is None:
await self.bot.say('Not adding repo.')
return
elif "i agree" not in answer.content.lower():
await self.bot.say('Not adding repo.')
return
self.repos[repo_name] = {} self.repos[repo_name] = {}
self.repos[repo_name]['url'] = repo_url self.repos[repo_name]['url'] = repo_url
try: try: