Made it work
Updated console output Improved checks for config file
This commit is contained in:
@@ -4,7 +4,11 @@ from os.path import exists
|
||||
|
||||
def check_if_config_exists():
|
||||
if exists('./config.ini'):
|
||||
return True
|
||||
config = configparser.SafeConfigParser()
|
||||
if config.has_section('Bot_Info') and config.has_section('Device'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -35,30 +39,34 @@ def write_config_file(**kwargs):
|
||||
if not config.has_section('Device'):
|
||||
config.add_section('Device')
|
||||
|
||||
if kwargs['token']:
|
||||
config['Bot_Info']['Token'] = kwargs['token']
|
||||
if 'token' in kwargs.keys():
|
||||
config['Bot_Info']['Token'] = str(kwargs['token'])
|
||||
elif kwargs['init']:
|
||||
config['Bot_Info']['Token'] = get_user_token()
|
||||
config['Bot_Info']['Token'] = str(get_user_token())
|
||||
|
||||
if kwargs['device_id'] or kwargs['device_name']:
|
||||
config['Device']['ID'] = kwargs['device_id']
|
||||
config['Device']['Name'] = kwargs['device_name']
|
||||
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']:
|
||||
config['Device']['ID'], config['Device']['Name'] = get_user_device_selection()
|
||||
device_id, device_name = get_user_device_selection()
|
||||
config['Device']['ID'] = str(device_id)
|
||||
config['Device']['Name'] = str(device_name)
|
||||
|
||||
if kwargs['mention_group']:
|
||||
config['Bot_Info']['Mention_Group'] = kwargs['mention_group']
|
||||
if 'mention_group' in kwargs.keys():
|
||||
config['Bot_Info']['Mention_Group'] = str(kwargs['mention_group'])
|
||||
elif kwargs['init']:
|
||||
config['Bot_Info']['Mention_Group'] = get_user_mention_group()
|
||||
config['Bot_Info']['Mention_Group'] = str(get_user_mention_group())
|
||||
|
||||
if kwargs['channel_id']:
|
||||
config['Bot_Info']['Channel_ID'] = kwargs['channel_id']
|
||||
if 'channel_id' in kwargs.keys():
|
||||
config['Bot_Info']['Channel_ID'] = str(kwargs['channel_id'])
|
||||
elif kwargs['init']:
|
||||
config['Bot_Info']['Channel_ID'] = str(get_user_mention_channel_id())
|
||||
|
||||
with open('./config.ini', 'w') as config_file:
|
||||
config.write(config_file)
|
||||
|
||||
print("Config Saved")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -122,7 +130,7 @@ def get_user_mention_group():
|
||||
def get_user_mention_channel_id():
|
||||
channel_id = None
|
||||
while not channel_id:
|
||||
channel_id = int(input(f"Please enter the channel ID of the the default channel you would like messages to be sent in"))
|
||||
channel_id = int(input(f"Please enter the channel ID of the the default channel you would like messages to be sent in:\t"))
|
||||
if len(str(channel_id)) == len('757379843792044102'):
|
||||
return channel_id
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user