diff options
| -rw-r--r-- | arthur/exts/fun/devops_rules.py | 18 | 
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)  |