[V3 Travis] Update travis to not skip pipfile lock... (#1678)

* Update travis to not sip pipfile lock

update pipfile dependencies

additional black formatting pass to conform to black 18.5b

* .

* pin async timeout until further discussion of 3.5 support

* .
This commit is contained in:
Michael H 2018-05-18 21:48:22 -04:00 committed by palmtree5
parent 55afc7eb33
commit d3f406a34a
35 changed files with 214 additions and 297 deletions

View File

@ -17,7 +17,7 @@ env:
install:
- pip install --upgrade pip pipenv
- pipenv install --skip-lock --dev
- pipenv install --dev
script:
- pipenv run tox

18
Pipfile.lock generated
View File

@ -48,10 +48,10 @@
},
"async-timeout": {
"hashes": [
"sha256:474d4bc64cee20603e225eb1ece15e248962958b45a3648a9f5cc29e827a610c",
"sha256:b3c0ddc416736619bd4a95ca31de8da6920c3b9a140c64dbef2b2fa7bf521287"
"sha256:00cff4d2dce744607335cba84e9929c3165632da2d27970dbc55802a0c7873d0",
"sha256:9093db5b8ddbe4b8f6885d1a6e0ad84ae3155464cbf6877c387605244c285f3c"
],
"version": "==3.0.0"
"version": "==2.0.1"
},
"chardet": {
"hashes": [
@ -215,12 +215,12 @@
},
"black": {
"hashes": [
"sha256:58594128efb5d21f359c8680911241985e627eb3505397f3982ffbae914d8202",
"sha256:dfb0e344587510ef662785f4a8991addb4017840459bb6d1d53d344ab0f10300"
"sha256:4fec2566f9fbbd4a58de50a168cbe3ab952713530410d227e82e4c65d1fad946",
"sha256:5fec0f25486046b9edb97961c946412ced96021247dd1a60ecd9f0567b68b030"
],
"index": "pypi",
"markers": "python_version >= '3.6'",
"version": "==18.4a4"
"version": "==18.5b0"
},
"certifi": {
"hashes": [
@ -418,10 +418,10 @@
},
"virtualenv": {
"hashes": [
"sha256:1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54",
"sha256:e8e05d4714a1c51a2f5921e62f547fcb0f713ebbe959e0a7f585cc8bef71d11f"
"sha256:2ce32cd126117ce2c539f0134eb89de91a8413a29baac49cbab3eb50e2026669",
"sha256:ca07b4c0b54e14a91af9f34d0919790b016923d157afda5efdde55c96718f752"
],
"version": "==15.2.0"
"version": "==16.0.0"
}
}
}

View File

@ -199,9 +199,7 @@ class Alias:
"You attempted to create a new alias"
" with the name {} but that"
" name is already a command on this bot."
).format(
alias_name
)
).format(alias_name)
)
return
@ -212,9 +210,7 @@ class Alias:
"You attempted to create a new alias"
" with the name {} but that"
" alias already exists on this server."
).format(
alias_name
)
).format(alias_name)
)
return
@ -226,9 +222,7 @@ class Alias:
" with the name {} but that"
" name is an invalid alias name. Alias"
" names may not contain spaces."
).format(
alias_name
)
).format(alias_name)
)
return
# endregion
@ -255,9 +249,7 @@ class Alias:
"You attempted to create a new global alias"
" with the name {} but that"
" name is already a command on this bot."
).format(
alias_name
)
).format(alias_name)
)
return
@ -268,9 +260,7 @@ class Alias:
"You attempted to create a new global alias"
" with the name {} but that"
" alias already exists on this server."
).format(
alias_name
)
).format(alias_name)
)
return
@ -282,9 +272,7 @@ class Alias:
" with the name {} but that"
" name is an invalid alias name. Alias"
" names may not contain spaces."
).format(
alias_name
)
).format(alias_name)
)
return
# endregion

View File

@ -10,9 +10,7 @@ import redbot.core
LAVALINK_DOWNLOAD_URL = (
"https://github.com/Cog-Creators/Red-DiscordBot/" "releases/download/{}/Lavalink.jar"
).format(
redbot.core.__version__
)
).format(redbot.core.__version__)
LAVALINK_DOWNLOAD_DIR = cog_data_path(raw_name="Audio")
LAVALINK_JAR_FILE = LAVALINK_DOWNLOAD_DIR / "Lavalink.jar"

View File

