mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Fixes
This commit is contained in:
parent
2b2eeaafba
commit
18aae9eabe
|
@ -94,6 +94,6 @@ class base():
|
||||||
logger.warning("Unable to download data on the edit content!")
|
logger.warning("Unable to download data on the edit content!")
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@formatter.compact(event="edit", mode="embed")
|
@formatter.compact(event="edit", mode="compact")
|
||||||
def compact_edit(self, change: dict):
|
def compact_edit(self, ctx: Context, change: dict):
|
||||||
return DiscordMessage()
|
return DiscordMessage()
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import src.api.hooks
|
||||||
import src.rcgcdw
|
|
||||||
import logging
|
import logging
|
||||||
from src.configloader import settings
|
from src.configloader import settings
|
||||||
from src.exceptions import FormatterBreaksAPISpec
|
from src.exceptions import FormatterBreaksAPISpec
|
||||||
|
@ -37,11 +36,11 @@ def _register_formatter(func: Callable[[dict], DiscordMessage], kwargs: dict[str
|
||||||
if action_type is None:
|
if action_type is None:
|
||||||
raise FormatterBreaksAPISpec("event type")
|
raise FormatterBreaksAPISpec("event type")
|
||||||
if settings["appearance"]["mode"] == formatter_type:
|
if settings["appearance"]["mode"] == formatter_type:
|
||||||
if action_type in src.rcgcdw.formatter_hooks:
|
if action_type in src.api.hooks.formatter_hooks:
|
||||||
logger.warning(f"Action {action_type} is already defined inside of "
|
logger.warning(f"Action {action_type} is already defined inside of "
|
||||||
f"{src.rcgcdw.formatter_hooks[action_type].__module__}! "
|
f"{src.api.hooks.formatter_hooks[action_type].__module__}! "
|
||||||
f"Overwriting it with one from {func.__module__}")
|
f"Overwriting it with one from {func.__module__}")
|
||||||
src.rcgcdw.formatter_hooks[action_type] = func
|
src.api.hooks.formatter_hooks[action_type] = func
|
||||||
|
|
||||||
|
|
||||||
def embed(**kwargs):
|
def embed(**kwargs):
|
||||||
|
@ -59,7 +58,7 @@ def embed(**kwargs):
|
||||||
return decorator_cont
|
return decorator_cont
|
||||||
|
|
||||||
|
|
||||||
def compact(func: Callable[[dict], DiscordMessage], **kwargs):
|
def compact(**kwargs):
|
||||||
"""
|
"""
|
||||||
Decorator to register a formatter are return a function
|
Decorator to register a formatter are return a function
|
||||||
|
|
||||||
|
@ -72,4 +71,4 @@ def compact(func: Callable[[dict], DiscordMessage], **kwargs):
|
||||||
_register_formatter(func, kwargs, "compact")
|
_register_formatter(func, kwargs, "compact")
|
||||||
return func
|
return func
|
||||||
|
|
||||||
return decorator_cont
|
return decorator_cont
|
||||||
|
|
17
src/api/hooks.py
Normal file
17
src/api/hooks.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
|
||||||
|
#
|
||||||
|
# RcGcDw is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# RcGcDw is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Made just to avoid circular imports
|
||||||
|
formatter_hooks = {}
|
|
@ -19,7 +19,7 @@
|
||||||
# WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT
|
# WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT
|
||||||
# You have been warned
|
# You have been warned
|
||||||
|
|
||||||
import time, logging.config, requests, datetime, gettext, math, os.path, schedule, sys, re
|
import time, logging.config, requests, datetime, math, os.path, schedule, sys, re
|
||||||
|
|
||||||
import src.misc
|
import src.misc
|
||||||
from collections import defaultdict, Counter
|
from collections import defaultdict, Counter
|
||||||
|
@ -27,6 +27,7 @@ from collections import defaultdict, Counter
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
import src.api.client
|
import src.api.client
|
||||||
from src.api.context import Context
|
from src.api.context import Context
|
||||||
|
from src.api.hooks import formatter_hooks
|
||||||
from src.configloader import settings
|
from src.configloader import settings
|
||||||
from src.misc import add_to_dict, datafile, \
|
from src.misc import add_to_dict, datafile, \
|
||||||
WIKI_API_PATH
|
WIKI_API_PATH
|
||||||
|
@ -44,13 +45,11 @@ if settings["fandom_discussions"]["enabled"]:
|
||||||
import src.discussions
|
import src.discussions
|
||||||
|
|
||||||
TESTING = True if "--test" in sys.argv else False # debug mode, pipeline testing
|
TESTING = True if "--test" in sys.argv else False # debug mode, pipeline testing
|
||||||
formatter_hooks = {}
|
|
||||||
# Prepare logging
|
# Prepare logging
|
||||||
|
|
||||||
logging.config.dictConfig(settings["logging"])
|
logging.config.dictConfig(settings["logging"])
|
||||||
logger = logging.getLogger("rcgcdw")
|
logger = logging.getLogger("rcgcdw")
|
||||||
logger.debug("Current settings: {settings}".format(settings=settings))
|
logger.debug("Current settings: {settings}".format(settings=settings))
|
||||||
from src.migrations import * # migrations after logging
|
|
||||||
|
|
||||||
|
|
||||||
def load_extensions():
|
def load_extensions():
|
||||||
|
|
Loading…
Reference in a new issue