Open Sean-McConnachie opened 4 years ago
I don't think that's a bug, since it's just a normal string response.. you could get a line-by-line output with something like this: resp = mcr.command("/help")
wanted_resp = ""
wanted_resp_list = resp.split("/") wanted_resp_list.pop(0) for command in wanted_resp_list: wanted_resp += "/" + command + "\n"
print(wanted_resp)
this way, you will get the proper response in "wanted_resp". I am also pretty sure that there is a much quicker way of doing this. Hope this is helpful!
The issue seems to apply to any response that should contain a newline. It simply excludes any newline character in the response string entirely.
The fix that @salamelek suggested will only work for help
command and others that have a similar response pattern.
For example, sending the whitelist
command without any argument will result in the server complaining. Usually, the output will be over two lines like this:
Unknown or incomplete command, see below for error
whitelist<--[HERE]
But the string that we get from the command method does not have a newline:
Unknown or incomplete command, see below for errorwhitelist<--[HERE]
Yeah, looking into this I'm unsure if we can really even do anything about this. The raw returned byte data seems to have no idea about where the newlines should be, and we can't really infer anything consistently about where to split sadly. :(
I'm going to label it as won't fix, but not close it so others don't attempt to submit the same issue.
Hi there,
There seems to be a bug that causes there to be no newlines in responses.
E.g.
mcr = MCRcon("10.1.1.1", "sekret")
mcr.connect()
resp = mcr.command("/help")
print(resp)
mcr.disconnect()
gives/advancement (grant|revoke)/ban <targets> [<reason>]....
on one line.