Create GUI
Update README
This commit is contained in:
@@ -19,12 +19,15 @@ def read_config_file():
|
||||
config.read('./config.ini')
|
||||
|
||||
config_return = {
|
||||
'Bot Token': config['Bot_Info']['Token'],
|
||||
'Token': config['Bot_Info']['Token'],
|
||||
'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'])
|
||||
}
|
||||
if config.has_option('Bot_Info', 'Mention_Group'): #'Mention Group' in config['Bot_Info'].items():
|
||||
config_return['Mention Group'] = str(config['Bot_Info']['Mention_Group'])
|
||||
|
||||
if 'Channel_ID' in config['Bot_Info'].keys():
|
||||
config_return['Channel ID'] = int(config['Bot_Info']['Channel_ID'])
|
||||
|
||||
print("Found config options:")
|
||||
for key in config_return.keys():
|
||||
@@ -36,7 +39,7 @@ def read_config_file():
|
||||
def write_config_file(**kwargs):
|
||||
config = configparser.SafeConfigParser()
|
||||
|
||||
if not kwargs['init'] and exists('./config.ini'):
|
||||
if 'init' not in kwargs.keys() and exists('./config.ini'):
|
||||
config.read('./config.ini')
|
||||
|
||||
if not config.has_section('Bot_Info'):
|
||||
@@ -47,29 +50,32 @@ def write_config_file(**kwargs):
|
||||
|
||||
if 'token' in kwargs.keys():
|
||||
config['Bot_Info']['Token'] = str(kwargs['token'])
|
||||
elif kwargs['init']:
|
||||
elif 'init' in kwargs.keys():
|
||||
config['Bot_Info']['Token'] = str(get_user_token())
|
||||
|
||||
if 'device_id' in kwargs.keys() or 'device_name' in kwargs.keys():
|
||||
config['Device']['ID'] = str(kwargs['device_id'])
|
||||
config['Device']['Name'] = str(kwargs['device_name'])
|
||||
elif kwargs['init']:
|
||||
elif 'init' in kwargs.keys():
|
||||
device_id, device_name = get_user_device_selection()
|
||||
config['Device']['ID'] = str(device_id)
|
||||
config['Device']['Name'] = str(device_name)
|
||||
|
||||
if 'mention_group' in kwargs.keys():
|
||||
config['Bot_Info']['Mention_Group'] = str(kwargs['mention_group'])
|
||||
elif kwargs['init']:
|
||||
elif 'init' in kwargs.keys():
|
||||
config['Bot_Info']['Mention_Group'] = str(get_user_mention_group())
|
||||
|
||||
if 'channel_id' in kwargs.keys():
|
||||
config['Bot_Info']['Channel_ID'] = str(kwargs['channel_id'])
|
||||
elif kwargs['init']:
|
||||
elif 'init' in kwargs.keys():
|
||||
config['Bot_Info']['Channel_ID'] = str(get_user_mention_channel_id())
|
||||
|
||||
with open('./config.ini', 'w') as config_file:
|
||||
config.write(config_file)
|
||||
try:
|
||||
with open('./config.ini', 'w') as config_file:
|
||||
config.write(config_file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
print("Config Saved")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user