Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup non printable characters and special sequences from chat messages #532

Closed
S-S-X opened this issue Aug 15, 2020 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@S-S-X
Copy link
Member

S-S-X commented Aug 15, 2020

So cleanup things like colored chat messages, worst is rainbow text which looks like nonsense gibberish in discord/irc:

�(c@#FF0000)d�(c@#FF3600)o�(c@#FF6D00)e�(c@#FFA300)s �(c@#ECFF00)a�(c@#B6FF00)n�(c@#7FFF00)y�(c@#48FF00)o�(c@#12FF00)n�(c@#00FF24)e �(c@#00FF91)s�(c@#00FFC8)e�(c@#00FEFF)l�(c@#00C8FF)l �(c@#005BFF)m�(c@#0024FF)u�(c@#1200FF)s�(c@#4800FF)h�(c@#7F00FF)r�(c@#B600FF)o�(c@#EC00FF)o�(c@#FF00DA)m�(c@#FF00A3)s �(c@#FF0036)?

Cleanup these things when sending messages to discord / irc.
Maybe consider cleaning up these also in game chat.
Another thing to think about is possible conversion for chat platforms irc / discord.

@S-S-X
Copy link
Member Author

S-S-X commented Aug 15, 2020

Some chatting about issue:

SX: created issue #532 to cleanup nonptintable characters and/or special sequeneces
chi: could roughly convert them
chi: 2^24 colors to 16
chi: just truncate each byte and look up a table is probably good enough
SX: yeah, I was thinking about converting but then I don't think those are really nice thing to have around as it can make chat a bit messy in the end..
chi: would be just 64 entries in the table
chi: smaller than the color list for named
SX: but yeah, that should be considered too. maybe even tried
chi: removal sounds very easy though
chi: oh and there's b instead of c for background color apparently
chi: things could get very colorful
SX: have not been that big problem so far as not many are using client mods or custom clients to allow colored messages, probably wont be really big problem if converted unless a lot of people start to (ab)use those
chi: is one reason i'm thinking of speed with tables
chi: on irc it's filtered out for me
chi: because for some reason people insist on coloring their text black and not setting the background color
chi: when my terminal background is black

@BuckarooBanzay BuckarooBanzay added the enhancement New feature or request label Aug 17, 2020
@S-S-X
Copy link
Member Author

S-S-X commented Aug 17, 2020

Maybe consider cleaning up these also in game chat.

This probably would be easiest solution as I think it will be enough to just strip control characters from messages sent by players, maybe few trash messages will get through but they will quickly learn that colored messages will not work.
Could maybe add that one anyway as configurable enable/disable option to beerchat.

Cleanup these things when sending messages to discord / irc

Similar to first option but need a bit more code / message parsing / cleanup as this would need to match whole control sequence, validate it similar way mt engine does and then remove it similar way that mt engine would.

Color code conversion for chat platforms

This requires a bit more code but still not very much, would be nice option someone willing to do conversion for currently used platforms irc and discord.
This could then also have configuration option to enable/disable conversion.

@BuckarooBanzay
Copy link
Contributor

This requires a bit more code but still not very much, would be nice option someone willing to do conversion for currently used platforms irc and discord.

I already looked at that, discord does not have (real) coloring for text, stripping the control-codes sounds good IMO...

@S-S-X
Copy link
Member Author

S-S-X commented Aug 18, 2020

Added that, code is basically:

beerchat.register_callback('on_receive', function(msg_data)
	msg_data.message = msg_data.message:gsub('%c','')
end)

Rest of it is new callback handling. Seems that github linked PR here too ^^.

And to actually use control char cleaner:
To enable cleanup add beerchat.enable_cleaner = true to minetest.conf

BuckarooBanzay added a commit that referenced this issue Aug 18, 2020
@S-S-X
Copy link
Member Author

S-S-X commented Aug 20, 2020

mods updated

@S-S-X S-S-X closed this as completed Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants