Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,31 @@ verify_ssl = true
name = "pypi"

[packages]
discord = {file = "https://github.com/Rapptz/discord.py/archive/rewrite.zip", egg = "discord.py[voice]"}
discord-py = {git = "https://github.com/Rapptz/discord.py.git", extras = ["voice"], ref = "860d6a9ace8248dfeec18b8b159e7b757d9f56bb", editable = true}
dulwich = "*"
multidict = "*"
sympy = "*"
aiodns = "*"
logmatic-python = "*"
aiohttp = "<2.3.0,>=2.0.0"
websockets = ">=4.0,<5.0"
aiohttp = "*"
sphinx = "*"
markdownify = "*"
lxml = "*"
pyyaml = "*"
yarl = "==1.1.1"
fuzzywuzzy = "*"
pillow = "*"
aio-pika = "*"
python-dateutil = "*"
deepdiff = "*"
requests = "*"

[dev-packages]
"flake8" = "*"
"flake8" = ">=3.6"
Comment thread
GhostofGoes marked this conversation as resolved.
"flake8-bugbear" = "*"
"flake8-import-order" = "*"
"flake8-tidy-imports" = "*"
"flake8-todo" = "*"
"flake8-string-format" = "*"
safety = "*"
dodgy = "*"
requests = "*"

[requires]
python_version = "3.6"
Expand Down
635 changes: 372 additions & 263 deletions Pipfile.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ variables:
PIPENV_HIDE_EMOJIS: 1
PIPENV_IGNORE_VIRTUALENVS: 1
PIPENV_NOSPIN: 1
PIPENV_VENV_IN_PROJECT: 1

jobs:
- job: test
displayName: 'Lint & Test'

pool:
vmImage: 'Ubuntu 16.04'

variables:
PIPENV_CACHE_DIR: ".cache/pipenv"
PIP_CACHE_DIR: ".cache/pip"
PIP_SRC: ".cache/src"

steps:
- script: sudo apt-get install build-essential curl docker libffi-dev libfreetype6-dev libxml2 libxml2-dev libxslt1-dev zlib1g zlib1g-dev
displayName: 'Install base dependencies'

- task: UsePythonVersion@0
displayName: 'Set Python version'
inputs:
versionSpec: '3.7.x'
addToPath: true
versionSpec: '3.7.x'
addToPath: true

- script: sudo pip install pipenv
displayName: 'Install pipenv'

- script: pipenv install --dev --deploy --system
displayName: 'Install project using pipenv'

- script: python -m flake8
displayName: 'Run linter'

- job: build
displayName: 'Build Containers'
dependsOn: 'test'

steps:
- task: Docker@1
displayName: 'Login: Docker Hub'
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def get_group_alias(self, ctx):

