Skip to content

Commit

Permalink
Allow gclone path to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
wrenfairbank authored Jun 25, 2020
1 parent 315e4e5 commit 6f7e35c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions telegram_gcloner/utils/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def load_config(self):
config_general = config_file['General']

config_general_keywords_str = [
'path_to_gclone',
'telegram_token',
'user_ids',
'group_ids',
'ad_string',
]

self.get_config_from_section('str', config_general_keywords_str, config_general)
self.get_config_from_section('str', ['path_to_gclone'], config_general, optional=True)

self._user_ids = [int(item) for item in self._user_ids.split(',')]
self._group_ids = [int(item) for item in self._group_ids.split(',')]
Expand All @@ -68,7 +68,7 @@ def load_config(self):
sys.exit(0)
logger.info('Found token: ' + self._telegram_token)

def get_config_from_section(self, var_type, keywords, section):
def get_config_from_section(self, var_type, keywords, section, optional=False):
for item in keywords:
if var_type == 'int':
value = section.getint(item, 0)
Expand All @@ -78,7 +78,7 @@ def get_config_from_section(self, var_type, keywords, section):
value = section.getboolean(item, False)
else:
raise TypeError
if not value and value is not False:
if not optional and not value and value is not False:
logger.warning('{} is not provided.'.format(item))
input("Press Enter to continue...")
sys.exit(1)
Expand Down

0 comments on commit 6f7e35c

Please sign in to comment.