Add max points, add missing config constraints and default values
This commit is contained in:
parent
e197a19f1c
commit
893229363f
3 changed files with 27 additions and 10 deletions
|
@ -35,13 +35,22 @@ class ConfigReader(ConfigParser):
|
|||
'all.minimum_points': '%s' % (value_range(0, 400)),
|
||||
'all.max_entries': '%s' % (value_range(0, 100000)),
|
||||
'all.max_time_left': '%s' % (value_range(0, 21600)),
|
||||
'all.max_points': '%s' % (value_range(0, 400)),
|
||||
'all.minimum_game_points': '%s' % (value_range(0, 50))
|
||||
},
|
||||
'WISHLIST': {
|
||||
'wishlist.enabled': ('true', 'false'),
|
||||
'wishlist.minimum_points': '%s' % (value_range(0, 400)),
|
||||
'wishlist.max_entries': '%s' % (value_range(0, 100000)),
|
||||
'wishlist.max_time_left': '%s' % (value_range(0, 21600))
|
||||
'wishlist.max_time_left': '%s' % (value_range(0, 21600)),
|
||||
'wishlist.max_points': '%s' % (value_range(0, 400)),
|
||||
},
|
||||
'DLC': {
|
||||
'dlc.enabled': ('true', 'false'),
|
||||
'dlc.minimum_points': '%s' % (value_range(0, 400)),
|
||||
'dlc.max_entries': '%s' % (value_range(0, 100000)),
|
||||
'dlc.max_time_left': '%s' % (value_range(0, 21600)),
|
||||
'dlc.max_points': '%s' % (value_range(0, 400)),
|
||||
},
|
||||
'NOTIFICATIONS': {
|
||||
'pushover.enabled': ('true', 'false'),
|
||||
|
@ -61,6 +70,7 @@ class ConfigReader(ConfigParser):
|
|||
'all.minimum_points': f"{randint(20, 50)}",
|
||||
'all.max_entries': f"{randint(1000, 2500)}",
|
||||
'all.max_time_left': f"{randint(180, 500)}",
|
||||
'all.max_points': f"{randint(300, 400)}",
|
||||
'all.minimum_game_points': "0",
|
||||
'all.blacklist_keywords': 'hentai,adult'
|
||||
},
|
||||
|
@ -68,13 +78,15 @@ class ConfigReader(ConfigParser):
|
|||
'wishlist.enabled': 'true',
|
||||
'wishlist.minimum_points': '1',
|
||||
'wishlist.max_entries': f"{randint(10000, 100000)}",
|
||||
'wishlist.max_time_left': f"{randint(180, 500)}"
|
||||
'wishlist.max_time_left': f"{randint(180, 500)}",
|
||||
'wishlist.max_points': f"{randint(300, 400)}",
|
||||
},
|
||||
'DLC': {
|
||||
'dlc.enabled': 'true',
|
||||
'dlc.minimum_points': '1',
|
||||
'dlc.max_entries': f"{randint(10000, 100000)}",
|
||||
'dlc.max_time_left': f"{randint(180, 500)}"
|
||||
'dlc.max_time_left': f"{randint(180, 500)}",
|
||||
'dlc.max_points': f"{randint(300, 400)}",
|
||||
},
|
||||
'NOTIFICATIONS': {
|
||||
'notification.prefix': '',
|
||||
|
|
|
@ -21,7 +21,7 @@ class SteamGiftsException(Exception):
|
|||
class EnterGiveaways:
|
||||
|
||||
def __init__(self, cookie, user_agent, gifts_type, pinned, min_points, max_entries,
|
||||
max_time_left, minimum_game_points, blacklist, notification):
|
||||
max_time_left, max_points, minimum_game_points, blacklist, notification):
|
||||
self._contributor_level = None
|
||||
self._xsrf_token = None
|
||||
self._points = None
|
||||
|
@ -34,6 +34,7 @@ class EnterGiveaways:
|
|||
self._min_points = int(min_points)
|
||||
self._max_entries = int(max_entries)
|
||||
self._max_time_left = int(max_time_left)
|
||||
self._max_points = int(max_points)
|
||||
self._minimum_game_points = int(minimum_game_points)
|
||||
self._blacklist = blacklist.split(',')
|
||||
self._notification = notification
|
||||
|
@ -137,12 +138,12 @@ class EnterGiveaways:
|
|||
f"level to enter. Your level: {self._contributor_level}"
|
||||
logger.info(txt)
|
||||
return False
|
||||
if giveaway.time_remaining_in_minutes > self._max_time_left:
|
||||
if giveaway.time_remaining_in_minutes > self._max_time_left and self._points < self._max_points:
|
||||
txt = f"〰️ Game {giveaway.game_name} has {giveaway.time_remaining_in_minutes} minutes left and is " \
|
||||
f"above your cutoff of {self._max_time_left} minutes."
|
||||
logger.info(txt)
|
||||
return False
|
||||
if giveaway.game_entries / giveaway.copies > self._max_entries:
|
||||
if giveaway.game_entries / giveaway.copies > self._max_entries and self._points < self._max_points:
|
||||
txt = f"〰️ Game {giveaway.game_name} has {giveaway.game_entries} entries and is above your cutoff " \
|
||||
f"of {self._max_entries} entries."
|
||||
logger.info(txt)
|
||||
|
@ -236,7 +237,8 @@ class EnterGiveaways:
|
|||
# max time left amount, then we don't need to continue to look at giveaways as any
|
||||
# after this point will also exceed the max time left
|
||||
if self._gifts_type != "New" and not giveaway.pinned and \
|
||||
giveaway.time_remaining_in_minutes > self._max_time_left:
|
||||
giveaway.time_remaining_in_minutes > self._max_time_left and \
|
||||
self._points < self._max_points:
|
||||
logger.info("🟡 We have run out of gifts to consider.")
|
||||
run = False
|
||||
break
|
||||
|
|
|
@ -35,27 +35,30 @@ class GiveawayThread(threading.Thread):
|
|||
all_minimum_points = config['ALL'].getint('all.minimum_points')
|
||||
all_max_entries = config['ALL'].getint('all.max_entries')
|
||||
all_max_time_left = config['ALL'].getint('all.max_time_left')
|
||||
all_max_points = config['ALL'].getint('all.max_points')
|
||||
all_minimum_game_points = config['DEFAULT'].getint('minimum_game_points')
|
||||
all_blacklist = config['DEFAULT'].get('blacklist_keywords')
|
||||
|
||||
self._all_page = EnterGiveaways(cookie, user_agent, 'All', False, all_minimum_points, all_max_entries,
|
||||
all_max_time_left, all_minimum_game_points, all_blacklist, notification)
|
||||
all_max_time_left, all_max_points, all_minimum_game_points, all_blacklist, notification)
|
||||
|
||||
if config['WISHLIST'].getboolean('wishlist.enabled'):
|
||||
wishlist_minimum_points = config['WISHLIST'].getint('wishlist.minimum_points')
|
||||
wishlist_max_entries = config['WISHLIST'].getint('wishlist.max_entries')
|
||||
wishlist_max_time_left = config['WISHLIST'].getint('wishlist.max_time_left')
|
||||
wishlist_max_points = config['WISHLIST'].getint('wishlist.max_points')
|
||||
|
||||
self._wishlist_page = EnterGiveaways(cookie, user_agent, 'Wishlist', False, wishlist_minimum_points,
|
||||
wishlist_max_entries, wishlist_max_time_left, 0, '', notification)
|
||||
wishlist_max_entries, wishlist_max_time_left, wishlist_max_points, 0, '', notification)
|
||||
|
||||
if config['DLC'].getboolean('dlc.enabled'):
|
||||
dlc_minimum_points = config['DLC'].getint('dlc.minimum_points')
|
||||
dlc_max_entries = config['DLC'].getint('dlc.max_entries')
|
||||
dlc_max_time_left = config['DLC'].getint('dlc.max_time_left')
|
||||
dlc_max_points = config['DLC'].getint('dlc.max_points')
|
||||
|
||||
self._dlc_page = EnterGiveaways(cookie, user_agent, 'DLC', False, dlc_minimum_points,
|
||||
dlc_max_entries, dlc_max_time_left, 0, '', notification)
|
||||
dlc_max_entries, dlc_max_time_left, dlc_max_points, 0, '', notification)
|
||||
|
||||
if not self._all_page and not self._wishlist_page and not self._dlc_page :
|
||||
logger.error("⁉️ 'All', 'Wishlist' and 'DLC' configurations are disabled. Nothing will run. Exiting...")
|
||||
|
|
Loading…
Reference in a new issue