mcstatus
mcstatus copied to clipboard
Support multiple types of formatting for MOTD
Authored by kevinkjt2000
From this conversation https://github.com/Dinnerbone/mcstatus/pull/196#discussion_r794997184_
We could make parsing descriptions easier by providing multiple properties for MOTD that format in a way that match their name (e.g. html_description, ansi_description, plaintext_description, xt256_description, etc.)
I already made plain
and html
attributes. But there is a question happened, with what should replace ansi
method non-ansi
characters? And what is xt256
? (Google giving nothing, except some mentions in tracebacks and graphics cards)
with what should replace
ansi
method non-ansi characters?
Hm? There are ANSI escape codes for all of minecraft's available styles/colors. You can check this website for more about ANSI, and minecraft fandom wiki for specific ANSI sequences mapped to equivalent minecraft syntax.
ANSI sequences even support arbitrary color from True colors (24-bit RGB), which we can use if we obtained hex rgb color (i.e. something like #FF0025
. This has the following format where you'd replace <r>
,<g>
,<b>
with corresponding colors in base 10 (0-255):
\033[38;2;<r>;<g>;<b>m #Select RGB foreground color
\033[48;2;<r>;<g>;<b>m #Select RGB background color
And what is
xt256
?
Not sure, @kevinkjt2000 proposed that, but I think it's safe to assume it's a shorthand for xterm-256 colors
So this all just apply to colors? Left alone non-English characters?
Obviously, the whole point is to use the ANSI escape codes instead of the minecraft code to represent the style/color of some text. They're supported in most terminals, so when they're printed out the text will actually appear colored.