some cleanup

This commit is contained in:
mcinj 2022-05-12 11:54:58 -04:00
parent de4450a29a
commit 6d57c1c4f2
5 changed files with 13 additions and 10 deletions

View file

@ -4,7 +4,7 @@ RUN mkdir -p /app
WORKDIR /app WORKDIR /app
# resolves gcc issue with installing regex dependency # resolves gcc issue with installing regex dependency
RUN apk add build-base tzdata --no-cache RUN apk add tzdata --no-cache
ENV TZ=America/New_York ENV TZ=America/New_York
ENV VIRTUAL_ENV=/app/env ENV VIRTUAL_ENV=/app/env

View file

@ -9,9 +9,10 @@ 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 = 50 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 blacklist_keywords = hentai,adult
[WISHLIST] [WISHLIST]
# should we consider giveaways on the 'Wishlist' page? # should we consider giveaways on the 'Wishlist' page?
wishlist.enabled = true wishlist.enabled = true
@ -21,6 +22,7 @@ wishlist.minimum_points = 1
wishlist.max_entries = 10000 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
[NOTIFICATIONS] [NOTIFICATIONS]
# a prefix for messages sent via notifications # a prefix for messages sent via notifications
notification.prefix = SG-Bot notification.prefix = SG-Bot

View file

@ -1,5 +1,6 @@
from configparser import ConfigParser from configparser import ConfigParser
from random import randint from random import randint
import log import log
logger = log.get_logger(__name__) logger = log.get_logger(__name__)
@ -35,10 +36,10 @@ class ConfigReader(ConfigParser):
'DEFAULT': { 'DEFAULT': {
'cookie': '', 'cookie': '',
'enabled': 'true', 'enabled': 'true',
'minimum_points': f"{randint(20, 100)}", 'minimum_points': f"{randint(20, 50)}",
'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': f"{randint(20, 100)}", 'minimum_game_points': "0",
'blacklist_keywords': 'hentai,adult' 'blacklist_keywords': 'hentai,adult'
}, },
'WISHLIST': { 'WISHLIST': {

View file

@ -35,7 +35,7 @@ def run():
try: try:
cookie = config['DEFAULT'].get('cookie') cookie = config['DEFAULT'].get('cookie')
enabled = config['DEFAULT'].getboolean('enabled') main_page_enabled = config['DEFAULT'].getboolean('enabled')
minimum_points = config['DEFAULT'].getint('minimum_points') minimum_points = config['DEFAULT'].getint('minimum_points')
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')
@ -45,7 +45,7 @@ def run():
all_page = SteamGifts(cookie, 'All', False, minimum_points, max_entries, all_page = SteamGifts(cookie, 'All', False, minimum_points, max_entries,
max_time_left, minimum_game_points, blacklist, notification) max_time_left, minimum_game_points, blacklist, notification)
wishlist_enabled = config['WISHLIST'].getboolean('wishlist.enabled') wishlist_page_enabled = config['WISHLIST'].getboolean('wishlist.enabled')
wishlist_minimum_points = config['WISHLIST'].getint('wishlist.minimum_points') wishlist_minimum_points = config['WISHLIST'].getint('wishlist.minimum_points')
wishlist_max_entries = config['WISHLIST'].getint('wishlist.max_entries') wishlist_max_entries = config['WISHLIST'].getint('wishlist.max_entries')
wishlist_max_time_left = config['WISHLIST'].getint('wishlist.max_time_left') wishlist_max_time_left = config['WISHLIST'].getint('wishlist.max_time_left')
@ -53,15 +53,15 @@ def run():
wishlist_page = SteamGifts(cookie, 'Wishlist', False, wishlist_minimum_points, wishlist_page = SteamGifts(cookie, '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 enabled and not wishlist_enabled: if not main_page_enabled and not wishlist_page_enabled:
logger.error("Both 'Default' and 'Wishlist' configurations are disabled. Nothing will run. Exiting...") logger.error("Both 'Default' and 'Wishlist' configurations are disabled. Nothing will run. Exiting...")
sleep(10) sleep(10)
exit(-1) exit(-1)
while True: while True:
if wishlist_enabled: if wishlist_page_enabled:
wishlist_page.start() wishlist_page.start()
if enabled: if main_page_enabled:
all_page.start() all_page.start()
random_seconds = randint(1740, 3540) # sometime between 29-59 minutes random_seconds = randint(1740, 3540) # sometime between 29-59 minutes

View file

@ -1,6 +1,6 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from dateutil import tz
from dateutil import tz
from sqlalchemy import create_engine, Integer, String, Column, DateTime, Boolean, func, ForeignKey from sqlalchemy import create_engine, Integer, String, Column, DateTime, Boolean, func, ForeignKey
from sqlalchemy.orm import registry, relationship, Session from sqlalchemy.orm import registry, relationship, Session
from sqlalchemy_utils import database_exists, create_database from sqlalchemy_utils import database_exists, create_database