mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
parent
b6065a8188
commit
b63aadb74d
|
@ -36,6 +36,7 @@
|
|||
"show_abuselog": false,
|
||||
"hide_ips": false,
|
||||
"discord_message_cooldown": 0,
|
||||
"datafile_path": "data.json",
|
||||
"auto_suppression": {
|
||||
"enabled": false,
|
||||
"db_location": ":memory:"
|
||||
|
|
|
@ -16,19 +16,18 @@
|
|||
import json
|
||||
import logging
|
||||
import sys
|
||||
|
||||
global settings
|
||||
from src.argparser import command_args
|
||||
|
||||
|
||||
def load_settings():
|
||||
global settings
|
||||
try: # load settings
|
||||
with open("settings.json", encoding="utf8") as sfile:
|
||||
settings = json.load(sfile)
|
||||
if settings["limitrefetch"] < settings["limit"] and settings["limitrefetch"] != -1:
|
||||
settings["limitrefetch"] = settings["limit"]
|
||||
if "user-agent" in settings["header"]:
|
||||
settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.14.0.1") # set the version in the useragent
|
||||
settings = json.load(command_args.settings)
|
||||
if settings["limitrefetch"] < settings["limit"] and settings["limitrefetch"] != -1:
|
||||
settings["limitrefetch"] = settings["limit"]
|
||||
if "user-agent" in settings["header"]:
|
||||
settings["header"]["user-agent"] = settings["header"]["user-agent"].format(version="1.14.0.2") # 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)
|
||||
|
@ -45,4 +44,3 @@ def load_settings():
|
|||
|
||||
load_settings()
|
||||
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class DataFile:
|
|||
if self.changed is False: # don't cause unnecessary write operations
|
||||
return
|
||||
try:
|
||||
with open("data.json", "w", encoding="utf-8") as data_file:
|
||||
with open(settings.get("datafile_path", "data.json"), "w", encoding="utf-8") as data_file:
|
||||
data_file.write(json.dumps(self.data, indent=4))
|
||||
self.changed = False
|
||||
misc_logger.debug("Saving the database succeeded.")
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
# WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT
|
||||
# You have been warned
|
||||
|
||||
import time, logging.config, requests, datetime, math, os.path, schedule, sys, re, importlib
|
||||
import time, logging.config, requests, datetime, math, os.path, schedule, sys, re, importlib, argparse
|
||||
|
||||
import src.misc
|
||||
import src.configloader
|
||||
from collections import defaultdict, Counter, OrderedDict
|
||||
|
||||
from typing import Optional
|
||||
import src.api.client
|
||||
from src.api.context import Context
|
||||
from src.api.hooks import formatter_hooks, pre_hooks, post_hooks
|
||||
from src.configloader import settings
|
||||
from src.misc import add_to_dict, datafile, WIKI_API_PATH, LinkParser, run_hooks
|
||||
from src.api.util import create_article_path, default_message
|
||||
from src.discord.queue import send_to_discord
|
||||
|
@ -37,6 +37,7 @@ from src.exceptions import MWError, ServerError, MediaWikiError, BadRequest, Cli
|
|||
from src.i18n import rcgcdw
|
||||
from src.wiki import Wiki
|
||||
|
||||
settings = src.configloader.settings
|
||||
_ = rcgcdw.gettext
|
||||
ngettext = rcgcdw.ngettext
|
||||
|
||||
|
|
Loading…
Reference in a new issue