Kneemund / previewBOT

A Discord bot written in Rust for sending file previews of GitHub URLs and for juxtaposing images.
https://previewbot.kneemund.de/invite
Mozilla Public License 2.0
1 stars 0 forks source link

Improve Github preview message #2

Open ChiefArug opened 2 months ago

ChiefArug commented 2 months ago

First of all, very cool bot! I'm used to message preview bots but this is building on that and definitely a cool addition.

Currently it is a bit awkward with the full commit hash in the message, which is very long and often causes slightly odd line wrapping when you aren't using maximized desktop discord, which is why git and github typically only display the first 6 characters. It would also be nice to have more links in there, like the file path selector github has when viewing a file.

Something like: TelepaticGrunt/Bumblezone:c2d25d common/src/main/resources/assets/the_bumblezone/sounds.json#450

405 |   "entity.the_bumblezone.bee_queen.happy": {

(side note, since when has githubs json syntax highlighter had syntax errors)

where each clickable section goes to where you expect it to.

This is a bit long in terms of raw character count (see below), but if it starts to not fit in discords character limit then you can replace the commit hash with the short hash (first 6 chars) and github will still resolve it into the full hash!

[TelepaticGrunt](<https://github.com/TelepathicGrunt>)/[Bumblezone](<https://github.com/TelepathicGrunt/Bumblezone>):[c2d25d](<https://github.com/TelepathicGrunt/Bumblezone/commit/c2d25d19155a2b4ba6307aa730a297970e94f2f2>)
[common](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/>)/[src](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/>)/[main](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/main/>)/[resources](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/main/resources/>)/[assets](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/main/resources/assets/>)/[the_bumblezone](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/main/resources/assets/the_bumblezone>)/[sounds.json#450](<https://github.com/TelepathicGrunt/Bumblezone/blob/c2d25d19155a2b4ba6307aa730a297970e94f2f2/common/src/main/resources/assets/the_bumblezone/sounds.json#L405>)
```json
405 |   "entity.the_bumblezone.bee_queen.happy": {
ChiefArug commented 2 months ago

Looks like github uses the first 7 chars of the commit hash, not the first 6 whoops. Everything still applies though.

Kneemund commented 1 month ago

Thanks for the kind words and sorry for the late reply. Using the short hash in the message header seems like a good improvement, I'll work on that soon.

Adding hyperlinks to all sections of the URL also sounds good. Unfortunately, Discord mobile doesn't support file previews, so I'd like to keep the character count of the header to a minimum. That way, the content is more likely to fit into the character limit (and doesn't need to be appended as a file). Like you already said, all the hyperlinks would significantly increase the character count, and using the short hash in the URLs probably wouldn't help much.