@ -247,7 +247,7 @@ class Audio:
jarbuild = redbot.core.__version__
vote_percent = data["vote_percent"]
msg = ("```ini\n" "----Server Settings----\n")
msg = "```ini\n" "----Server Settings----\n"
if dj_enabled:
msg += "DJ Role: [{}]\n".format(dj_role_obj.name)
if jukebox:
@ -262,17 +262,13 @@ class Audio:
if vote_percent > 0:
msg += (
"Vote skip: [{vote_enabled}]\n" "Skip percentage: [{vote_percent}%]\n"
).format(
**data
)
).format(**data)
msg += (
"---Lavalink Settings---\n"
"Cog version: [{}]\n"
"Jar build: [{}]\n"
"External server: [{use_external_lavalink}]```"
).format(
__version__, jarbuild, **global_data
)
).format(__version__, jarbuild, **global_data)
embed = discord.Embed(colour=ctx.guild.me.top_role.colour, description=msg)
return await ctx.send(embed=embed)
@ -347,9 +343,8 @@ class Audio:
return await self._embed_msg(ctx, "Nothing playing.")
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You must be in the voice channel to bump a song.")
if dj_enabled:
if not await self._can_instaskip(ctx, ctx.author):
@ -373,9 +368,8 @@ class Audio:
if dj_enabled:
if not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You need the DJ role to disconnect.")
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return await self._embed_msg(ctx, "There are other people listening to music.")
else:
@ -418,9 +412,8 @@ class Audio:
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
vote_enabled = await self.config.guild(ctx.guild).vote_enabled()
if dj_enabled or vote_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return
@ -458,16 +451,14 @@ class Audio:
return await self._embed_msg(ctx, "Nothing playing.")
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to pause the music."
)
if dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return await self._embed_msg(ctx, "You need the DJ role to pause songs.")
@ -572,9 +563,8 @@ class Audio:
player.store("guild", ctx.guild.id)
await self._data_check(ctx)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to use the play command."
)
@ -645,10 +635,9 @@ class Audio:
return
async with self.config.guild(ctx.guild).playlists() as playlists:
try:
if (
playlists[playlist_name]["author"] != ctx.author.id
and not await self._can_instaskip(ctx, ctx.author)
):
if playlists[playlist_name][
"author"
] != ctx.author.id and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You are not the author of that playlist.")
player = lavalink.get_player(ctx.guild.id)
to_append = await self._playlist_tracks(ctx, player, url)
@ -693,10 +682,9 @@ class Audio:
"""Delete a saved playlist."""
async with self.config.guild(ctx.guild).playlists() as playlists:
try:
if (
playlists[playlist_name]["author"] != ctx.author.id
and not await self._can_instaskip(ctx, ctx.author)
):
if playlists[playlist_name][
"author"
] != ctx.author.id and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You are not the author of that playlist.")
del playlists[playlist_name]
except KeyError:
@ -799,10 +787,9 @@ class Audio:
"""Remove a song from a playlist by url."""
async with self.config.guild(ctx.guild).playlists() as playlists:
try:
if (
playlists[playlist_name]["author"] != ctx.author.id
and not await self._can_instaskip(ctx, ctx.author)
):
if playlists[playlist_name][
"author"
] != ctx.author.id and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You are not the author of that playlist.")
except KeyError:
return await self._embed_msg(ctx, "No playlist with that name.")
@ -977,9 +964,8 @@ class Audio:
player.store("channel", ctx.channel.id)
player.store("guild", ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
await self._embed_msg(
ctx, "You must be in the voice channel to use the playlist command."
)
@ -1019,15 +1005,13 @@ class Audio:
player = lavalink.get_player(ctx.guild.id)
shuffle = await self.config.guild(ctx.guild).shuffle()
if dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return await self._embed_msg(ctx, "You need the DJ role to skip songs.")
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to skip the music."
)
@ -1130,9 +1114,8 @@ class Audio:
"""Toggles repeat."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
if dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._has_dj_role(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._has_dj_role(
ctx, ctx.author
):
return await self._embed_msg(ctx, "You need the DJ role to toggle repeat.")
repeat = await self.config.guild(ctx.guild).repeat()
@ -1142,9 +1125,8 @@ class Audio:
await self._data_check(ctx)
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to toggle repeat."
)
@ -1163,9 +1145,8 @@ class Audio:
if not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You need the DJ role to remove songs.")
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to manage the queue."
)
@ -1195,9 +1176,8 @@ class Audio:
player.store("channel", ctx.channel.id)
player.store("guild", ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You must be in the voice channel to enqueue songs.")
await self._data_check(ctx)
@ -1341,14 +1321,12 @@ class Audio:
return await self._embed_msg(ctx, "Nothing playing.")
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, "You must be in the voice channel to use seek.")
if dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return await self._embed_msg(ctx, "You need the DJ role to use seek.")
if player.current:
@ -1381,9 +1359,8 @@ class Audio:
await self._data_check(ctx)
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to toggle shuffle."
)
@ -1396,9 +1373,8 @@ class Audio:
return await self._embed_msg(ctx, "Nothing playing.")
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to skip the music."
)
@ -1450,13 +1426,21 @@ class Audio:
is_owner = member.id == self.bot.owner_id
is_server_owner = member.id == ctx.guild.owner_id
is_coowner = any(x == member.id for x in self.bot._co_owners)
is_admin = discord.utils.get(
ctx.guild.get_member(member.id).roles, id=admin_role
) is not None
is_admin = (
discord.utils.get(ctx.guild.get_member(member.id).roles, id=admin_role) is not None
)
is_mod = discord.utils.get(ctx.guild.get_member(member.id).roles, id=mod_role) is not None
is_bot = member.bot is True
return is_active_dj or is_owner or is_server_owner or is_coowner or is_admin or is_mod or is_bot
return (
is_active_dj
or is_owner
or is_server_owner
or is_coowner
or is_admin
or is_mod
or is_bot
)
async def _is_alone(self, ctx, member):
try:
@ -1521,16 +1505,14 @@ class Audio:
return await self._embed_msg(ctx, "Nothing playing.")
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to stop the music."
)
if vote_enabled or vote_enabled and dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._is_alone(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
ctx, ctx.author
):
return await self._embed_msg(
ctx, "There are other people listening - vote to skip instead."
@ -1563,16 +1545,14 @@ class Audio:
if self._player_check(ctx):
player = lavalink.get_player(ctx.guild.id)
if (
(not ctx.author.voice or ctx.author.voice.channel != player.channel)
and not await self._can_instaskip(ctx, ctx.author)
):
not ctx.author.voice or ctx.author.voice.channel != player.channel
) and not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(
ctx, "You must be in the voice channel to change the volume."
)
if dj_enabled:
if (
not await self._can_instaskip(ctx, ctx.author)
and not await self._has_dj_role(ctx, ctx.author)
if not await self._can_instaskip(ctx, ctx.author) and not await self._has_dj_role(
ctx, ctx.author
):
return await self._embed_msg(ctx, "You need the DJ role to change the volume.")
if vol > 150:

View File

@ -75,17 +75,9 @@ class Bank:
currency_name = await bank._conf.guild(ctx.guild).currency()
default_balance = await bank._conf.guild(ctx.guild).default_balance()
settings = (
_(
"Bank settings:\n\n"
"Bank name: {}\n"
"Currency: {}\n"
"Default balance: {}"
""
).format(
bank_name, currency_name, default_balance
)
)
settings = _(
"Bank settings:\n\n" "Bank name: {}\n" "Currency: {}\n" "Default balance: {}" ""
).format(bank_name, currency_name, default_balance)
await ctx.send(box(settings))
await ctx.send_help()
@ -103,9 +95,7 @@ class Bank:
_(
"This will toggle the bank to be {}, deleting all accounts "
"in the process! If you're sure, type `{}`"
).format(
word, "{}bankset toggleglobal yes".format(ctx.prefix)
)
).format(word, "{}bankset toggleglobal yes".format(ctx.prefix))
)
else:
await bank.set_global(not cur_setting)

View File

@ -198,8 +198,10 @@ class Cleanup:
before=ctx.message,
delete_pinned=delete_pinned,
)
reason = "{}({}) deleted {} messages " " made by {}({}) in channel {}." "".format(
author.name, author.id, len(to_delete), member or "???", _id, channel.name
reason = (
"{}({}) deleted {} messages "
" made by {}({}) in channel {}."
"".format(author.name, author.id, len(to_delete), member or "???", _id, channel.name)
)
log.info(reason)
@ -326,8 +328,10 @@ class Cleanup:
)
to_delete.append(ctx.message)
reason = "{}({}) deleted {} " " command messages in channel {}." "".format(
author.name, author.id, len(to_delete), channel.name
reason = (
"{}({}) deleted {} "
" command messages in channel {}."
"".format(author.name, author.id, len(to_delete), channel.name)
)
log.info(reason)
@ -369,7 +373,7 @@ class Cleanup:
me = ctx.guild.me
can_mass_purge = channel.permissions_for(me).manage_messages
use_re = (match_pattern and match_pattern.startswith("r(") and match_pattern.endswith(")"))
use_re = match_pattern and match_pattern.startswith("r(") and match_pattern.endswith(")")
if use_re:
match_pattern = match_pattern[1:] # strip 'r'
@ -414,8 +418,10 @@ class Cleanup:
else:
channel_name = str(channel)
reason = "{}({}) deleted {} messages " "sent by the bot in {}." "".format(
author.name, author.id, len(to_delete), channel_name
reason = (
"{}({}) deleted {} messages "
"sent by the bot in {}."
"".format(author.name, author.id, len(to_delete), channel_name)
)
log.info(reason)

View File

@ -40,16 +40,12 @@ class CommandObj:
return customcommands
async def get_responses(self, ctx):
intro = (
_(
intro = _(
"Welcome to the interactive random {} maker!\n"
"Every message you send will be added as one of the random "
"response to choose from once this {} is "
"triggered. To exit this interactive menu, type `{}`"
).format(
"customcommand", "customcommand", "exit()"
)
)
).format("customcommand", "customcommand", "exit()")
await ctx.send(intro)
def check(m):
@ -263,9 +259,7 @@ class CustomCommands:
_(
"There are no custom commands in this server."
" Use `{}` to start adding some."
).format(
"{}customcom add".format(ctx.prefix)
)
).format("{}customcom add".format(ctx.prefix))
)
return

View File

@ -28,7 +28,11 @@ def install_agreement():
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)

View File

@ -30,7 +30,7 @@ class Repo(RepoJSONMixin):
GIT_DIFF_FILE_STATUS = (
"git -C {path} diff --no-commit-id --name-status" " {old_hash} {new_hash}"
)
GIT_LOG = ("git -C {path} log --relative-date --reverse {old_hash}.." " {relative_file_path}")
GIT_LOG = "git -C {path} log --relative-date --reverse {old_hash}.." " {relative_file_path}"
GIT_DISCOVER_REMOTE_URL = "git -C {path} config --get remote.origin.url"
PIP_INSTALL = "{python} -m pip install -U -t {target_dir} {reqs}"

View File

@ -39,13 +39,16 @@ PAYOUTS = {
"phrase": _("JACKPOT! 226! Your bid has been multiplied * 2500!"),
},
(SMReel.flc, SMReel.flc, SMReel.flc): {
"payout": lambda x: x + 1000, "phrase": _("4LC! +1000!")
"payout": lambda x: x + 1000,
"phrase": _("4LC! +1000!"),
},
(SMReel.cherries, SMReel.cherries, SMReel.cherries): {
"payout": lambda x: x + 800, "phrase": _("Three cherries! +800!")
"payout": lambda x: x + 800,
"phrase": _("Three cherries! +800!"),
},
(SMReel.two, SMReel.six): {
"payout": lambda x: x * 4 + x, "phrase": _("2 6! Your bid has been multiplied * 4!")
"payout": lambda x: x * 4 + x,
"phrase": _("2 6! Your bid has been multiplied * 4!"),
},
(SMReel.cherries, SMReel.cherries): {
"payout": lambda x: x * 3 + x,
@ -67,9 +70,7 @@ SLOT_PAYOUTS_MSG = _(
"{cherries.value} {cherries.value} Bet * 3\n\n"
"Three symbols: +500\n"
"Two symbols: Bet * 2"
).format(
**SMReel.__dict__
)
).format(**SMReel.__dict__)
def guild_only_check():
@ -362,11 +363,11 @@ class Economy:
slot_time = await self.config.SLOT_TIME()
last_slot = await self.config.user(author).last_slot()
else:
valid_bid = await self.config.guild(
guild
).SLOT_MIN() <= bid <= await self.config.guild(
guild
).SLOT_MAX()
valid_bid = (
await self.config.guild(guild).SLOT_MIN()
<= bid
<= await self.config.guild(guild).SLOT_MAX()
)
slot_time = await self.config.guild(guild).SLOT_TIME()
last_slot = await self.config.member(author).last_slot()
now = calendar.timegm(ctx.message.created_at.utctimetuple())

View File

@ -199,7 +199,7 @@ class General:
# A special case for a special someone :^)
special_date = datetime.datetime(2016, 1, 10, 6, 8, 4, 443000)
is_special = (user.id == 96130341705637888 and guild.id == 133049272517001216)
is_special = user.id == 96130341705637888 and guild.id == 133049272517001216
roles = sorted(user.roles)[1:]
@ -268,11 +268,9 @@ class General:
text_channels = len(guild.text_channels)
voice_channels = len(guild.voice_channels)
passed = (ctx.message.created_at - guild.created_at).days
created_at = (
_("Since {}. That's over {} days ago!" "").format(
created_at = _("Since {}. That's over {} days ago!" "").format(
guild.created_at.strftime("%d %b %Y %H:%M"), passed
)
)
colour = "".join([choice("0123456789ABCDEF") for x in range(6)])
colour = randint(0, 0xFFFFFF)
@ -332,9 +330,8 @@ class General:
definition = item_list[pos]["definition"]
example = item_list[pos]["example"]
defs = len(item_list)
msg = (
"**Definition #{} out of {}:\n**{}\n\n"
"**Example:\n**{}".format(pos + 1, defs, definition, example)
msg = "**Definition #{} out of {}:\n**{}\n\n" "**Example:\n**{}".format(
pos + 1, defs, definition, example
)
msg = pagify(msg, ["\n"])
for page in msg:

View File

@ -143,9 +143,8 @@ class Image:
await ctx.send_help()
return
url = (
"http://api.giphy.com/v1/gifs/search?&api_key={}&q={}"
"".format(GIPHY_API_KEY, keywords)
url = "http://api.giphy.com/v1/gifs/search?&api_key={}&q={}" "".format(
GIPHY_API_KEY, keywords
)
async with self.session.get(url) as r:
@ -167,9 +166,8 @@ class Image:
await ctx.send_help()
return
url = (
"http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}"
"".format(GIPHY_API_KEY, keywords)
url = "http://api.giphy.com/v1/gifs/random?&api_key={}&tag={}" "".format(
GIPHY_API_KEY, keywords
)
async with self.session.get(url) as r:

View File

@ -223,9 +223,7 @@ class Mod:
"Autoban for mention spam enabled. "
"Anyone mentioning {} or more different people "
"in a single message will be autobanned."
).format(
max_mentions
)
).format(max_mentions)
)
else:
cur_setting = await self.settings.guild(guild).ban_mention_spam()
@ -272,9 +270,7 @@ class Mod:
"Bot will delete command messages after"
" {} seconds. Set this value to -1 to"
" stop deleting messages"
).format(
delay
)
).format(delay)
)
else:
await ctx.send(_("I will not delete command messages."))
@ -511,9 +507,7 @@ class Mod:
_(
"You have been temporarily banned from {} until {}. "
"Here is an invite for when your ban expires: {}"
).format(
guild.name, unban_time.strftime("%m-%d-%Y %H:%M:%S"), invite
)
).format(guild.name, unban_time.strftime("%m-%d-%Y %H:%M:%S"), invite)
)
except discord.HTTPException:
msg = None
@ -580,9 +574,7 @@ class Mod:
"You have been banned and "
"then unbanned as a quick way to delete your messages.\n"
"You can now join the server again. {}"
).format(
invite
)
).format(invite)
)
except discord.HTTPException:
msg = None
@ -686,9 +678,7 @@ class Mod:
_(
"You've been unbanned from {}.\n"
"Here is an invite for that server: {}"
).format(
guild.name, invite.url
)
).format(guild.name, invite.url)
)
except discord.Forbidden:
await ctx.send(
@ -696,18 +686,14 @@ class Mod:
"I failed to send an invite to that user. "
"Perhaps you may be able to send it for me?\n"
"Here's the invite link: {}"
).format(
invite.url
)
).format(invite.url)
)
except discord.HTTPException:
await ctx.send(
_(
"Something went wrong when attempting to send that user"
"an invite. Here's the link so you can try: {}"
).format(
invite.url
)
).format(invite.url)
)
@staticmethod
@ -997,7 +983,8 @@ class Mod:
return False, mute_unmute_issues["hierarchy_problem"]
perms_cache[str(channel.id)] = {
"send_messages": overwrites.send_messages, "add_reactions": overwrites.add_reactions
"send_messages": overwrites.send_messages,
"add_reactions": overwrites.add_reactions,
}
overwrites.update(send_messages=False, add_reactions=False)
try:

View File

@ -75,11 +75,9 @@ class ModLog:
enabled = await casetype.is_enabled()
await casetype.set_enabled(True if not enabled else False)
msg = (
_("Case creation for {} actions is now {}.").format(
msg = _("Case creation for {} actions is now {}.").format(
action, "enabled" if not enabled else "disabled"
)
)
await ctx.send(msg)
@modlogset.command()

View File

@ -252,9 +252,7 @@ class Streams:
await ctx.send(
_(
"The Youtube API key is either invalid or has not been set. " "See {}."
).format(
"`{}streamset youtubekey`".format(ctx.prefix)
)
).format("`{}streamset youtubekey`".format(ctx.prefix))
)
return
except APIError:
@ -362,9 +360,7 @@ class Streams:
_(
"When a stream configured for stream alerts "
"comes online, {} will be mentioned"
).format(
"@\u200beveryone"
)
).format("@\u200beveryone")
)
@mention.command(aliases=["here"])
@ -384,9 +380,7 @@ class Streams:
_(
"When a stream configured for stream alerts "
"comes online, {} will be mentioned"
).format(
"@\u200bhere"
)
).format("@\u200bhere")
)
@mention.command()
@ -411,9 +405,7 @@ class Streams:
"When a stream configured for stream alerts "
"comes online, {} will be mentioned"
""
).format(
"@\u200b{}".format(role.name)
)
).format("@\u200b{}".format(role.name))
)
@streamset.command()
@ -458,9 +450,7 @@ class Streams:
"I'll send a notification in this channel when a "
"channel is streaming to the {} community"
""
).format(
community.name
)
).format(community.name)
)
else:
community.channels.remove(ctx.channel.id)
@ -471,9 +461,7 @@ class Streams:
"I won't send notifications about channels streaming "
"to the {} community in this channel anymore"
""
).format(
community.name
)
).format(community.name)
)
await self.save_communities()

View File

@ -266,7 +266,7 @@ class TwitchStream(Stream):
url = channel["url"]
logo = channel["logo"]
if logo is None:
logo = ("https://static-cdn.jtvnw.net/" "jtv_user_pictures/xarth/404_user_70x70.png")
logo = "https://static-cdn.jtvnw.net/" "jtv_user_pictures/xarth/404_user_70x70.png"
status = channel["status"]
if not status:
status = "Untitled broadcast"
@ -348,7 +348,7 @@ class MixerStream(Stream):
raise APIError()
def make_embed(self, data):
default_avatar = ("https://mixer.com/_latest/assets/images/main/" "avatars/default.jpg")
default_avatar = "https://mixer.com/_latest/assets/images/main/" "avatars/default.jpg"
user = data["user"]
url = "https://mixer.com/" + data["token"]
embed = discord.Embed(title=data["name"], url=url)

View File

@ -19,7 +19,7 @@ _FAIL_MESSAGES = (
)
class TriviaSession():
class TriviaSession:
"""Class to run a session of trivia with the user.
To run the trivia session immediately, use `TriviaSession.start` instead of
@ -216,9 +216,7 @@ class TriviaSession():
answers = tuple(s.lower() for s in answers)
def _pred(message: discord.Message):
early_exit = (
message.channel != self.ctx.channel or message.author == self.ctx.guild.me
)
early_exit = message.channel != self.ctx.channel or message.author == self.ctx.guild.me
if early_exit:
return False

