mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-05 09:21:23 +02:00
cleanup
This commit is contained in:
+33
-30
@@ -1,6 +1,20 @@
|
||||
import configparser
|
||||
|
||||
# Read the config file
|
||||
# Global variables
|
||||
URL_TIMEOUT = 10 # wait time for URL requests
|
||||
DAYS_OF_WEATHER = 4 # weather forecast days, the first two rows are today and tonight
|
||||
ALERT_COUNT = 2 # number of weather alerts to display
|
||||
STORE_LIMIT = 3 # number of messages to store for Store and Forward
|
||||
bbs_ban_list = [] # list of banned nodes numbers ex: [2813308004, 4258675309]
|
||||
bbs_admin_list = [] # list of admin nodes numbers ex: [2813308004, 4258675309]
|
||||
msg_history = [] # message history for the store and forward feature
|
||||
|
||||
# messages
|
||||
NO_DATA_NOGPS = "No location data: does your device have GPS?"
|
||||
ERROR_FETCHING_DATA = "error fetching data"
|
||||
WELCOME_MSG = 'MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd'
|
||||
|
||||
# Read the config file, if it does not exist, create basic config file
|
||||
config = configparser.ConfigParser()
|
||||
config_file = "config.ini"
|
||||
|
||||
@@ -21,43 +35,32 @@ if config.sections() == []:
|
||||
config.write(open(config_file, 'w'))
|
||||
print (f"System: Config file created, check {config_file} or review the config.template")
|
||||
|
||||
# config.ini variables
|
||||
# interface1 settings
|
||||
interface1_type = config['interface'].get('type', 'serial')
|
||||
port1 = config['interface'].get('port', '')
|
||||
hostname1 = config['interface'].get('hostname', '')
|
||||
mac1 = config['interface'].get('mac', '')
|
||||
msg_history = [] # message history for the store and forward feature
|
||||
storeFlimit = config['general'].getint('StoreLimit', 3) # limit of messages to store for Store and Forward
|
||||
|
||||
RESPOND_BY_DM_ONLY = config['general'].getboolean('respond_by_dm_only', True)
|
||||
DEFAULT_CHANNEL = config['general'].getint('defaultChannel', 0)
|
||||
# interface2 settings
|
||||
if 'interface2' in config:
|
||||
interface2_type = config['interface2'].get('type', 'serial')
|
||||
port2 = config['interface2'].get('port', '')
|
||||
hostname2 = config['interface2'].get('hostname', '')
|
||||
mac2 = config['interface2'].get('mac', '')
|
||||
interface2_enabled = config['interface2'].getboolean('enabled', False)
|
||||
|
||||
LATITUDE = config['location'].getfloat('lat', 48.50)
|
||||
LONGITUDE = config['location'].getfloat('lon', -123.0)
|
||||
|
||||
zuluTime = config['general'].getboolean('zuluTime', False)
|
||||
|
||||
try:
|
||||
if MOTD == '':
|
||||
config['general'].get('motd', 'Thanks for using MeshBOT! Have a good day!')
|
||||
except NameError:
|
||||
MOTD = config['general'].get('motd', 'Thanks for using MeshBOT! Have a good day!')
|
||||
|
||||
welcome_message = config['general'].get('welcome_message', 'MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd')
|
||||
|
||||
solar_conditions_enabled = config['solar'].getboolean('enabled', False)
|
||||
# variables
|
||||
storeFlimit = config['general'].getint('StoreLimit', STORE_LIMIT)
|
||||
useDMForResponse = config['general'].getboolean('respond_by_dm_only', True)
|
||||
publicChannel = config['general'].getint('defaultChannel', 0) # the meshtastic public channel
|
||||
location_enabled = config['location'].getboolean('enabled', False)
|
||||
latitudeValue = config['location'].getfloat('lat', 48.50)
|
||||
longitudeValue = config['location'].getfloat('lon', -123.0)
|
||||
zuluTime = config['general'].getboolean('zuluTime', False)
|
||||
welcome_message = config['general'].get('welcome_message', WELCOME_MSG)
|
||||
solar_conditions_enabled = config['solar'].getboolean('enabled', False)
|
||||
bbs_enabled = config['bbs'].getboolean('enabled', False)
|
||||
bbsdb = config['bbs'].get('bbsdb', 'bbsdb.pkl')
|
||||
dad_jokes_enabled = config['general'].getboolean('DadJokes', False)
|
||||
store_forward_enabled = config['general'].getboolean('StoreForward', False)
|
||||
|
||||
URL_TIMEOUT = 10 # wait time for URL requests
|
||||
DAYS_OF_WEATHER = 4 # weather forecast days, the first two rows are today and tonight
|
||||
# error messages
|
||||
ALERT_COUNT = 2 # number of weather alerts to display
|
||||
NO_DATA_NOGPS = "No location data: does your device have GPS?"
|
||||
ERROR_FETCHING_DATA = "error fetching data"
|
||||
|
||||
bbs_ban_list = [] # list of banned nodes numbers ex: [2813308004, 4258675309]
|
||||
bbs_admin_list = [] # list of admin nodes numbers ex: [2813308004, 4258675309]
|
||||
config['general'].get('motd', 'Thanks for using MeshBOT! Have a good day!')
|
||||
@@ -65,8 +65,8 @@ def get_sun(lat=0, lon=0):
|
||||
obs.lat = str(lat)
|
||||
obs.lon = str(lon)
|
||||
else:
|
||||
obs.lat = str(LATITUDE)
|
||||
obs.lon = str(LONGITUDE)
|
||||
obs.lat = str(latitudeValue)
|
||||
obs.lon = str(longitudeValue)
|
||||
|
||||
sun.compute(obs)
|
||||
sun_table = {}
|
||||
@@ -101,8 +101,8 @@ def get_moon(lat=0, lon=0):
|
||||
obs.lat = str(lat)
|
||||
obs.lon = str(lon)
|
||||
else:
|
||||
obs.lat = str(LATITUDE)
|
||||
obs.lon = str(LONGITUDE)
|
||||
obs.lat = str(latitudeValue)
|
||||
obs.lon = str(longitudeValue)
|
||||
|
||||
obs.date = datetime.now()
|
||||
moon.compute(obs)
|
||||
|
||||
Reference in New Issue
Block a user