Merge V3/release/3.0.0 into V3/develop

This commit is contained in:
Toby Harradine
2018-10-12 08:59:14 +11:00
committed by GitHub
13 changed files with 249 additions and 107 deletions

View File

@@ -34,14 +34,14 @@ async def download_lavalink(session):
async def maybe_download_lavalink(loop, cog):
jar_exists = LAVALINK_JAR_FILE.exists()
current_build = redbot.core.VersionInfo.from_json(await cog.config.current_build())
current_build = redbot.core.VersionInfo.from_json(await cog.config.current_version())
if not jar_exists or current_build < redbot.core.version_info:
log.info("Downloading Lavalink.jar")
LAVALINK_DOWNLOAD_DIR.mkdir(parents=True, exist_ok=True)
async with ClientSession(loop=loop) as session:
await download_lavalink(session)
await cog.config.current_build.set(redbot.core.version_info.to_json())
await cog.config.current_version.set(redbot.core.version_info.to_json())
shutil.copyfile(str(BUNDLED_APP_YML_FILE), str(APP_YML_FILE))

View File

@@ -48,7 +48,7 @@ class Audio(commands.Cog):
"ws_port": "2332",
"password": "youshallnotpass",
"status": False,
"current_build": redbot.core.VersionInfo.from_str("3.0.0a0").to_json(),
"current_version": redbot.core.VersionInfo.from_str("3.0.0a0").to_json(),
"use_external_lavalink": False,
}

View File

@@ -169,7 +169,7 @@ class Cleanup(commands.Cog):
member = None
try:
member = await commands.converter.MemberConverter().convert(ctx, user)
member = await commands.MemberConverter().convert(ctx, user)
except commands.BadArgument:
try:
_id = int(user)

View File

@@ -542,7 +542,8 @@ class Permissions(commands.Cog):
continue
conf = self.config.custom(category)
for cmd_name, cmd_rules in rules_dict.items():
await conf.set_raw(cmd_name, guild_id, value=cmd_rules)
cmd_rules = {str(model_id): rule for model_id, rule in cmd_rules.items()}
await conf.set_raw(cmd_name, str(guild_id), value=cmd_rules)
cmd_obj = getter(cmd_name)
if cmd_obj is not None:
self._load_rules_for(cmd_obj, {guild_id: cmd_rules})
@@ -651,14 +652,14 @@ class Permissions(commands.Cog):
if category in old_rules:
for name, rules in old_rules[category].items():
these_rules = new_rules.setdefault(name, {})
guild_rules = these_rules.setdefault(guild_id, {})
guild_rules = these_rules.setdefault(str(guild_id), {})
# Since allow rules would take precedence if the same model ID
# sat in both the allow and deny list, we add the deny entries
# first and let any conflicting allow entries overwrite.
for model_id in rules.get("deny", []):
guild_rules[model_id] = False
guild_rules[str(model_id)] = False
for model_id in rules.get("allow", []):
guild_rules[model_id] = True
guild_rules[str(model_id)] = True
if "default" in rules:
default = rules["default"]
if default == "allow":
@@ -689,7 +690,9 @@ class Permissions(commands.Cog):
"""
for guild_id, guild_dict in _int_key_map(rule_dict.items()):
for model_id, rule in _int_key_map(guild_dict.items()):
if rule is True:
if model_id == "default":
cog_or_command.set_default_rule(rule, guild_id=guild_id)
elif rule is True:
cog_or_command.allow_for(model_id, guild_id=guild_id)
elif rule is False:
cog_or_command.deny_to(model_id, guild_id=guild_id)
@@ -724,9 +727,16 @@ class Permissions(commands.Cog):
rules.
"""
for guild_id, guild_dict in _int_key_map(rule_dict.items()):
for model_id in map(int, guild_dict.keys()):
cog_or_command.clear_rule_for(model_id, guild_id)
for model_id in guild_dict.keys():
if model_id == "default":
cog_or_command.set_default_rule(None, guild_id=guild_id)
else:
cog_or_command.clear_rule_for(int(model_id), guild_id=guild_id)
def _int_key_map(items_view: ItemsView[str, Any]) -> Iterator[Tuple[int, Any]]:
return map(lambda tup: (int(tup[0]), tup[1]), items_view)
def _int_key_map(items_view: ItemsView[str, Any]) -> Iterator[Tuple[Union[str, int], Any]]:
for k, v in items_view:
if k == "default":
yield k, v
else:
yield int(k), v

View File

@@ -322,9 +322,9 @@ def _parse_answers(answers):
for answer in answers:
if isinstance(answer, bool):
if answer is True:
ret.extend(["True", "Yes", _("Yes")])
ret.extend(["True", "Yes", "On"])
else:
ret.extend(["False", "No", _("No")])
ret.extend(["False", "No", "Off"])
else:
ret.append(str(answer))
# Uniquify list

View File

@@ -19,9 +19,11 @@ async def warning_points_add_check(
act = {}
async with guild_settings.actions() as registered_actions:
for a in registered_actions:
# Actions are sorted in decreasing order of points.
# The first action we find where the user is above the threshold will be the
# highest action we can take.
if points >= a["points"]:
act = a
else:
break
if act and act["exceed_command"] is not None: # some action needs to be taken
await create_and_invoke_context(ctx, act["exceed_command"], user)

View File

@@ -9,7 +9,7 @@ from redbot.cogs.warnings.helpers import (
get_command_for_dropping_points,
warning_points_remove_check,
)
from redbot.core import Config, modlog, checks, commands
from redbot.core import Config, checks, commands
from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n
from redbot.core.utils.mod import is_admin_or_superior
@@ -34,15 +34,14 @@ class Warnings(commands.Cog):
self.config.register_guild(**self.default_guild)
self.config.register_member(**self.default_member)
self.bot = bot
loop = asyncio.get_event_loop()
loop.create_task(self.register_warningtype())
@staticmethod
async def register_warningtype():
try:
await modlog.register_casetype("warning", True, "\N{WARNING SIGN}", "Warning", None)
except RuntimeError:
pass
# We're not utilising modlog yet - no need to register a casetype
# @staticmethod
# async def register_warningtype():
# try:
# await modlog.register_casetype("warning", True, "\N{WARNING SIGN}", "Warning", None)
# except RuntimeError:
# pass
@commands.group()
@commands.guild_only()