Open thinko opened 10 years ago
As far as I know, WhatsApp does not support ANSI escape codes, so yes: ideally they should be stripped before sending to WA.
After a quick googling, this python snippet should be able to remove any ANSI escape code in a string: http://stackoverflow.com/a/2187024
The exact point of BreakBot in which that snippet should be inserted & adapted would be: https://github.com/stenyak/breakbot/blob/master/wa_bot.py#L130
(specifically, the "text" variable is what needs to be un-escaped)
Could you please test if that works for your use cases?
Thanks for the report.
Need to scrape the incoming IRC messages and strip the ASCII codes used for color and other formatting when bringing across to Whatsapp.
I'm guessing should be some simple regex like: import re // regex = re.compile("\x0f|\x1f|\x02|\x03(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE) regex.sub('', msg)
Right now, the ascii shows up in Whatsapp like this: