aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-07-25 20:29:28 +0100
committerGravatar Chris Lovering <[email protected]>2024-07-25 20:29:28 +0100
commitbe23270bd3949214d5dbeb139284e29af0f0543d (patch)
tree106ed1f87418e932d3ca273b10556165456cd913
parentfix(deps): update dependency sentry-sdk to v2.11.0 (#242) (diff)
Fix the rules command now that the source file is an rst file
-rw-r--r--arthur/exts/fun/devops_rules.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/arthur/exts/fun/devops_rules.py b/arthur/exts/fun/devops_rules.py
index 14bccde..5041395 100644
--- a/arthur/exts/fun/devops_rules.py
+++ b/arthur/exts/fun/devops_rules.py
@@ -5,7 +5,7 @@ from discord.ext.commands import Cog, Context, Greedy, group
from arthur.bot import KingArthur
-RULES_URL = "https://raw.githubusercontent.com/python-discord/infra/main/docs/content/docs/onboarding/rules.md"
+RULES_URL = "https://raw.githubusercontent.com/python-discord/infra/main/docs/onboarding/rules.rst"
class Rules(Cog):
@@ -21,12 +21,18 @@ class Rules(Cog):
resp.raise_for_status()
raw_content = await resp.text()
# Ignore markdown frontmatter
- parsed_content = raw_content.split("---")[-1].strip()
- # Ignore first 4 lines, as they are not the rules
- parsed_content = parsed_content.split("\n")[4:]
+ parsed_content = raw_content.split("=====")[-1].strip()
+ # Ignore first 3 lines, as they are not the rules
+ parsed_content = parsed_content.split("\n", maxsplit=2)[2]
+ # Split on periods to get each rule, and hope we never use periods in our rules.
+ parsed_content = parsed_content.split(".")[1:]
self.rules = {}
- for line in parsed_content:
- number, rule = line.split(".", maxsplit=1)
+ for number, raw_rule in enumerate(parsed_content, 1):
+ # Drop extra newlines, backslashes that were added for sphinx
+ rule = raw_rule.replace("\n", "").replace(r"\ ", "")
+ if rule[-1].isdecimal():
+ # Drop the last character, if it is the index of the next rule.
+ rule = rule[:-1]
self.rules[int(number)] = rule.strip()
@group(name="rules", aliases=("rule",), invoke_without_command=True)