TJ-Bot icon indicating copy to clipboard operation
TJ-Bot copied to clipboard

Bot code detection on non-code-boxes or files

Open MrMystery10-del opened this issue 3 years ago • 4 comments

A possible improvement for the code-detection feature is to make it recognize code snippets in plain text messages, not only in files or pre-formatted code blocks.

This would save time and effort for both the helpers and the users who need help with their code. Instead of instructing the users how to format their code properly, the bot could automatically suggest them to do so when they send their code as plain text.

Here for example the code is already formatted by the user: Screenshot 2023-10-24 105151 And the bot still recommends to format it: Screenshot 2023-10-24 105210

But now if the code is not formatted and is just plain text, the bot does not recommend to formatt it: Screenshot 2023-10-24 105434

Of course i do talk more about the highlight and not the line breaks because that it more important to read the code easy

MrMystery10-del avatar Oct 24 '23 09:10 MrMystery10-del

valid suggestion, but unsure how you would detect such code. its not trivial at all and we had attempts to do so in the past, but it wasnt really giving good results.

instead, we added the code-actions command (right click a message, select code-actions). that spawns the format-dialog on-demand.

Zabuzard avatar Oct 24 '23 10:10 Zabuzard

also note that the dialog is not only suggesting format. it will (soon) also suggest running code. so it should not only be spawned on badly formatted code, but on any code snippet

Zabuzard avatar Oct 24 '23 10:10 Zabuzard

Well we could create a small parser that validates the token-combinations, identifies the code boundaries, and uses the rest of the text as a header

MrMystery10-del avatar Oct 24 '23 10:10 MrMystery10-del

It has been attempted already with unsatisfying results. But sure, its valid and someone can feel free to attempt it.

Zabuzard avatar Oct 24 '23 11:10 Zabuzard