keyword blacklist

- allows for a simple comma separated list of words to look for in a game title and if they exist then ignore the giveaway
This commit is contained in:
mcinj 2022-04-27 14:13:54 -04:00
parent 5402130fbf
commit 55dd027393
3 changed files with 16 additions and 4 deletions

View file

@ -10,4 +10,6 @@ max_entries = 2000
# time left in minutes of a giveaway for it to be considered # time left in minutes of a giveaway for it to be considered
max_time_left = 300 max_time_left = 300
# the minimum point value for a giveaway to be considered # the minimum point value for a giveaway to be considered
minimum_game_points = 5 minimum_game_points = 5
# a comma separated list of keywords in game titles to ignore
blacklist_keywords = hentai,puzzle,adult

View file

@ -15,7 +15,8 @@ logger = log.get_logger(__name__)
class SteamGifts: class SteamGifts:
def __init__(self, cookie, gifts_type, pinned, min_points, max_entries, max_time_left, minimum_game_points): def __init__(self, cookie, gifts_type, pinned, min_points, max_entries,
max_time_left, minimum_game_points, blacklist):
self.cookie = { self.cookie = {
'PHPSESSID': cookie 'PHPSESSID': cookie
} }
@ -25,6 +26,7 @@ class SteamGifts:
self.max_entries = int(max_entries) self.max_entries = int(max_entries)
self.max_time_left = int(max_time_left) self.max_time_left = int(max_time_left)
self.minimum_game_points = int(minimum_game_points) self.minimum_game_points = int(minimum_game_points)
self.blacklist = blacklist.split(',')
self.base = "https://www.steamgifts.com" self.base = "https://www.steamgifts.com"
self.session = requests.Session() self.session = requests.Session()
@ -82,6 +84,12 @@ class SteamGifts:
f"copies) - Created {giveaway.time_created_string} ago with {giveaway.time_remaining_string} remaining." f"copies) - Created {giveaway.time_created_string} ago with {giveaway.time_remaining_string} remaining."
logger.debug(txt) logger.debug(txt)
if self.blacklist is not None and self.blacklist != ['']:
for keyword in self.blacklist:
if giveaway.game_name.find(keyword) != -1:
txt = f"Game {giveaway.game_name} contains the blacklisted keyword {keyword}"
logger.debug(txt)
return False
if self.points - int(giveaway.game_cost) < 0: if self.points - int(giveaway.game_cost) < 0:
txt = f"⛔ Not enough points to enter: {giveaway.game_name}" txt = f"⛔ Not enough points to enter: {giveaway.game_name}"
logger.debug(txt) logger.debug(txt)

View file

@ -34,7 +34,8 @@ class MyConfig(ConfigParser):
'minimum_points': f"{randint(20, 100)}", 'minimum_points': f"{randint(20, 100)}",
'max_entries': f"{randint(1000, 2500)}", 'max_entries': f"{randint(1000, 2500)}",
'max_time_left': f"{randint(180,500)}", 'max_time_left': f"{randint(180,500)}",
'minimum_game_points': '1' 'minimum_game_points': '1',
'blacklist_keywords': 'hentai,puzzle,adult'
} }
} }
@ -101,8 +102,9 @@ def run():
max_entries = config['DEFAULT'].getint('max_entries') max_entries = config['DEFAULT'].getint('max_entries')
max_time_left = config['DEFAULT'].getint('max_time_left') max_time_left = config['DEFAULT'].getint('max_time_left')
minimum_game_points = config['DEFAULT'].getint('minimum_game_points') minimum_game_points = config['DEFAULT'].getint('minimum_game_points')
blacklist = config['DEFAULT'].get('blacklist_keywords')
s = SG(cookie, gift_types, pinned_games, minimum_points, max_entries, max_time_left, minimum_game_points) s = SG(cookie, gift_types, pinned_games, minimum_points, max_entries, max_time_left, minimum_game_points, blacklist)
s.start() s.start()