python-discord / bot

The community bot for the Python Discord community
https://pythondiscord.com
MIT License
1.3k stars 652 forks source link

Arrange tags in sub-directories to utilise the group feature from `tags.py` #2423

Open Ibrahim2750mi opened 1 year ago

Ibrahim2750mi commented 1 year ago

According to these lines

# Files directly under `base_path` have an empty string as the parent directory name
tag_group = parent_dir.name or None

tag_group will be None until the tag is in a sub-directory inside bot/resources/tags/ eg: bot/resources/tags/fstring/fstring.md and currently we don't have sub-directories in the folder.

Moving them to sub-directories might also solve #2345 as then the aliases will be listed as bullets under the directory name eg: 2023-03-02_03-41 NOTE: I have kept the directories name as same as the .md(s) here, it could look a lot better if used correct names in parent bullet.

My suggestion is either we nuke them or sort the tags in the directory to use the group functionality of the code.

janine9vn commented 1 year ago

The intent was to sort tags into groups and sub-directories but no one has taken it up yet. I'm firmly against removing this feature just because we haven't used it yet.

For instance, all the d.py related tags can go into a subdirectory, it just requires someone making that PR

Ibrahim2750mi commented 1 year ago

This is the reason I made the issue(if there already an issue for this, then I am sorry), I could sort them up in the sub-directories.

But first I think we need to finalise the groups we are going to have. I am thinking something along these lines.

I feel like there can be more groups added to lighten up python-beginner-syntax. Help to suggest group names is appreciated.

janine9vn commented 1 year ago

I don't think we need to create groups for every single tag or for most tags. Any additional grouping we add means you need an additional term to invoke it. With your proposal, calling the pep8 tag would be !python-environment pep-8. So I want to really avoid grouping things just to group them, there should be a natural purpose to it besides "we're not using this code feature yet." The purpose behind groups was to avoid cluttering the namespace and avoid conflicts around calling tags, so that should still be kept in mind.

For me, the group names that make sense are:

Also, I don't believe this solves the aliases being listed issue. It just sorts the duplicated names for tags, it doesn't reduce the total clutter or duplicate-nature of it.

There is an existing issue for utilizing the tag groups as well for some specific tags: https://github.com/python-discord/bot/issues/1835

Side note: it seems the slash command for tags wasn't tested with tag groups, because the functionality of tag groups has been changed and is no longer really working. It was working when I was testing it with the alias feature though.

Ibrahim2750mi commented 1 year ago

Can't we do something like we only require the group name for triggering some specific group tags, an example would be dpy and use the other groups to list the tags in the embed more cleanly? We can check if the tag.group is an enforced(enforced meaning it would require the user to add the group name before the tag to invoke it) group if not then it can be triggered by both !group tag and !tag? For dpy we can make it an enforced group.

Also for the slash commands I think we can make it probably ignore all the groups and use the tag name directly.

janine9vn commented 1 year ago

I like the idea of having an enforceable tag group vs not. It lets us keep things a bit organized without sacrificing fast tag invoking, but if needed we can still de-conflict tag invocations. Will probably need a core dev weigh in as it changes the original scope/intent of the feature.

I think the slash command should match whatever the !tag does, just for consistency. It would feel weird to have the two ways to invoke a tag be different.

Ibrahim2750mi commented 1 year ago

I think we are on the same page now.

RohanJnr commented 1 year ago

Currently, the new /tag command has the syntax: /tag name:<group_name> <tag_name>. To use a tag from a group, group name has to be mentioned. This could be quite unintuitive to always enter the group name for a simple tag search. Incase if we are enforcing group name, lets try to keep them as simple as possible and short as possible. Another approach would be to invoke a tag regardless of its group. Incase there are tags with the same name in multiple groups, the user will be prompted to choose from one group (using buttons here would be nice).

Also, do we want to categorize tags on the site into different urls? I believe with the current implementation on the site, tag groups will be listed as folders on the site and tags inside them. https://github.com/python-discord/site/pull/763

HassanAbouelela commented 1 year ago

As Janine pointed out, the tag functionality was greatly reduced with the slash command migration. I’m guessing slash commands don’t allow you to enter invalid commands? That is in part how we were handling tag matching before slash commands (its in the error handler).

If we can’t reimplement this flexibility with the slash-commands, then I don’t think this is a good use case for them, and we might be better off reverting these changes. Slash command benefits don’t outweigh the flexibility.

RohanJnr commented 1 year ago

I’m guessing slash commands don’t allow you to enter invalid commands? slash commands are kinda gimmicky, like you have to explicitely tell discord that you are providing a value for the name argument and only then the error handling takes place image

In the case below, discord correctly parses the name argument image

sometimes it just doesn't image