diff --git a/src/bot.py b/src/bot.py index 9f2df02..10c721f 100644 --- a/src/bot.py +++ b/src/bot.py @@ -1,12 +1,20 @@ import logging.config from src.config import settings +import sqlite3 +from src.wiki import Wiki logging.config.dictConfig(settings["logging"]) logger = logging.getLogger("rcgcdb.bot") logger.debug("Current settings: {settings}".format(settings=settings)) -# Fetch basic information about all of the wikis in the database +conn = sqlite3.connect('rcgcdb.db') +c = conn.cursor() +# Fetch basic information about all of the wikis in the database +all_wikis = {} + +for wiki in c.execute('SELECT * FROM wikis'): + all_wikis[wiki[0]] = Wiki() # assign cached information # Start queueing logic diff --git a/src/config.py b/src/config.py index a88d5c1..b970a39 100644 --- a/src/config.py +++ b/src/config.py @@ -1,10 +1,10 @@ import json, sys, logging try: # load settings - with open("settings.json") as sfile: + with open("../settings.json") as sfile: settings = json.load(sfile) if "user-agent" in settings["header"]: - settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.11") # set the version in the useragent + settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.0") # set the version in the useragent except FileNotFoundError: logging.critical("No config file could be found. Please make sure settings.json is in the directory.") sys.exit(1) \ No newline at end of file diff --git a/src/settings.json b/src/settings.json deleted file mode 100644 index 0fe6f5a..0000000 --- a/src/settings.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "header": { - "user-agent": "RcGcDb/{version}" - }, - "logging": { - "version": 1, - "disable_existing_loggers": false, - "formatters": { - "standard": { - "format": "%(name)s - %(levelname)s: %(message)s" - } - }, - "handlers": { - "default": { - "formatter": "standard", - "class": "logging.StreamHandler", - "stream": "ext://sys.stdout" - } - }, - "loggers": { - "": { - "level": 0, - "handlers": [ - "default" - ] - }, - "rcgcdb": {}, - "rcgcdb.bot": {}, - "rcgcdb.config": {}, - "rcgcdb.discord": {} - } - } -} \ No newline at end of file diff --git a/src/wiki.py b/src/wiki.py index a97df02..944ad26 100644 --- a/src/wiki.py +++ b/src/wiki.py @@ -1 +1,5 @@ +from dataclasses import dataclass + +@dataclass class Wiki: + fail_times: int = 0 # corresponding to amount of times connection with wiki failed for client reasons (400-499)