pydle icon indicating copy to clipboard operation
pydle copied to clipboard

Any way to handle message formatting? (colors etc.)

Open la55u opened this issue 7 years ago • 2 comments

Maybe I'm missing something but currently I can't seem to figure out how to get the messages without the leftover from the formatting. All I did was adding a print(message) line to the 'Basic Usage' example's on_message method and enter a channel that's full of formatting. Here's the output: https://i.imgur.com/kqRVlmG.png It does leave the color codes in the message. For example the 04 is red etc. What should I do to get only the plain text message without any type of formatting? (colors, bold, italic etc.)

I found an answer elsewhere on how to strip the colors, but I'm not sure where to apply it: regex = re.compile("\x1f|\x02|\x12|\x0f|\x16|\x03(?:\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)

Thank you.

la55u avatar Jun 09 '18 09:06 la55u

Given that regexp, you'd run message = regex.sub(message, '') on the message. I'm not sure if we want to support complete message stripping like that in Pydle itself, however.

shizmob avatar Aug 05 '18 02:08 shizmob

I don't believe its Pydle's job to strip color formatting from incoming IRC messages, though it can be relatively easily implementable as a service function.

I believe the implementation of such behavior should be differed to your bot's implementation.

theunkn0wn1 avatar Dec 24 '18 08:12 theunkn0wn1