Merge V3/release/3.0.0 into V3/develop

This commit is contained in:
Toby Harradine
2019-01-28 15:30:30 +11:00
committed by GitHub
69 changed files with 21563 additions and 81 deletions

View File

@@ -117,7 +117,7 @@ async def sigterm_handler(red, log):
def main():
description = "Red - Version {}".format(__version__)
description = "Red V3"
cli_flags = parse_cli_flags(sys.argv[1:])
if cli_flags.list_instances:
list_instances()

View File

@@ -96,9 +96,12 @@ async def start_lavalink_server(loop):
if not java_available:
raise RuntimeError("You must install Java 1.8+ for Lavalink to run.")
extra_flags = ""
if java_version == (1, 8):
extra_flags = "-Dsun.zip.disableMemoryMapping=true"
elif java_version >= (11, 0):
extra_flags = "-Djdk.tls.client.protocols=TLSv1.2"
else:
extra_flags = ""
from . import LAVALINK_DOWNLOAD_DIR, LAVALINK_JAR_FILE

View File

@@ -148,5 +148,5 @@ class VersionInfo:
)
__version__ = "3.0.0rc3.post1"
__version__ = "3.0.0"
version_info = VersionInfo.from_str(__version__)

View File

@@ -500,7 +500,12 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
if result is not None:
hook_results.append(result)
if hook_results:
return all(hook_results)
if all(hook_results):
ctx.permission_state = commands.PermState.ALLOWED_BY_HOOK
return True
else:
ctx.permission_state = commands.PermState.DENIED_BY_HOOK
return False
class Red(RedBase, discord.AutoShardedClient):

View File

@@ -30,7 +30,7 @@ def interactive_config(red, token_set, prefix_set):
"\nPick a prefix. A prefix is what you type before a "
"command. Example:\n"
"!help\n^ The exclamation mark is the prefix in this case.\n"
"Can be multiple characters. You will be able to change it "
"The prefix can be multiple characters. You will be able to change it "
"later and add more of them.\nChoose your prefix:\n"
)
while not prefix:
@@ -51,7 +51,7 @@ def ask_sentry(red: Red):
loop = asyncio.get_event_loop()
print(
"\nThank you for installing Red V3! Red is constantly undergoing\n"
" improvements, and we would like ask if you are comfortable with\n"
" improvements, and we would like to ask if you are comfortable with\n"
" the bot automatically submitting fatal error logs to the development\n"
' team. If you wish to opt into the process please type "yes":\n'
)

View File

@@ -93,6 +93,10 @@ DM_PERMS.update(
class PrivilegeLevel(enum.IntEnum):
"""Enumeration for special privileges."""
# Maintainer Note: do NOT re-order these.
# Each privelege level also implies access to the ones before it.
# Inserting new privelege levels at a later point is fine if that is considered.
NONE = enum.auto()
"""No special privilege level."""
@@ -168,6 +172,17 @@ class PermState(enum.Enum):
chain.
"""
# The below are valid states, but should not be transitioned to
# They should be set if they apply.
ALLOWED_BY_HOOK = enum.auto()
"""This command has been actively allowed by a permission hook.
check validation doesn't need this, but is useful to developers"""
DENIED_BY_HOOK = enum.auto()
"""This command has been actively denied by a permission hook
check validation doesn't need this, but is useful to developers"""
def transition_to(
self, next_state: "PermState"
) -> Tuple[Optional[bool], Union["PermState", Dict[bool, "PermState"]]]:

View File

@@ -115,18 +115,7 @@ def update_red(dev=False, voice=False, mongo=False, docs=False, test=False):
package = "Red-DiscordBot"
if egg_l:
package += "[{}]".format(", ".join(egg_l))
arguments = [
interpreter,
"-m",
"pip",
"install",
"-U",
"-I",
"--no-cache-dir",
"--force-reinstall",
"--process-dependency-links",
package,
]
arguments = [interpreter, "-m", "pip", "install", "-U", package]
if not is_venv():
arguments.append("--user")
code = subprocess.call(arguments)

View File

@@ -114,7 +114,7 @@ def get_storage_type():
print()
print("Please choose your storage backend (if you're unsure, choose 1).")
print("1. JSON (file storage, requires no database).")
print("2. MongoDB")
print("2. MongoDB (not recommended, currently unstable)")
storage = input("> ")
try:
storage = int(storage)
@@ -198,22 +198,23 @@ async def mongo_to_json(current_data_dir: Path, storage_details: dict):
m = Mongo("Core", "0", **storage_details)
db = m.db
collection_names = await db.collection_names(include_system_collections=False)
for c_name in collection_names:
if c_name == "Core":
collection_names = await db.list_collection_names()
for collection_name in collection_names:
if collection_name == "Core":
c_data_path = current_data_dir / "core"
else:
c_data_path = current_data_dir / "cogs/{}".format(c_name)
output = {}
docs = await db[c_name].find().to_list(None)
c_id = None
for item in docs:
item_id = item.pop("_id")
if not c_id:
c_id = str(hash(item_id))
output[item_id] = item
target = JSON(c_name, c_id, data_path_override=c_data_path)
await target.jsonIO._threadsafe_save_json(output)
c_data_path = current_data_dir / "cogs" / collection_name
c_data_path.mkdir(parents=True, exist_ok=True)
# Every cog name has its own collection
collection = db[collection_name]
async for document in collection.find():
# Every cog has its own document.
# This means if two cogs have the same name but different identifiers, they will
# be two separate documents in the same collection
cog_id = document.pop("_id")
driver = JSON(collection_name, cog_id, data_path_override=c_data_path)
for key, value in document.items():
await driver.set(key, value=value)
async def edit_instance():