aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Andi Qu <[email protected]>2020-07-05 20:54:55 +0200
committerGravatar Andi Qu <[email protected]>2020-07-05 20:54:55 +0200
commit2fe46fd372a5c8a69437e3f29c0137cb11d156d9 (patch)
tree0a19a60bf544521bd05e7e3ef124c8b3e55aa744
parentTried to fix some of the flake8 style errors (diff)
Fixed all docstrings
-rw-r--r--bot/cogs/print_snippets.py14
-rw-r--r--bot/cogs/repo_widgets.py20
2 files changed, 17 insertions, 17 deletions
diff --git a/bot/cogs/print_snippets.py b/bot/cogs/print_snippets.py
index 4be3653d5..5c83cd62b 100644
--- a/bot/cogs/print_snippets.py
+++ b/bot/cogs/print_snippets.py
@@ -10,7 +10,7 @@ from bot.bot import Bot
async def fetch_http(session: aiohttp.ClientSession, url: str, response_format: str, **kwargs) -> str:
- """Uses aiohttp to make http GET requests"""
+ """Uses aiohttp to make http GET requests."""
async with session.get(url, **kwargs) as response:
if response_format == 'text':
return await response.text()
@@ -19,21 +19,21 @@ async def fetch_http(session: aiohttp.ClientSession, url: str, response_format:
async def revert_to_orig(d: dict) -> dict:
- """Replace URL Encoded values back to their original"""
+ """Replace URL Encoded values back to their original."""
for obj in d:
if d[obj] is not None:
d[obj] = d[obj].replace('%2F', '/').replace('%2E', '.')
async def orig_to_encode(d: dict) -> dict:
- """Encode URL Parameters"""
+ """Encode URL Parameters."""
for obj in d:
if d[obj] is not None:
d[obj] = d[obj].replace('/', '%2F').replace('.', '%2E')
async def snippet_to_embed(d: dict, file_contents: str) -> str:
- """Given a regex groupdict and file contents, creates a code block"""
+ """Given a regex groupdict and file contents, creates a code block."""
if d['end_line']:
start_line = int(d['start_line'])
end_line = int(d['end_line'])
@@ -85,9 +85,9 @@ BITBUCKET_RE = re.compile(
class PrintSnippets(Cog):
"""
- Cog that prints out snippets to Discord
+ Cog that prints out snippets to Discord.
- Matches each message against a regex and prints the contents of all matched snippets
+ Matches each message against a regex and prints the contents of all matched snippets.
"""
def __init__(self, bot: Bot):
@@ -97,7 +97,7 @@ class PrintSnippets(Cog):
@Cog.listener()
async def on_message(self, message: Message) -> None:
- """Checks if the message starts is a GitHub snippet, then removes the embed, then sends the snippet in Discord"""
+ """Checks if the message has a snippet link, removes the embed, then sends the snippet contents."""
gh_match = GITHUB_RE.search(message.content)
gh_gist_match = GITHUB_GIST_RE.search(message.content)
gl_match = GITLAB_RE.search(message.content)
diff --git a/bot/cogs/repo_widgets.py b/bot/cogs/repo_widgets.py
index feb931e72..c8fde7c8e 100644
--- a/bot/cogs/repo_widgets.py
+++ b/bot/cogs/repo_widgets.py
@@ -9,7 +9,7 @@ from bot.bot import Bot
async def fetch_http(session: aiohttp.ClientSession, url: str, response_format: str, **kwargs) -> str:
- """Uses aiohttp to make http GET requests"""
+ """Uses aiohttp to make http GET requests."""
async with session.get(url, **kwargs) as response:
if response_format == 'text':
return await response.text()
@@ -18,7 +18,7 @@ async def fetch_http(session: aiohttp.ClientSession, url: str, response_format:
async def orig_to_encode(d: dict) -> dict:
- """Encode URL Parameters"""
+ """Encode URL Parameters."""
for obj in d:
if d[obj] is not None:
d[obj] = d[obj].replace('/', '%2F').replace('.', '%2E')
@@ -33,19 +33,19 @@ GITLAB_RE = re.compile(
class RepoWidgets(Cog):
"""
- Cog that sends pretty embeds of repos
+ Cog that sends pretty embeds of repos.
- Matches each message against a regex and sends an embed with the details of all referenced repos
+ Matches each message against a regex and sends an embed with the details of all referenced repos.
"""
def __init__(self, bot: Bot):
- """Initializes the cog's bot"""
+ """Initializes the cog's bot."""
self.bot = bot
self.session = aiohttp.ClientSession()
@Cog.listener()
async def on_message(self, message: Message) -> None:
- """Checks if the message starts is a GitHub repo link, then removes the embed, then sends a rich embed to Discord"""
+ """Checks if the message has a repo link, removes the embed, then sends a rich embed."""
gh_match = GITHUB_RE.search(message.content)
gl_match = GITLAB_RE.search(message.content)
@@ -69,10 +69,10 @@ class RepoWidgets(Cog):
url=repo['html_url'],
color=0x111111
).set_footer(
- text=f'Language: {repo["language"]} | ' +
- f'Stars: {repo["stargazers_count"]} | ' +
- f'Forks: {repo["forks_count"]} | ' +
- f'Size: {repo["size"]}kb'
+ text=f'Language: {repo["language"]} | '
+ + f'Stars: {repo["stargazers_count"]} | '
+ + f'Forks: {repo["forks_count"]} | '
+ + f'Size: {repo["size"]}kb'
).set_thumbnail(url=repo['owner']['avatar_url'])
if repo['homepage']:
embed.add_field(name='Website', value=repo['homepage'])