Track DLC page, fix dependencies, refactor config
This commit is contained in:
parent
cc1cbc08f4
commit
e197a19f1c
4 changed files with 70 additions and 32 deletions
|
@ -2,16 +2,18 @@
|
||||||
cookie = PHPSESSIONCOOKIEGOESHERE
|
cookie = PHPSESSIONCOOKIEGOESHERE
|
||||||
# should we consider giveaways on the 'ALL' page? it is the main page
|
# should we consider giveaways on the 'ALL' page? it is the main page
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
||||||
|
[ALL]
|
||||||
# minimum number of points in your account before entering into giveaways
|
# minimum number of points in your account before entering into giveaways
|
||||||
minimum_points = 50
|
all.minimum_points = 50
|
||||||
# max number of entries in a giveaway for it to be considered
|
# max number of entries in a giveaway for it to be considered
|
||||||
max_entries = 2000
|
all.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
|
all.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 = 1
|
all.minimum_game_points = 1
|
||||||
# a comma separated list of keywords in game titles to ignore
|
# a comma separated list of keywords in game titles to ignore
|
||||||
blacklist_keywords = hentai,adult
|
all.blacklist_keywords = hentai,adult
|
||||||
|
|
||||||
[WISHLIST]
|
[WISHLIST]
|
||||||
# should we consider giveaways on the 'Wishlist' page?
|
# should we consider giveaways on the 'Wishlist' page?
|
||||||
|
@ -23,6 +25,16 @@ wishlist.max_entries = 10000
|
||||||
# time left in minutes of a giveaway for it to be considered
|
# time left in minutes of a giveaway for it to be considered
|
||||||
wishlist.max_time_left = 300
|
wishlist.max_time_left = 300
|
||||||
|
|
||||||
|
[DLC]
|
||||||
|
# should we consider giveaways on the 'DLC' page?
|
||||||
|
dlc.enabled = true
|
||||||
|
# minimum number of points in your account before entering into giveaways
|
||||||
|
dlc.minimum_points = 1
|
||||||
|
# max number of entries in a giveaway for it to be considered
|
||||||
|
dlc.max_entries = 10000
|
||||||
|
# time left in minutes of a giveaway for it to be considered
|
||||||
|
dlc.max_time_left = 300
|
||||||
|
|
||||||
[NOTIFICATIONS]
|
[NOTIFICATIONS]
|
||||||
# a prefix for messages sent via notifications
|
# a prefix for messages sent via notifications
|
||||||
notification.prefix = SG-Bot
|
notification.prefix = SG-Bot
|
||||||
|
|
|
@ -10,3 +10,4 @@ Flask==2.1.2
|
||||||
Flask-BasicAuth==0.2.0
|
Flask-BasicAuth==0.2.0
|
||||||
pyopenssl==22.0.0
|
pyopenssl==22.0.0
|
||||||
apscheduler==3.9.1
|
apscheduler==3.9.1
|
||||||
|
werkzeug==2.2.2
|
||||||
|
|
|
@ -29,11 +29,13 @@ def choose_user_agent():
|
||||||
class ConfigReader(ConfigParser):
|
class ConfigReader(ConfigParser):
|
||||||
required_values = {
|
required_values = {
|
||||||
'DEFAULT': {
|
'DEFAULT': {
|
||||||
'enabled': ('true', 'false'),
|
},
|
||||||
'minimum_points': '%s' % (value_range(0, 400)),
|
'ALL': {
|
||||||
'max_entries': '%s' % (value_range(0, 100000)),
|
'all.enabled': ('true', 'false'),
|
||||||
'max_time_left': '%s' % (value_range(0, 21600)),
|
'all.minimum_points': '%s' % (value_range(0, 400)),
|
||||||
'minimum_game_points': '%s' % (value_range(0, 50))
|
'all.max_entries': '%s' % (value_range(0, 100000)),
|
||||||
|
'all.max_time_left': '%s' % (value_range(0, 21600)),
|
||||||
|
'all.minimum_game_points': '%s' % (value_range(0, 50))
|
||||||
},
|
},
|
||||||
'WISHLIST': {
|
'WISHLIST': {
|
||||||
'wishlist.enabled': ('true', 'false'),
|
'wishlist.enabled': ('true', 'false'),
|
||||||
|
@ -52,13 +54,15 @@ class ConfigReader(ConfigParser):
|
||||||
default_values = {
|
default_values = {
|
||||||
'DEFAULT': {
|
'DEFAULT': {
|
||||||
'cookie': '',
|
'cookie': '',
|
||||||
'user_agent': f"{choose_user_agent()}",
|
'user_agent': f"{choose_user_agent()}"
|
||||||
'enabled': 'true',
|
},
|
||||||
'minimum_points': f"{randint(20, 50)}",
|
'ALL': {
|
||||||
'max_entries': f"{randint(1000, 2500)}",
|
'all.enabled': 'true',
|
||||||
'max_time_left': f"{randint(180, 500)}",
|
'all.minimum_points': f"{randint(20, 50)}",
|
||||||
'minimum_game_points': "0",
|
'all.max_entries': f"{randint(1000, 2500)}",
|
||||||
'blacklist_keywords': 'hentai,adult'
|
'all.max_time_left': f"{randint(180, 500)}",
|
||||||
|
'all.minimum_game_points': "0",
|
||||||
|
'all.blacklist_keywords': 'hentai,adult'
|
||||||
},
|
},
|
||||||
'WISHLIST': {
|
'WISHLIST': {
|
||||||
'wishlist.enabled': 'true',
|
'wishlist.enabled': 'true',
|
||||||
|
@ -66,6 +70,12 @@ class ConfigReader(ConfigParser):
|
||||||
'wishlist.max_entries': f"{randint(10000, 100000)}",
|
'wishlist.max_entries': f"{randint(10000, 100000)}",
|
||||||
'wishlist.max_time_left': f"{randint(180, 500)}"
|
'wishlist.max_time_left': f"{randint(180, 500)}"
|
||||||
},
|
},
|
||||||
|
'DLC': {
|
||||||
|
'dlc.enabled': 'true',
|
||||||
|
'dlc.minimum_points': '1',
|
||||||
|
'dlc.max_entries': f"{randint(10000, 100000)}",
|
||||||
|
'dlc.max_time_left': f"{randint(180, 500)}"
|
||||||
|
},
|
||||||
'NOTIFICATIONS': {
|
'NOTIFICATIONS': {
|
||||||
'notification.prefix': '',
|
'notification.prefix': '',
|
||||||
'pushover.enabled': 'false',
|
'pushover.enabled': 'false',
|
||||||
|
|
|
@ -24,18 +24,22 @@ class GiveawayThread(threading.Thread):
|
||||||
self.won_giveaway_job_id = 'eval_won_giveaways'
|
self.won_giveaway_job_id = 'eval_won_giveaways'
|
||||||
self.evaluate_giveaway_job_id = 'eval_giveaways'
|
self.evaluate_giveaway_job_id = 'eval_giveaways'
|
||||||
|
|
||||||
if config['DEFAULT'].getboolean('enabled'):
|
self._all_page = None
|
||||||
cookie = config['DEFAULT'].get('cookie')
|
self._wishlist_page = None
|
||||||
user_agent = config['DEFAULT'].get('user_agent')
|
self._dlc_page = None
|
||||||
|
|
||||||
minimum_points = config['DEFAULT'].getint('minimum_points')
|
cookie = config['DEFAULT'].get('cookie')
|
||||||
max_entries = config['DEFAULT'].getint('max_entries')
|
user_agent = config['DEFAULT'].get('user_agent')
|
||||||
max_time_left = config['DEFAULT'].getint('max_time_left')
|
|
||||||
minimum_game_points = config['DEFAULT'].getint('minimum_game_points')
|
|
||||||
blacklist = config['DEFAULT'].get('blacklist_keywords')
|
|
||||||
|
|
||||||
self._all_page = EnterGiveaways(cookie, user_agent, 'All', False, minimum_points, max_entries,
|
if config['ALL'].getboolean('all.enabled'):
|
||||||
max_time_left, minimum_game_points, blacklist, notification)
|
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_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)
|
||||||
|
|
||||||
if config['WISHLIST'].getboolean('wishlist.enabled'):
|
if config['WISHLIST'].getboolean('wishlist.enabled'):
|
||||||
wishlist_minimum_points = config['WISHLIST'].getint('wishlist.minimum_points')
|
wishlist_minimum_points = config['WISHLIST'].getint('wishlist.minimum_points')
|
||||||
|
@ -45,8 +49,16 @@ class GiveawayThread(threading.Thread):
|
||||||
self._wishlist_page = EnterGiveaways(cookie, user_agent, 'Wishlist', False, wishlist_minimum_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, 0, '', notification)
|
||||||
|
|
||||||
if not self._all_page and not self._wishlist_page:
|
if config['DLC'].getboolean('dlc.enabled'):
|
||||||
logger.error("⁉️ Both 'Default' and 'Wishlist' configurations are disabled. Nothing will run. Exiting...")
|
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')
|
||||||
|
|
||||||
|
self._dlc_page = EnterGiveaways(cookie, user_agent, 'DLC', False, dlc_minimum_points,
|
||||||
|
dlc_max_entries, dlc_max_time_left, 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...")
|
||||||
sleep(10)
|
sleep(10)
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
@ -69,7 +81,7 @@ class GiveawayThread(threading.Thread):
|
||||||
if evaluate_giveaway_job:
|
if evaluate_giveaway_job:
|
||||||
logger.debug("Previous giveaway evaluator job exists. Removing.")
|
logger.debug("Previous giveaway evaluator job exists. Removing.")
|
||||||
evaluate_giveaway_job.remove()
|
evaluate_giveaway_job.remove()
|
||||||
runner = GiveawayThread.GiveawayRunner(self._wishlist_page, self._all_page,
|
runner = GiveawayThread.GiveawayRunner(self._dlc_page, self._wishlist_page, self._all_page,
|
||||||
self.evaluate_giveaway_job_id)
|
self.evaluate_giveaway_job_id)
|
||||||
self._scheduler.add_job(runner.run,
|
self._scheduler.add_job(runner.run,
|
||||||
id=self.evaluate_giveaway_job_id,
|
id=self.evaluate_giveaway_job_id,
|
||||||
|
@ -116,13 +128,16 @@ class GiveawayThread(threading.Thread):
|
||||||
|
|
||||||
class GiveawayRunner:
|
class GiveawayRunner:
|
||||||
|
|
||||||
def __init__(self, wishlist_page, all_page, job_id):
|
def __init__(self, dlc_page, wishlist_page, all_page, job_id):
|
||||||
|
self._dlc_page = dlc_page
|
||||||
self._wishlist_page = wishlist_page
|
self._wishlist_page = wishlist_page
|
||||||
self._all_page = all_page
|
self._all_page = all_page
|
||||||
self._job_id = job_id
|
self._job_id = job_id
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logger.info("🟢 Evaluating giveaways.")
|
logger.info("🟢 Evaluating giveaways.")
|
||||||
|
if self._dlc_page:
|
||||||
|
self._dlc_page.start()
|
||||||
if self._wishlist_page:
|
if self._wishlist_page:
|
||||||
self._wishlist_page.start()
|
self._wishlist_page.start()
|
||||||
if self._all_page:
|
if self._all_page:
|
||||||
|
|
Loading…
Reference in a new issue