View File

@ -228,9 +228,7 @@ class Warnings:
_(
"Custom reasons are not allowed! Please see {} for "
"a complete list of valid reasons"
).format(
"`{}reasonlist`".format(ctx.prefix)
)
).format("`{}reasonlist`".format(ctx.prefix))
)
return
reason_type = await self.custom_warning_reason(ctx)

View File

@ -21,7 +21,11 @@ class VersionInfo:
my_index = self._levels.index(self.releaselevel)
other_index = self._levels.index(other.releaselevel)
return (self.major, self.minor, self.micro, my_index, self.serial) < (
other.major, other.minor, other.micro, other_index, other.serial
other.major,
other.minor,
other.micro,
other_index,
other.serial,
)
def __repr__(self):

View File

@ -79,12 +79,10 @@ class RedBase(BotBase, RpcMethodMixin):
return global_prefix
server_prefix = await bot.db.guild(message.guild).prefix()
if cli_flags.mentionable:
return when_mentioned_or(*server_prefix)(
bot, message
) if server_prefix else when_mentioned_or(
*global_prefix
)(
bot, message
return (
when_mentioned_or(*server_prefix)(bot, message)
if server_prefix
else when_mentioned_or(*global_prefix)(bot, message)
)
else:
return server_prefix if server_prefix else global_prefix
@ -159,9 +157,8 @@ class RedBase(BotBase, RpcMethodMixin):
bool
:code:`True` if an embed is requested
"""
if (
isinstance(channel, discord.abc.PrivateChannel)
or (command and command == self.get_command("help"))
if isinstance(channel, discord.abc.PrivateChannel) or (
command and command == self.get_command("help")
):
user_setting = await self.db.user(user).embeds()
if user_setting is not None:

View File

@ -19,7 +19,7 @@ def is_owner(**kwargs):
async def check(ctx):
override = await check_overrides(ctx, level="owner")
return (override if override is not None else await ctx.bot.is_owner(ctx.author, **kwargs))
return override if override is not None else await ctx.bot.is_owner(ctx.author, **kwargs)
return commands.check(check)
@ -113,7 +113,7 @@ def guildowner_or_permissions(**perms):
is_guild_owner = ctx.author == ctx.guild.owner
override = await check_overrides(ctx, level="guildowner")
return (override if override is not None else is_guild_owner or has_perms_or_is_owner)
return override if override is not None else is_guild_owner or has_perms_or_is_owner
return commands.check(predicate)

View File

@ -348,8 +348,8 @@ class Core:
except Exception as e:
log.exception("Package loading failed", exc_info=e)
exception_log = (
"Exception in command '{}'\n" "".format(ctx.command.qualified_name)
exception_log = "Exception in command '{}'\n" "".format(
ctx.command.qualified_name
)
exception_log += "".join(
traceback.format_exception(type(e), e, e.__traceback__)
@ -434,9 +434,7 @@ class Core:
except Exception as e:
log.exception("Package reloading failed", exc_info=e)
exception_log = (
"Exception in command '{}'\n" "".format(ctx.command.qualified_name)
)
exception_log = "Exception in command '{}'\n" "".format(ctx.command.qualified_name)
exception_log += "".join(traceback.format_exception(type(e), e, e.__traceback__))
self.bot._last_exception = exception_log
@ -448,7 +446,7 @@ class Core:
await ctx.send(_(formed))
if failed_packages:
fmt = ("Failed to reload package{plural} {packs}. Check your " "logs for details")
fmt = "Failed to reload package{plural} {packs}. Check your " "logs for details"
formed = self.get_package_strings(failed_packages, fmt)
await ctx.send(_(formed))
@ -694,9 +692,7 @@ class Core:
"only do it up to 2 times an hour. Use "
"nicknames if you need frequent changes. "
"`{}set nickname`"
).format(
ctx.prefix
)
).format(ctx.prefix)
)
else:
await ctx.send(_("Done."))
@ -799,9 +795,7 @@ class Core:
" it is recommended to reset it right now. Go to the following link and"
" select `Reveal Token` and `Generate a new token?`."
"\n\nhttps://discordapp.com/developers/applications/me/{}"
).format(
self.bot.user.id
)
).format(self.bot.user.id)
)
return
@ -948,7 +942,7 @@ class Core:
else:
await ctx.send(_("Your message has been sent."))
else:
msg_text = ("{}\nMessage:\n\n{}\n{}".format(description, message, footer))
msg_text = "{}\nMessage:\n\n{}\n{}".format(description, message, footer)
try:
await owner.send("{}\n{}".format(content, box(msg_text)))
except discord.InvalidArgument:

View File

@ -214,7 +214,7 @@ def init_events(bot, cli_flags):
"logs for details."
"".format(ctx.command.qualified_name)
)
exception_log = ("Exception in command '{}'\n" "".format(ctx.command.qualified_name))
exception_log = "Exception in command '{}'\n" "".format(ctx.command.qualified_name)
exception_log += "".join(
traceback.format_exception(type(error), error, error.__traceback__)
)

View File

@ -110,9 +110,12 @@ class Help(formatter.HelpFormatter):
def get_ending_note(self):
# command_name = self.context.invoked_with
return "Type {0}help <command> for more info on a command.\n" "You can also type {0}help <category> for more info on a category.".format(
return (
"Type {0}help <command> for more info on a command.\n"
"You can also type {0}help <category> for more info on a category.".format(
self.clean_prefix
)
)
async def format(self) -> dict:
"""Formats command for output.

View File

@ -109,8 +109,8 @@ def _normalize(string, remove_newline=False):
"""Normalizes the whitespace in a string; \s+ becomes one space."""
if not s:
return str(s) # not the same reference
starts_with_space = (s[0] in " \n\t\r")
ends_with_space = (s[-1] in " \n\t\r")
starts_with_space = s[0] in " \n\t\r"
ends_with_space = s[-1] in " \n\t\r"
if remove_newline:
newline_re = re.compile("[\r\n]+")
s = " ".join(filter(bool, newline_re.split(s)))

View File

@ -36,9 +36,10 @@ class AntiSpam:
self.__discard_after = max([x.period for x in self.__intervals])
def __interval_check(self, interval: AntiSpamInterval):
return len(
[t for t in self.__event_timestamps if (t + interval.period) > datetime.utcnow()]
) >= interval.frequency
return (
len([t for t in self.__event_timestamps if (t + interval.period) > datetime.utcnow()])
>= interval.frequency
)
@property
def spammy(self):

View File

@ -235,8 +235,8 @@ def pagify(
while len(in_text) > page_length:
this_page_len = page_length
if escape_mass_mentions:
this_page_len -= (
in_text.count("@here", 0, page_length) + in_text.count("@everyone", 0, page_length)
this_page_len -= in_text.count("@here", 0, page_length) + in_text.count(
"@everyone", 0, page_length
)
closest_delim = (in_text.rfind(d, 1, this_page_len) for d in delims)
if priority:
@ -315,7 +315,5 @@ def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False)
text = text.replace("@everyone", "@\u200beveryone")
text = text.replace("@here", "@\u200bhere")
if formatting:
text = (
text.replace("`", "\\`").replace("*", "\\*").replace("_", "\\_").replace("~", "\\~")
)
text = text.replace("`", "\\`").replace("*", "\\*").replace("_", "\\_").replace("~", "\\~")
return text

View File

@ -52,9 +52,8 @@ async def menu(
RuntimeError
If either of the notes above are violated
"""
if (
not all(isinstance(x, discord.Embed) for x in pages)
and not all(isinstance(x, str) for x in pages)
if not all(isinstance(x, discord.Embed) for x in pages) and not all(
isinstance(x, str) for x in pages
):
raise RuntimeError("All pages must be of the same type")
for key, value in controls.items():

View File

@ -79,10 +79,10 @@ def get_audit_reason(author: discord.Member, reason: str = None):
The formatted audit log reason.
"""
return "Action requested by {} (ID {}). Reason: {}".format(
author, author.id, reason
) if reason else "Action requested by {} (ID {}).".format(
author, author.id
return (
"Action requested by {} (ID {}). Reason: {}".format(author, author.id, reason)
if reason
else "Action requested by {} (ID {}).".format(author, author.id)
)

View File

@ -356,16 +356,13 @@ def debug_info():
os_info = distro.linux_distribution()
osver = "{} {}".format(os_info[0], os_info[1]).strip()
user_who_ran = getpass.getuser()
info = "Debug Info for Red\n\n" + "Python version: {}\n".format(
pyver
) + "Red version: {}\n".format(
redver
) + "OS version: {}\n".format(
osver
) + "System arch: {}\n".format(
platform.machine()
) + "User: {}\n".format(
user_who_ran
info = (
"Debug Info for Red\n\n"
+ "Python version: {}\n".format(pyver)
+ "Red version: {}\n".format(redver)
+ "OS version: {}\n".format(osver)
+ "System arch: {}\n".format(platform.machine())
+ "User: {}\n".format(user_who_ran)
)
print(info)
exit(0)

View File

@ -6,3 +6,4 @@ colorama==0.3.9
aiohttp-json-rpc==0.8.7
pyyaml==3.12
Red-Trivia>=1.1.1
async-timeout<3.0.0

View File

@ -42,9 +42,7 @@ def get_version():
with open("redbot/core/__init__.py") as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
).group(
1
)
).group(1)
return version

View File

@ -156,7 +156,7 @@ def red(config_fr):
description = "Red v3 - Alpha"
Config.get_core_conf = (lambda *args, **kwargs: config_fr)
Config.get_core_conf = lambda *args, **kwargs: config_fr
red = Red(cli_flags, description=description, pm_help=None)