Added fortune file via ENV VAR and in data dir.

Added missing config and data dir in previous commit
This commit is contained in:
Jeff Laflamme 2024-06-27 12:03:28 +07:00
parent eedb7c448d
commit b3bae047d5
4 changed files with 5 additions and 2 deletions

View File

@ -96,6 +96,8 @@ Be sure you've followed the Python virtual environment steps above and activated
The docker entrypoint.sh will automatically copy config.ini.sample to config.ini
if you want to edit config, make sure you add the config directory as a docker volume.
Environment Variables: FORTUNE_FILE, DB_FILE, CONFIG_FILE
```sh
docker run -it --name tc2bbsmesh -v tc2bbsmesh-config:/app/config/ -v tc2bbsmesh-data:/app/data/ --device=/dev/ttyACM0 tc2-bbs-mesh
```

View File

@ -1,4 +1,5 @@
import logging
import os
import random
import time
@ -89,7 +90,7 @@ def handle_stats_command(sender_id, interface):
def handle_fortune_command(sender_id, interface):
try:
with open('fortunes.txt', 'r') as file:
with open(os.getenv('FORTUNE_FILE','data/fortunes.txt'), 'r') as file:
fortunes = file.readlines()
if not fortunes:
send_message("No fortunes available.", sender_id, interface)
@ -389,4 +390,4 @@ def handle_channel_directory_steps(sender_id, message, step, state, interface):
channel_name = state['channel_name']
add_channel(channel_name, channel_url)
send_message(f"Your channel '{channel_name}' has been added to the directory.", sender_id, interface)
handle_channel_directory_command(sender_id, interface)
handle_channel_directory_command(sender_id, interface)