diff options
-rw-r--r-- | bot/exts/info/tags.py | 8 | ||||
-rw-r--r-- | bot/resources/tags/dashmpip.md | 1 | ||||
-rw-r--r-- | bot/resources/tags/f-strings.md | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py index 5d7467caf..83d3a9d93 100644 --- a/bot/exts/info/tags.py +++ b/bot/exts/info/tags.py @@ -82,6 +82,7 @@ class Tag: self.metadata = post.metadata self._restricted_to: set[int] = set(self.metadata.get("restricted_to", ())) self._cooldowns: dict[discord.TextChannel, float] = {} + self.aliases: list[str] = self.metadata.get("aliases", []) @property def embed(self) -> Embed: @@ -149,7 +150,11 @@ class Tags(Cog): # Files directly under `base_path` have an empty string as the parent directory name tag_group = parent_dir.name or None - self.tags[TagIdentifier(tag_group, tag_name)] = Tag(file) + tag = Tag(file) + self.tags[TagIdentifier(tag_group, tag_name)] = tag + + for alias in tag.aliases: + self.tags[TagIdentifier(tag_group, alias)] = tag def _get_suggestions(self, tag_identifier: TagIdentifier) -> list[tuple[TagIdentifier, Tag]]: """Return a list of suggested tags for `tag_identifier`.""" @@ -274,6 +279,7 @@ class Tags(Cog): if tag.accessible_by(ctx.author) ] + # Try exact match, includes checking through alt names tag = self.tags.get(tag_identifier) if tag is None and tag_identifier.group is not None: diff --git a/bot/resources/tags/dashmpip.md b/bot/resources/tags/dashmpip.md index 4c9f2870e..0dd866aeb 100644 --- a/bot/resources/tags/dashmpip.md +++ b/bot/resources/tags/dashmpip.md @@ -1,4 +1,5 @@ --- +aliases: ["minusmpip"] embed: title: "Install packages with `python -m pip`" --- diff --git a/bot/resources/tags/f-strings.md b/bot/resources/tags/f-strings.md index 5ccafe723..ab6ec75c9 100644 --- a/bot/resources/tags/f-strings.md +++ b/bot/resources/tags/f-strings.md @@ -1,3 +1,6 @@ +--- +aliases: ["fstrings", "fstring", "f-string"] +--- Creating a Python string with your variables using the `+` operator can be difficult to write and read. F-strings (*format-strings*) make it easy to insert values into a string. If you put an `f` in front of the first quote, you can then put Python expressions between curly braces in the string. ```py |