tldr-bot
tldr-bot copied to clipboard
proposal: /commands (set-more-info-link in particular)
I recently wrote a Python script, set-more-info-link.py (https://github.com/tldr-pages/tldr/pull/5654) that takes a page in the format platform/page.md and a link, and adds/updates the link in the page and all translations using a map of the approprate labels.
I was thinking just now that it might be nice to be able to, in a PR, comment something like
@tldr-bot /set-more-info-link common/page.md "https://example.com"
whereupon the bot (@tldr-bot) ran set-more-info-link.py with those arguments, committed the changes to the PR, maybe the message could be like
page: update more information link
If this were approved, I'd be happy to work on it.
That's a nice idea! Could be convenient.
Security must be central to the implementation though. @tldr-bot should check to make sure that the user executing the command actually permission to do so on that particular PR.
How does it handle these cases?
- Pages in other languages
- Pages that already have a more information link
- Pages with invalid syntax (i.e. invalid syntax that tldr-bot has previously commented on
@tldr-bot should check to make sure that the user executing the command actually permission to do so on that particular PR.
Definitely. Would be very simple to ensure.
- Pages in other languages.
The script applies the appropriate label for the language the page is in. See here
- Pages that already have a more information link
The script overwrites the existing link in the pages that already have one, and adds it to pages that don't.
- Pages with invalid syntax (i.e. invalid syntax that tldr-bot has previously commented on
I'm not sure how the script would react to that. It finds were to insert/modify the line by checking for > at the beginning; in most cases it would probably be fine. We could also perhaps check if there is a comment (maybe non-hidden?) by @tldr-bot and if there are any commits after it, run the script, otherwise stop.
@sbrl keep in mind that we already have a script that does this (https://github.com/tldr-pages/tldr/pull/5654), but the issue with it that I see is that it's somewhat cumbersome to use, and contributors need Python installed, and it would be really inconvenient to have to install Python just to change some links.
Cool, that sounds sensible - just wanted to check some edge cases there. I can definitely see the appeal of adding this to the tldr-bot. I would suggest a check that if the GitHub actions have failed on the target PR, then it does not attempt to make a change. If the GitHub actions are in progress, it reschedules the check for say 5 minutes time, but that might be complex to program.