Added Handler config option
This commit is contained in:
@@ -7,7 +7,7 @@ def check_if_config_exists():
|
||||
if exists('./config.ini'):
|
||||
config = configparser.SafeConfigParser()
|
||||
config.read('./config.ini')
|
||||
if config.has_section('Bot_Info') and config.has_section('Device'):
|
||||
if config.has_section('Bot_Info') and config.has_section('Device') and config.has_section('Config'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -24,7 +24,8 @@ def read_config_file():
|
||||
'Device ID': int(config['Device']['ID']),
|
||||
'Device Name': str(config['Device']['Name']),
|
||||
'Mention Group': str(config['Bot_Info']['Mention_Group']),
|
||||
'Channel ID': int(config['Bot_Info']['Channel_ID'])
|
||||
'Channel ID': int(config['Bot_Info']['Channel_ID']),
|
||||
'Handler': str(config['Config']['Handler'])
|
||||
}
|
||||
|
||||
print("Found config options:")
|
||||
@@ -43,9 +44,17 @@ def write_config_file(**kwargs):
|
||||
if not config.has_section('Bot_Info'):
|
||||
config.add_section('Bot_Info')
|
||||
|
||||
if not config.has_section('Config'):
|
||||
config.add_section('Config')
|
||||
|
||||
if not config.has_section('Device'):
|
||||
config.add_section('Device')
|
||||
|
||||
if 'handler' in kwargs.keys():
|
||||
config['Config']['Handler'] = str(kwargs['handler'])
|
||||
elif kwargs['init']:
|
||||
config['Config']['Handler'] = str(get_handler())
|
||||
|
||||
if 'token' in kwargs.keys():
|
||||
config['Bot_Info']['Token'] = str(kwargs['token'])
|
||||
elif kwargs['init']:
|
||||
@@ -154,6 +163,16 @@ def get_user_mention_channel_id():
|
||||
continue
|
||||
|
||||
|
||||
def get_handler():
|
||||
handler = None
|
||||
while not handler:
|
||||
handler = str(input(f"Please enter the name of the handler you would like to use:\t"))
|
||||
if handler == "gqrx":
|
||||
return handler
|
||||
elif handler == '':
|
||||
return handler
|
||||
|
||||
|
||||
def check_negative(s):
|
||||
try:
|
||||
f = float(s)
|
||||
|
||||
Reference in New Issue
Block a user