Closed Nodeswitch closed 3 years ago
Hmm.. I may have done something wrong initially. I destroyed the container and started again. I'm getting different errors now.
Said hi to discord_user#1234.
[discord_user#1234]: list
Incorrect argument for commandlist <--[HERE]
[discord_user#1234]: list
Incorrect argument for commandlist <--[HERE]
[discord_user#1234]: op
Incorrect argument for commandop <--[HERE]
Whenever I try a command, I'm getting the above. I'm entering without a space, so >list
, >op
and so on.
It looks like commands that don't have parameters passed through, like >list
are failing, but say >op player
works. It looks like there's a space being added when running commands without parameters that isn't being stripped.
Thanks!
That's very strange behavior. You seem to have gotten the connection working, so I'll assume you don't need help with that.
Could you tell me what kind of system you're running this on in terms of CPU architecture? Also, have you been building the image yourself or using the provided one? I just did some work on the Docker images yesterday, so you may want to pull the most recent image.
I immediately thought it was a parsing error as well, but in my testing >list
behaves the same as >list
(with an extra space at the end). Line 55 in mconBot.py is the section that parses commands from Discord. It parses using white space, so there seems to be some kind of error in the exception around line 60. Currently, for commands that don't have parameters provided, I set args = ''
. I'll try changing that to a null character, args = '\0'
.
Edit: setting args = '\0'
in line 60 maintains functionality on my system, although I have no way of knowing if it will fix issues on yours. Fingers crossed.
Sorry for the delay! Running x86_64 and using the provided image (raynieport/mconbot). Running image d12aaa8197f1
from three days ago.
Thanks for the suggestion! I've tried both args = ``
and args =
\0
, but don't see a change after stopping and starting the container. I'm probably doing something wrong here!
If I display all spaces in the log as ␣
then it looks like the below, if that's of any help.
[discord_user#1234]:␣op␣$
Incorrect␣argument␣for␣commandop␣<--[HERE]$
[discord_user#1234]:␣op␣player$
Made␣player␣a␣server␣operator$
[discord_user#1234]:␣deop␣player$
Made␣player␣no␣longer␣a␣server␣operator$
[discord_user#1234]:␣list␣$
Incorrect␣argument␣for␣commandlist␣<--[HERE]$
No worries about the delay. I've done most of my testing on x86_64, so I was curious if you were trying to run on a different architecture. Unfortunately I can't seem to reproduce your issue in any of my testing.
For now, here's what I'd recommend:
docker rm mconbot
and docker rmi raynieport/mconbot
. This should completely remove the container and image from your system.docker run -dt --name mconbot --env-file .env raynieport/mconbot
to get the latest image.Try this out, and if you're still having issues with the new image then maybe we could schedule some kind of call (maybe on Discord, since we both use that) where I could try to help you sort everything out. Sorry it hasn't been smooth sailing for you, but I appreciate you trying it out and giving feedback! If there is some kind of bug in the bot, hopefully we can find it together!
Try this out, and if you're still having issues with the new image then maybe we could schedule some kind of call (maybe on Discord, since we both use that) where I could try to help you sort everything out. Sorry it hasn't been smooth sailing for you, but I appreciate you trying it out and giving feedback! If there is some kind of bug in the bot, hopefully we can find it together!
No problem at all! I'm happy to be of help, this is a great project!
I've cleared out the existing container and image, but have pulled down the same image again and can replicate the issue again. Removing docker from the mix and installing straight to python virtualenv, I'm able to replicate this as well.
On sending a command from discord, I see the following in the console.
/data/mc/python$ python3 mconBot.py
[discorduser#1234]: list
Incorrect argument for commandlist <--[HERE]
The venv looks like the following, which was built from installing from the requirements file.
$ python --version
Python 3.8.5
$ pip --version
pip 21.1.2 from /data/mc/python/venv/lib/python3.8/site-packages/pip (python 3.8)
$ pip list --local
Package Version
----------------- -----------
aiohttp 3.7.4.post0
async-timeout 3.0.1
attrs 21.2.0
chardet 4.0.0
discord.py 1.7.2
idna 3.1
mcrcon 0.6.0
multidict 5.1.0
pip 21.1.2
python-dotenv 0.17.1
setuptools 57.0.0
typing-extensions 3.10.0.0
wheel 0.36.2
yarl 1.6.3
I then tried downgrading discord.py and python-dotenv to the exact versions in the requirements file, but the same issue persists.
If there's anything else I can try, let me know! (:
Glad you enjoy the project!
I must have misread your previous post, it does seem that you're using the most recent image... Let me check what versions I'm using and see if I can replicate the issue. My mind is a little blown because everything seems to be the same, so I don't understand why it isn't working for you. I thought Docker was supposed to eliminate these dependency headaches and differences between machines :P
I'll get back to you when I test things out again using a fresh container. My only other thought is that maybe your Discord is doing something funny and appending some kind of character at the end of a each message.. that seems highly unlikely though.
Edit: Okay, I went ahead and wiped the Docker image and container from my own machine and pulled the most recent image from Docker Hub just like you did. Fortunately (unfortunately?) it works entirely as expected:
Said hi to discorduser#1234. [discorduser#1234]: list There are 0 of a max of 20 players online: [discorduser#1234]: banlist There are no bans [discorduser#1234]: seed Seed: [-8513184642686157235] [discorduser#1234]: weather clear Set the weather to clear
I then ran docker exec -it mconbot /bin/sh
to get the versions of everything in the container itself. Can you confirm that your container has the same? Based on my understanding of Docker images, it should. It doesn't hurt to check, though.
/code # python3 --version Python 3.8.10 /code # pip3 --version pip 20.3.4 from /usr/lib/python3.8/site-packages/pip (python 3.8) /code # pip3 list --local Package Version ----------------- ----------- aiohttp 3.7.4.post0 appdirs 1.4.4 async-timeout 3.0.1 attrs 21.2.0 CacheControl 0.12.6 chardet 4.0.0 colorama 0.4.4 contextlib2 0.6.0 discord.py 1.7.2 distlib 0.3.1 distro 1.5.0 html5lib 1.1 idna 3.1 lockfile 0.12.2 mcrcon 0.6.0 msgpack 1.0.2 multidict 5.1.0 ordered-set 4.0.2 packaging 20.9 pep517 0.9.1 pip 20.3.4 progress 1.5 pyparsing 2.4.7 python-dotenv 0.17.1 pytoml 0.1.21 requests 2.25.1 retrying 1.3.3 setuptools 51.3.3 six 1.15.0 toml 0.10.2 typing-extensions 3.10.0.0 urllib3 1.26.2 webencodings 0.5.1 yarl 1.6.3
Again, based on my understanding of Docker, it shouldn't matter - but what is your host OS? I've been testing on Alpine, Arch, and Ubuntu Linux.
I also just tested outside of my Docker container in Ubuntu using Python 3.8.5 and pretty much all the other same versions as you, but still can't replicate the problem... I have to admit I'm a little stumped. I'll ask some friends to test on their machines to see if anyone else can replicate the issue you're having. Is there any chance you have another machine you could test on? Maybe a Raspberry Pi or something?
Sure!
I've cloned the repo, set up a venv and populated the environment file, but still seem to get the same. Odd!
System info and python environment info:
~/mconbot/mconBot/src $ raspinfo
System Information
------------------
Raspberry Pi 4 Model B Rev 1.1
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
$ pip --version
pip 21.1.2 from /home/pi/mconbot/venv/lib/python3.7/site-packages/pip (python 3.7)
$ python --version
Python 3.7.3
$ pip list --local
Package Version
----------------- -----------
aiohttp 3.7.4.post0
async-timeout 3.0.1
attrs 21.2.0
chardet 4.0.0
discord.py 1.7.2
idna 3.1
mcrcon 0.6.0
multidict 5.1.0
pip 21.1.2
python-dotenv 0.17.1
setuptools 57.0.0
typing-extensions 3.10.0.0
wheel 0.36.2
yarl 1.6.3
mconBot :
$ python mconBot.py
[discord_user#1234]: list
Incorrect argument for commandlist <--[HERE]
[discord_user#1234]: say hello
[discord_user#1234]: weather clear
Set the weather to clear
Just tested sending the commands from the Android Discord client in case it was something related to using Discord in Firefox on Ubuntu, but still get the same.
Alright! I just spun up a new VM on a friend's server to test and finally have the same result as you using the Docker container. I don't know what's wrong yet but at least I am able to replicate the issue and can work on debugging. It would seem that something on my development machine is allowing it to run just fine.. I'll look into it. Maybe some dependency got left out, although I'm not sure how.
Thanks for your patience and help!
Alright, I just figured out what it is... I'm running a Spigot server, which seems to accept the space at the end of a command. Apparently Vanilla servers do not. Shouldn't be too bad of a fix. My bad for not testing on a vanilla server, I really shouldn't have assumed that they accepted RCON commands the same way.
I'll let you know as soon as I fix the problem.
Okay I fixed the code, rebuilt the Docker images, and pushed everything to GitHub/Docker Hub. You should be able to just pull down the most recent image and it should work with a Vanilla server. Sorry for wasting your time, I really should have tested that use case before releasing this project. I just assumed that Spigot and Vanilla would work the same in terms of receiving RCON commands.
I appreciate your help finding this bug! If you could let me know if it works now, I'll go ahead and close this issue.
I really shouldn't have assumed that they accepted RCON commands the same way.
I assumed that the server wouldn't be the problem as well, which is why I didn't even mention that I was running vanilla. Not great that Spigot handles RCON differently!
I appreciate your help finding this bug! If you could let me know if it works now, I'll go ahead and close this issue.
Totally not wasting my time. Happy to be able to help with something.
# docker logs mconbot --follow
[discord_user#1234]: list
There are 0 of a max of 4 players online:
Looking good! Thanks for the work put into this! :D
Great! Thanks again for letting me know about this issue. Enjoy the bot!
Hi!
I'm encountering an issue with the docker version of mconBot. I've followed the process for setting up a bot and integrating it with a channel. When running
>hi
and>help
it responds appropriately, but when I run a command that would query my server, it returnsConnection from the bot to the server failed
.When I check the docker logs, I see
Port 25575 is definitely open and I have the correct password defined in the environment file.
Running a shell on the container and executing mconbot from there seems to work fine
Is there anything else I can test here to identify where the issue may be coming from?