kirc icon indicating copy to clipboard operation
kirc copied to clipboard

Fails to recognize (properly ignore?) colors

Open 097115 opened this issue 2 years ago • 13 comments

When colors are added to messages, kirc ignores the control sequences (which is probably a good thing) but still displays the actual codes.

A simple example would be newsly bot from the ##news channel at libera.chat. With the log entry like this (^B and ^C being the actual binary entries, the raw log is available here):

Wed Dec 13 23:02:36 2022::newsly!~newsly@user/yano/bot/rssly PRIVMSG ##news :[^B^C6ECNS for China^C^B] ^BU.S. panel investigating Capitol riot to release final report next week^B http://www.ecns.cn/news/2022-12-14/detail-ihchtzzp6213103.shtml

kirc displays it like this -- note 6 after the opening square bracket:

newsly [6ECNS for China] U.S. panel investigating Capitol riot to release final report next week http://www.ecns.cn/news/2022-12-14/detail-ihchtzzp6213103.shtml

Would it possible to catch those somehow? And probably hide / ignore altogether?

097115 avatar Dec 14 '22 04:12 097115

Should be doable. The logging function is pretty dumb at the moment and does not handle escape sequences gracefully. Give me some time though (probably until after the new year) and I will prepare a new release (also with some overdue refactoring).

mcpcpc avatar Dec 15 '22 02:12 mcpcpc

@097115 had some bandwidth to work on this issue. Let me know if the 0.3.2 branch resolves your issue.

mcpcpc avatar Dec 16 '22 02:12 mcpcpc

Let me know if the 0.3.2 branch resolves your issue.

Sorry but it seems like no :)

I did git clone -b 0.3.2 https://github.com/mcpcpc/kirc/, but it still prints out the color codes, like this (note the 13 code):

newsly [13Google News - India] Parliament Winter Session updates...

And the logging now has [almost] the same line twice :) Like this:

Fri Dec 16 06:23:07 2022::newsly!~newsly@user/yano/bot/rssly PRIVMSG ##news :[13Google News - India] Parliament Winter Session updates | December 15 2022 - The Hindu https://www.thehindu.com/news/national/parliament-winter-session-updates-15-december-2022/article66265787.ece 2022-12-15T05:06:00
:newsly!~newsly@user/yano/bot/rssly PRIVMSG ##news :[13Google News - India] Parliament Winter Session updates | December 15 2022 - The Hindu https://www.thehindu.com/news/national/parliament-winter-session-updates-15-december-2022/article66265787.ece 2022-12-15T05:06:00

:)

097115 avatar Dec 16 '22 04:12 097115

@097115 My apologies… I forgot to remove the original printed string with the fix. But you can see that the second “duplicate” string removes the non-ASCII characters from being printed (e.g. ^B and ^C). Try the latest commit to the 0.3.2 Branch and let me know if that looks better =).

Regarding the 13 being printed, that will have to be addressed in the message parser directly (since it also prints to the console). So I'll need a little more time to dig into that.

mcpcpc avatar Dec 16 '22 12:12 mcpcpc

Yeah, the log is now cleaner, indeed :) However, this binary stuff was never the actual problem :)

As I mentioned earlier, the problem was color codes (numbers) that follow the control sequences. E.g., in the string [13Google News - India] Parliament Winter Session updat the number 13 is such a code. Ctrl-B makes the text bold, and Ctrl-C followed by a color code paints it.

So, now the control characters, like ^B and ^C are ignored (which is good) but the color codes are still shown (both in the log and in kirc itself).

Thus, you probably shouldn't just outright ignore those sequences but in order not to keep / not to show this number garbage you likely should also analyze them to some degree -- and to ignore not only the binary stuff but also the following codes, too :).

097115 avatar Dec 16 '22 13:12 097115

@097115 The latest commit removes the garbage characters in addition to the non-ASCII characters. I need to spend more time considering other impacted use cases for multi-byte characters, but this should work for the time being.

mcpcpc avatar Dec 16 '22 18:12 mcpcpc

Not to sound like a prick but no, it still has problems:

  • The captured buffer from kirc itself: screenshot, text
  • The corresponding part from the log: text

Unfortunately, I'm not using kirc at the moment, so can't be much of help, but as you can see, the log still has color codes parts if the code in question was double digits, and the program itself still displays them in any case.

097115 avatar Jan 05 '23 06:01 097115

Oof. I see it in my own logs now re-reviewing them. Looks like I forgot to push my last commit before the holidays.

mcpcpc avatar Jan 05 '23 12:01 mcpcpc