colorcodebot icon indicating copy to clipboard operation
colorcodebot copied to clipboard

Parse snippet format

Open MarkParker5 opened this issue 1 year ago • 4 comments

  1. Use regex to parse single-line snippets inside ` and multi-line snippets inside ``` instead of highlighting entire message
  2. Automatically parse language in multi-line snippets if it's specified e.g. ``` python print('Hello') ```

MarkParker5 avatar Aug 31 '23 12:08 MarkParker5

Thanks for the issue!

I'm away from my computer from a few days and will look more closely later.

For now I'll point out that if you add the bot to a chat, it behaves as number 1 (only processes the monospace content).

AndydeCleyre avatar Sep 01 '23 15:09 AndydeCleyre

  • For number two, I don't think the message object distinguishes between a fenced code block with the language specified in that style and a fenced code block whose first line happens to be a language name.

  • For number one, have you tried adding the bot to the group? This is my recommended usage model, and should already work the way you're after.

AndydeCleyre avatar Sep 07 '23 15:09 AndydeCleyre

I haven't tried adding a bot to a group, only in direct messages. Just mentioned features for improvements

MarkParker5 avatar Sep 07 '23 17:09 MarkParker5

Regarding the second issue here:

It looks like Telegram Desktop will soon support that natively.

I have not yet looked further into whether the bot can distinguish between a syntax specifier and a first line of code content.


Regarding the first:

The behavior requested is already the currently behavior when using the bot added to a group. But if you don't have permission or prefer not to add it to a group, you can achieve what you want by creating a new chat with just you and the bot. Then interact with that chat as if it were the bot chat. Any message sent will have only the monospaced portion of the content processed.

One use case of the bot is to syntax-highlight a message from someone else who didn't bother to monospace the content. Currently the most convenient way is to forward the message to the bot. I don't want to remove that flow unless a similarly convenient alternative flow for that can be suggested.

AndydeCleyre avatar Oct 08 '23 04:10 AndydeCleyre