@get_group_alias.command(name="tags", aliases=("tag", "t"), hidden=True)
async def tags_get_alias(
self, ctx: Context, *, tag_name: TagNameConverter=None
self, ctx: Context, *, tag_name: TagNameConverter = None
):
"""
Alias for invoking <prefix>tags get [tag_name].
Expand Down
6 changes: 3 additions & 3 deletions bot/cogs/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ async def on_message(self, msg: Message):
howto = (
"It looks like you are trying to paste code into this channel.\n\n"
"You seem to be using the wrong symbols to indicate where the codeblock should start. "
f"The correct symbols would be \`\`\`, not `{ticks}`.\n\n"
f"The correct symbols would be \\`\\`\\`, not `{ticks}`.\n\n"
"**Here is an example of how it should look:**\n"
f"\`\`\`python\n{content}\n\`\`\`\n\n**This will result in the following:**\n"
f"\\`\\`\\`python\n{content}\n\\`\\`\\`\n\n**This will result in the following:**\n"
f"```python\n{content}\n```"
)

Expand Down Expand Up @@ -329,7 +329,7 @@ async def on_message(self, msg: Message):
"syntax highlighting. Please use these whenever you paste code, as this "
"helps improve the legibility and makes it easier for us to help you.\n\n"
f"**To do this, use the following method:**\n"
f"\`\`\`python\n{content}\n\`\`\`\n\n**This will result in the following:**\n"
f"\\`\\`\\`python\n{content}\n\\`\\`\\`\n\n**This will result in the following:**\n"
f"```python\n{content}\n```"
)

Expand Down
9 changes: 4 additions & 5 deletions bot/cogs/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def _format(self, inp, out): # (str, Any) -> (str, discord.Embed)
res = (res, out)

else:
if (isinstance(out, str) and
out.startswith("Traceback (most recent call last):\n")):
if (isinstance(out, str) and out.startswith("Traceback (most recent call last):\n")):
Comment thread
MarkKoz marked this conversation as resolved.
# Leave out the traceback message
out = "\n" + "\n".join(out.split("\n")[1:])

Expand All @@ -115,9 +114,9 @@ def _format(self, inp, out): # (str, Any) -> (str, discord.Embed)
# Text too long, shorten
li = pretty.split("\n")

pretty = ("\n".join(li[:3]) + # First 3 lines
"\n ...\n" + # Ellipsis to indicate removed lines
"\n".join(li[-3:])) # last 3 lines
pretty = ("\n".join(li[:3]) # First 3 lines
Comment thread
GhostofGoes marked this conversation as resolved.
+ "\n ...\n" # Ellipsis to indicate removed lines
+ "\n".join(li[-3:])) # last 3 lines

# Add the output
res += pretty
Expand Down
8 changes: 4 additions & 4 deletions bot/cogs/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ async def on_ready(self):

async def on_member_update(self, before: Member, after: Member):
if (
before.roles == after.roles and
before.name == after.name and
before.discriminator == after.discriminator and
before.avatar == after.avatar):
before.roles == after.roles
and before.name == after.name
and before.discriminator == after.discriminator
and before.avatar == after.avatar):
return

before_role_names = [role.name for role in before.roles] # type: List[str]
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
r"([a-zA-Z0-9]+)" # the invite code itself
)

URL_RE = "(https?://[^\s]+)"
URL_RE = r"(https?://[^\s]+)"
ZALGO_RE = r"[\u0300-\u036F\u0489]"
RETARDED_RE = r"(re+)tar+(d+|t+)(ed)?"
SELF_DEPRECATION_RE = fr"((i'?m)|(i am)|(it'?s)|(it is)) (.+? )?{RETARDED_RE}"
Expand Down
4 changes: 2 additions & 2 deletions bot/cogs/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ async def delete_tag_data(self, tag_name: str) -> dict:
return tag_data

@group(name='tags', aliases=('tag', 't'), hidden=True, invoke_without_command=True)
async def tags_group(self, ctx: Context, *, tag_name: TagNameConverter=None):
async def tags_group(self, ctx: Context, *, tag_name: TagNameConverter = None):
"""Show all known tags, a single tag, or run a subcommand."""

await ctx.invoke(self.get_command, tag_name=tag_name)

@tags_group.command(name='get', aliases=('show', 'g'))
async def get_command(self, ctx: Context, *, tag_name: TagNameConverter=None):
async def get_command(self, ctx: Context, *, tag_name: TagNameConverter = None):
"""
Get a list of all tags or a specified tag.

Expand Down
6 changes: 3 additions & 3 deletions bot/cogs/wolfram.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
async def send_embed(
ctx: Context,
message_txt: str,
colour: int=Colours.soft_red,
footer: str=None,
img_url: str=None,
colour: int = Colours.soft_red,
footer: str = None,
img_url: str = None,
f: discord.File = None
) -> None:
"""
Expand Down
12 changes: 6 additions & 6 deletions bot/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def add_line(self, line='', *, empty=False):
@classmethod
async def paginate(cls, lines: Iterable[str], ctx: Context, embed: Embed,
prefix: str = "", suffix: str = "", max_lines: Optional[int] = None, max_size: int = 500,
empty: bool = True, restrict_to_user: User = None, timeout: int=300,
empty: bool = True, restrict_to_user: User = None, timeout: int = 300,
footer_text: str = None):
"""
Use a paginator and set of reactions to provide pagination over a set of lines. The reactions are used to
Expand Down Expand Up @@ -129,9 +129,9 @@ def event_check(reaction_: Reaction, user_: Member):

