zomboid log timestamp format as environment variable
All checks were successful
Build and Push Docker Image / build (push) Successful in 14s

This commit is contained in:
Corban-Lee Jones 2024-12-12 17:14:09 +00:00
parent bfe8651ee7
commit 96fe28b15c
2 changed files with 8 additions and 4 deletions

View File

@ -29,9 +29,12 @@ This should make the environment variables used be more clear and pronounced whe
|`SPIFFO__DISCORD_CHANNEL_ID`|Snowflake ID of the channel where join alerts and other server related messages should appear.|✔||
|`SPIFFO__STEAM_API_KEY`|Web API key granted by steam, allows for the user's steam profile info to be shown in the join alerts.|||
|`SPIFFO__ZOMBOID_FOLDER_PATH`|Absolute path to the 'Zomboid' folder that contains the `server-console.txt` file.|✔||
|`SPIFFO__DATA_FOLDER_PATH`|Custom path of where the bot will create and store data.|✔||
|`SPIFFO__SERVER_NAME`|Name of the server instance, don't change unless you know what you are doing!||servertest|
|`SPIFFO__DEBUG`|Whether to run in debug mode, which will reveal debug logs.||False|
|`SPIFFO__ZOMBOID_LOG_TIMESTAMP_FORMAT`|The format used for timestamps in Zomboid's logs - do not change this!|✔|%d-%m-%y %H:%M:%S.%f|
## Why Did I Make This?
## Why Am I Making This?
All existing bots are poorly coded, slow and/or lack certain features.

View File

@ -17,6 +17,7 @@ from utils.models import Player
ZOMBOID_FOLDER_PATH = Path(getenv("SPIFFO__ZOMBOID_FOLDER_PATH"))
LOGS_FOLDER_PATH = ZOMBOID_FOLDER_PATH / "Logs"
USER_LOG_FILE_PATH = next(LOGS_FOLDER_PATH.glob("*_user.txt"), None)
TIMESTAMP_FORMAT = getenv("SPIFFO__ZOMBOID_LOG_TIMESTAMP_FORMAT", "%d-%m-%y %H:%M:%S.%f")
log = logging.getLogger(__name__)
@ -99,7 +100,7 @@ class PlayersCog(commands.Cog):
cause=re_match.group("cause"),
timestamp=datetime.strptime(
re_match.group("timestamp"),
"%m-%d-%y %H:%M:%S.%f"
TIMESTAMP_FORMAT
)
)
await player.save()
@ -129,7 +130,7 @@ class PlayersCog(commands.Cog):
player, created = await Player.get_or_create(username=re_match.group("username"))
await player.open_session(
timestamp=datetime.strptime(re_match.group("timestamp"), "%d-%m-%y %H:%M:%S.%f"),
timestamp=datetime.strptime(re_match.group("timestamp"), TIMESTAMP_FORMAT),
coord_x=re_match.group("x"),
coord_y=re_match.group("y"),
coord_z=re_match.group("z")
@ -169,7 +170,7 @@ class PlayersCog(commands.Cog):
player, created = await Player.get_or_create(username=re_match.group("username"))
await player.close_session(
timestamp=datetime.strptime(re_match.group("timestamp"), "%d-%m-%y %H:%M:%S.%f"),
timestamp=datetime.strptime(re_match.group("timestamp"), TIMESTAMP_FORMAT),
coord_x=re_match.group("x"),
coord_y=re_match.group("y"),
coord_z=re_match.group("z")