AndydeCleyre / colorcodebot

A simple Telegram bot for syntax highlighting
The Unlicense
46 stars 6 forks source link

Parse snippet format #45

Closed MarkParker5 closed 3 weeks ago

MarkParker5 commented 1 year ago
  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') ```
AndydeCleyre commented 1 year ago

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 commented 1 year ago
MarkParker5 commented 1 year ago

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

AndydeCleyre commented 12 months ago

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 commented 3 weeks ago

OK, number 2 is now implemented, please give it a try!

The entire message is only highlighted if you send it directly to the bot, as a convenience so you don't have to monospace it. There's no reason to send anything to the bot you don't want highlighted.

When added to a group, which is recommended, it does already indeed parse messages for just the monospace substrings.

So I'm going to close this issue, but please let me know if the behavior is not satisfactory for some reason.