diff --git a/config/config.ini.example b/config/config.ini.example index a7496a4..a5a68fc 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -2,10 +2,6 @@ cookie = PHPSESSIONCOOKIEGOESHERE # should we consider giveaways on the 'ALL' page? it is the main page enabled = true -# gift_types options: All -gift_types = All -# should we consider pinned-at-the-top giveaways -pinned = false # minimum number of points in your account before entering into giveaways minimum_points = 50 # max number of entries in a giveaway for it to be considered diff --git a/src/ConfigReader.py b/src/ConfigReader.py index 7d3941a..8c13261 100644 --- a/src/ConfigReader.py +++ b/src/ConfigReader.py @@ -1,6 +1,8 @@ from configparser import ConfigParser from random import randint +import log +logger = log.get_logger(__name__) class ConfigException(Exception): pass @@ -13,8 +15,6 @@ class ConfigReader(ConfigParser): required_values = { 'DEFAULT': { 'enabled': ('true', 'false'), - 'gift_types': ('All'), - 'pinned': ('false'), 'minimum_points': '%s' % (value_range(0, 400)), 'max_entries': '%s' % (value_range(0, 100000)), 'max_time_left': '%s' % (value_range(0, 21600)), @@ -31,8 +31,6 @@ class ConfigReader(ConfigParser): 'DEFAULT': { 'cookie': '', 'enabled': 'true', - 'gift_types': 'All', - 'pinned': 'false', 'minimum_points': f"{randint(20, 100)}", 'max_entries': f"{randint(1000, 2500)}", 'max_time_left': f"{randint(180,500)}", @@ -46,6 +44,12 @@ class ConfigReader(ConfigParser): 'wishlist.max_time_left': f"{randint(180,500)}" } } + deprecated_values = { + 'DEFAULT': { + 'pinned': 'false', + 'gift_types': 'All' + } + } def __init__(self, config_file): super(ConfigReader, self).__init__() @@ -54,6 +58,7 @@ class ConfigReader(ConfigParser): if modified: with open(config_file, 'w+') as file: self.write(file) + self.find_deprecated() self.validate_config() def create_defaults(self): @@ -68,6 +73,12 @@ class ConfigReader(ConfigParser): modified = True return modified + def find_deprecated(self): + for section, keys in self.deprecated_values.items(): + for key, values in keys.items(): + if key in self[section]: + logger.warn(f"config.ini : Key '{key}' in {section} is no longer used. Please remove.") + def validate_config(self): for section, keys in self.required_values.items(): if section not in self: diff --git a/src/run.py b/src/run.py index aa5a811..b655b6f 100644 --- a/src/run.py +++ b/src/run.py @@ -25,15 +25,13 @@ def run(): config.read(file_name) cookie = config['DEFAULT'].get('cookie') enabled = config['DEFAULT'].getboolean('enabled') - pinned_games = config['DEFAULT'].getboolean('pinned') - gift_types = config['DEFAULT'].get('gift_types') minimum_points = config['DEFAULT'].getint('minimum_points') max_entries = config['DEFAULT'].getint('max_entries') max_time_left = config['DEFAULT'].getint('max_time_left') minimum_game_points = config['DEFAULT'].getint('minimum_game_points') blacklist = config['DEFAULT'].get('blacklist_keywords') - all_page = SteamGifts(cookie, gift_types, pinned_games, minimum_points, max_entries, + all_page = SteamGifts(cookie, 'All', False, minimum_points, max_entries, max_time_left, minimum_game_points, blacklist) wishlist_enabled = config['WISHLIST'].getboolean('wishlist.enabled')