diff --git a/rcgcdw.py b/rcgcdw.py index 0052e96..a993922 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -26,10 +26,15 @@ from collections import defaultdict, Counter from urllib.parse import quote_plus from html.parser import HTMLParser -with open("settings.json") as sfile: - settings = json.load(sfile) - if settings["limitrefetch"] < settings["limit"] and settings["limitrefetch"] != -1: - settings["limitrefetch"] = settings["limit"] +try: + with open("settings.json") as sfile: + settings = json.load(sfile) + if settings["limitrefetch"] < settings["limit"] and settings["limitrefetch"] != -1: + settings["limitrefetch"] = settings["limit"] +except FileNotFoundError: + logging.critical("No config file could be found. Please make sure settings.json is in the directory.") + sys.exit(1) + logged_in = False logging.basicConfig(level=settings["verbose_level"]) if settings["limitrefetch"] != -1 and os.path.exists("lastchange.txt") == False: @@ -1128,8 +1133,15 @@ if 1 == 2: _("autoreview"), _("autopatrol"), _("wiki_guardian")) if settings["overview"]: - schedule.every().day.at("{}:{}".format(time.strptime(settings["overview_time"], '%H:%M').tm_hour, - time.strptime(settings["overview_time"], '%H:%M').tm_min)).do(day_overview) + try: + overview_time=time.strptime(settings["overview_time"], '%H:%M') + schedule.every().day.at("{}:{}".format(str(overview_time.tm_hour).zfill(2), + str(overview_time.tm_min).zfill(2))).do(day_overview) + del overview_time + except schedule.ScheduleValueError: + logging.error("Invalid time format! Currently: {}:{}".format(time.strptime(settings["overview_time"], '%H:%M').tm_hour, time.strptime(settings["overview_time"], '%H:%M').tm_min)) + except ValueError: + logging.error("Invalid time format! Currentely: {}. Note: It needs to be in HH:MM format.".format(settings["overview_time"])) schedule.every().day.at("00:00").do(recent_changes.clear_cache) while 1: diff --git a/settings.json.example b/settings.json.example index 9102e77..70a6d8c 100644 --- a/settings.json.example +++ b/settings.json.example @@ -3,7 +3,7 @@ "wiki": "minecraft", "lang": "en", "header": { - "user-agent": "FrisksRcGcDw/1.5.1.1" + "user-agent": "FrisksRcGcDw/1.5.1.2" }, "limit": 11, "webhookURL": "https://discordapp.com/api/webhooks/111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", diff --git a/setup.py b/setup.py index 365f0c0..58bfa84 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='RcGcDw', - version='1.5.1.1', + version='1.5.1.2', packages=['venv.lib.python3.7.site-packages.bs4', 'venv.lib.python3.7.site-packages.bs4.tests', 'venv.lib.python3.7.site-packages.bs4.builder', 'venv.lib.python3.7.site-packages.idna', 'venv.lib.python3.7.site-packages.lxml', 'venv.lib.python3.7.site-packages.lxml.html',