filipre / signalbot

Micro framework to create your own signal bots.
MIT License
108 stars 23 forks source link

Add styling options to text #41

Open mariopaolo opened 9 months ago

mariopaolo commented 9 months ago

wanna start off saying this tool is amazing, I love it and use signalbot every day 😀

I would like to know if it's possible to support text styling in signalbot when sending messages. I see signal-cli correctly registers the current text styling, here an example:

INFO:root:[Raw Message] {"envelope":{"source":"+XXXXXXXXXXXX", "sourceNumber":"+XXXXXXXXXXXX", "sourceUuid":"mySourceUuid", "sourceName":"user", "sourceDevice":1,"timestamp":1703357219298, "dataMessage": {"timestamp":1703357219298, "message":"MESSAGE", "expiresInSeconds":0, "viewOnce":false, "textStyles":[{"style":"ITALIC", "start":0, "length":5}], "groupInfo":{"groupId": "myGroupID", "type":"DELIVER"}}}, "account": "+YYYYYYYYYYYY"}
"textStyles":[{"style":"ITALIC", "start":0, "length":5}]

but I can't seem to be able to set it in signalbot and cant find any reference in bot.py https://github.com/filipre/signalbot/blob/71e09a1f96362d24ae3747a98ce3caecc29cdc9d/signalbot/bot.py#L174-L204

in signal-cli-rest-api there is a way to pass style to text in the API call https://bbernhard.github.io/signal-cli-rest-api/#/Messages/post_v2_send

Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: italic text, bold text, ~strikethrough text~.

is there a way to do the same in signalbot and I just can't find it, or this would need to be implemented?

thanks again for the amazing tool!

filipre commented 9 months ago

I'm glad you like it! At the moment, styling is not supported, but it should be easy to add. Feel free to open a PR. I can also take a look a bit later.

mariopaolo commented 9 months ago

hey @filipre I just created a pull request here https://github.com/filipre/signalbot/pull/42 I tested it and it works but be gentle though, this is my first pull request 😅 if there is any problem let me know

filipre commented 9 months ago

Thanks a lot! For anyone who wants to give it a test before the release, feel free to checkout https://github.com/filipre/signalbot/pull/42#issuecomment-1871503288

discernica commented 3 weeks ago

(Nice to find the project, I am migrating my bot away from Telegram Bot) I think I'm almost there with styling, but maybe I'm not understanding the implementation.

In the examples folder the "styles.py" file the text is entirely surrounded by the marker characters, but I'd like something like:

Anyway, the results are strange and the styling is, well, off -- and seemingly random. Does this mean the entire text message must be completely styled one-way?