mcstatus icon indicating copy to clipboard operation
mcstatus copied to clipboard

Rewrite MOTD parser

Open PerchunPak opened this issue 2 years ago • 9 comments

Full rewrite of MOTD parser. I also made an API for users, so they can easily write their own parser.

Closes #204.

PerchunPak avatar Jun 23 '22 16:06 PerchunPak

Found something strange, when I read about the protocol, found that all text in MOTD can be formatted with one tag on top level. See this. Should I implement parsing for this?

PerchunPak avatar Jun 26 '22 18:06 PerchunPak

Found something strange, when I read about the protocol, found that all text in MOTD can be formatted with one tag on top level. See this. Should I implement parsing for this?

That's interesting, good catch, yeah it probably should be respected, even though I don't think I've seen that before. If you are going to be adding support for that here, make sure to also add a unit-test for that. Otherwise, you can reference this comment in a new issue about this and let someone else handle it later.

ItsDrike avatar Jun 26 '22 18:06 ItsDrike

NOTE: If this PR wasn't yet supposed to be reviewed, please mark it back as draft PR and feel free to ignore this review up until you think the PR will be ready.

This is ready to review, but not for merge. I'm keep doing ansi and xterm-256 properties.

PerchunPak avatar Jun 29 '22 09:06 PerchunPak

I pretty sure, few big moments here still needs more work.

PerchunPak avatar Jul 01 '22 19:07 PerchunPak

image

Hmmmmmmm... I wonder, how many things was broken in first implementation from Iapetus-11...

PerchunPak avatar Jul 02 '22 14:07 PerchunPak

Adding do-not-merge label, as requested.

This do-not-merge is here because this PR relies on renaming description to motd, which is currently a change that's not final and is still being discussed. To avoid the same discussion from happening here, a do-not-merge label is added until that discussion is resolved/306 gets merged.

Note that this PR can be still reviewed and approved, it just shouldn't yet be merged. But when reviewing, this blocking status should be taken into consideration, and some points on changes in variable naming or other inconsistencies with current code-base may not actually be inconsistencies, as this assumes the pending decision about this rename in 306 will end up on choosing to rename description to motd.

  • [ ] Merging blocked by #306

ItsDrike avatar Jul 02 '22 17:07 ItsDrike

Hmm, I found a server that's using text that includes the special color formatting: image

However this implementation is currently treating these text blocks as just plain strings (line 265):

text = item.get("text")
        if text is not None:
            parsed_motd.append(text)

Perhaps it would be wise to do parsed_motd.extend(cls._parse_as_string(text, bedrock)), so that we'll actually parse out the colors in this text too.

ItsDrike avatar Oct 01 '22 01:10 ItsDrike

I do not remember what I wanted to improve here, so opening this for review.

PerchunPak avatar Oct 01 '22 06:10 PerchunPak

Perhaps it would be wise to do parsed_motd.extend(cls._parse_as_string(text, bedrock)), so that we'll actually parse out the colors in this text too.

Done!

PerchunPak avatar Oct 01 '22 08:10 PerchunPak