JonnyPtn / zomboi

A discord bot for project zomboid multiplayer servers
50 stars 33 forks source link

Can't leave environment variables unset #18

Closed laurigates closed 2 years ago

laurigates commented 2 years ago

This issue applies at least when I try to run the bot in a Docker container.

It works as expected with the new environment variables if I specify all of them like so:

DISCORD_TOKEN: "xxxxx"
LOGS_PATH: "/home/zomboi/Zomboid/Logs"
MAPS_PATH: "/home/zomboi/steam/steamapps/common/ProjectZomboid/media/maps"
RCON_PASSWORD: "xxxxx"
RCON_PORT: 27015
CHANNEL: "mychannel"

But if I leave MAPS_PATH out for example, the following error is produced:

discord-zomboi_1  |   File "/home/zomboi/maps.py", line 43, in __init__
discord-zomboi_1  |     if len(self.mapsPath) == 0:
discord-zomboi_1  | TypeError: object of type 'NoneType' has no len()

Or I set it to an empty string like so MAPS_PATH: "", this error is produced:

discord-zomboi_1  | 2022-03-30 16:34:42,387:ERROR:zomboi: Map path not found and/or no suitable default

Not sure if there's currently any way to have the maps & logs paths fall back to trying the default paths, same with RCON port.

Yell420 commented 2 years ago

I have tried setting variables in both config.py and config.env and still no dice with this update.. setting paths does nothing, using windows

Traceback (most recent call last): File "C:\Zomboi\zomboi-master\zomboi.py", line 19, in if len(logPath) == 0: TypeError: object of type 'NoneType' has no len()

laurigates commented 2 years ago

I have tried setting variables in both config.py and config.env and still no dice with this update.. setting paths does nothing, using windows

Traceback (most recent call last): File "C:\Zomboi\zomboi-master\zomboi.py", line 19, in if len(logPath) == 0: TypeError: object of type 'NoneType' has no len()

The config file should be named .env after the update.

https://github.com/JonnyPtn/zomboi/blob/bca62649ff2e7cef7431a2adb3d104588bd211c1/sample.env#L1

The readme file needs an update in the configuration section about this.

Yell420 commented 2 years ago

I understand, thats why i tried the previous versions .py but received the same error even with setting the paths in the .env - im using the old version for now

JonnyPtn commented 2 years ago

in 8adcac8 I changed this so that it handles unset env variables correctly, thanks!