no_restrictions = (
# Pagination is not restricted
not restrict_to_user or
not restrict_to_user
# The reaction was by a whitelisted user
user_.id == restrict_to_user.id
or user_.id == restrict_to_user.id
)

return (
Expand Down Expand Up @@ -291,7 +291,7 @@ def __init__(self, prefix="", suffix=""):
self.images = []
self._pages = []

def add_line(self, line: str='', *, empty: bool=False) -> None:
def add_line(self, line: str = '', *, empty: bool = False) -> None:
"""
Adds a line to each page, usually just 1 line in this context
:param line: str to be page content / title
Expand All @@ -305,7 +305,7 @@ def add_line(self, line: str='', *, empty: bool=False) -> None:
self._current_page.append(line)
self.close_page()

def add_image(self, image: str=None) -> None:
def add_image(self, image: str = None) -> None:
"""
Adds an image to a page
:param image: image url to be appended
Expand All @@ -315,7 +315,7 @@ def add_image(self, image: str=None) -> None:

@classmethod
async def paginate(cls, pages: List[Tuple[str, str]], ctx: Context, embed: Embed,
prefix: str="", suffix: str="", timeout: int=300):
prefix: str = "", suffix: str = "", timeout: int = 300):
"""
Use a paginator and set of reactions to provide
pagination over a set of title/image pairs.The reactions are
Expand Down
6 changes: 3 additions & 3 deletions bot/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ async def disambiguate(
choices = (f'{index}: {entry}' for index, entry in enumerate(entries, start=1))

def check(message):
return (message.content.isdigit() and
message.author == ctx.author and
message.channel == ctx.channel)
return (message.content.isdigit()
and message.author == ctx.author
and message.channel == ctx.channel)

try:
if embed is None:
Expand Down
10 changes: 5 additions & 5 deletions bot/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
async def wait_for_deletion(
message: Message,
user_ids: Sequence[Snowflake],
deletion_emojis: Sequence[str]=("❌",),
timeout: float=60 * 5,
deletion_emojis: Sequence[str] = ("❌",),
timeout: float = 60 * 5,
attach_emojis=True,
client=None
):
Expand Down Expand Up @@ -62,9 +62,9 @@ async def wait_for_deletion(

def check(reaction, user):
return (
reaction.message.id == message.id and
reaction.emoji in deletion_emojis and
user.id in user_ids
reaction.message.id == message.id
and reaction.emoji in deletion_emojis
and user.id in user_ids
)

with contextlib.suppress(asyncio.TimeoutError):
Expand Down
28 changes: 14 additions & 14 deletions bot/utils/snakes/hatching.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
h1 = '''```
h1 = r'''```
Comment thread
GhostofGoes marked this conversation as resolved.
----
------
/--------\\
/--------\
|--------|
|--------|
\------/
----```'''

h2 = '''```
h2 = r'''```
----
------
/---\\-/--\\
|-----\\--|
/---\-/--\
|-----\--|
|--------|
\------/
----```'''

h3 = '''```
h3 = r'''```
----
------
/---\\-/--\\
|-----\\--|
/---\-/--\
|-----\--|
|-----/--|
\----\\-/
\----\-/
----```'''

h4 = '''```
h4 = r'''```
-----
----- \\
/--| /---\\
|--\\ -\\---|
|--\\--/-- /
----- \
/--| /---\
|--\ -\---|
|--\--/-- /
\------- /
------```'''

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
max-line-length=120
application_import_names=bot
exclude=.venv
exclude=.cache,.venv
ignore=B311,W503,E226,S311
import-order-style=pycharm