Few fixes

This commit is contained in:
Frisk 2021-04-24 14:55:37 +02:00
parent 3a23b5c003
commit d725b97c2a
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
6 changed files with 21 additions and 18 deletions

View file

@ -13,4 +13,4 @@
# 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 base import extensions.base

View file

@ -13,4 +13,4 @@
# 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 mediawiki import extensions.base.mediawiki

View file

@ -20,7 +20,7 @@ from src.api import formatter
from src.i18n import rc_formatters from src.i18n import rc_formatters
from src.api.client import Client, client from src.api.client import Client, client
from src.configloader import settings from src.configloader import settings
from src.exceptions import *
_ = rc_formatters.gettext _ = rc_formatters.gettext
@ -59,16 +59,19 @@ class base():
minor=_("m") if action == "edit" and "minor" in change else "", bot=_('b') if "bot" in change else "", minor=_("m") if action == "edit" and "minor" in change else "", bot=_('b') if "bot" in change else "",
space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "") space=" " if "bot" in change or (action == "edit" and "minor" in change) or action == "new" else "")
if settings["appearance"]["embed"]["show_edit_changes"]: if settings["appearance"]["embed"]["show_edit_changes"]:
if action == "new": try:
changed_content = safe_read(recent_changes._safe_request( if action == "new":
"{wiki}?action=compare&format=json&fromtext=&torev={diff}&topst=1&prop=diff".format( changed_content = ctx.client.make_api_request(
wiki=ctx.client.WIKI_API_PATH, diff=change["revid"] "{wiki}?action=compare&format=json&fromtext=&torev={diff}&topst=1&prop=diff".format(
)), "compare", "*") wiki=ctx.client.WIKI_API_PATH, diff=change["revid"]
else: ), "compare", "*")
changed_content = safe_read(recent_changes._safe_request( else:
"{wiki}?action=compare&format=json&fromrev={oldrev}&torev={diff}&topst=1&prop=diff".format( changed_content = ctx.client.make_api_request(
wiki=ctx.client.WIKI_API_PATH, diff=change["revid"], oldrev=change["old_revid"] "{wiki}?action=compare&format=json&fromrev={oldrev}&torev={diff}&topst=1&prop=diff".format(
)), "compare", "*") wiki=ctx.client.WIKI_API_PATH, diff=change["revid"], oldrev=change["old_revid"]
), "compare", "*")
except (ServerError):
changed_content = None
if changed_content: if changed_content:
EditDiff = ctx.client.content_parser() EditDiff = ctx.client.content_parser()
EditDiff.feed(changed_content) EditDiff.feed(changed_content)

View file

@ -61,5 +61,4 @@ class Client:
return self.__recent_changes.api_request(params, *json_path, timeout, allow_redirects) return self.__recent_changes.api_request(params, *json_path, timeout, allow_redirects)
client = Client() client = Client()
client.make_api_request()

View file

@ -13,7 +13,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/>.
from src.rcgcdw import formatter_hooks import src.rcgcdw
from src.configloader import settings from src.configloader import settings
from src.exceptions import FormatterBreaksAPISpec from src.exceptions import FormatterBreaksAPISpec
from src.discord.message import DiscordMessage from src.discord.message import DiscordMessage
@ -35,7 +35,7 @@ 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:
formatter_hooks[action_type] = func src.rcgcdw.formatter_hooks[action_type] = func
def embed(**kwargs): def embed(**kwargs):

View file

@ -47,9 +47,10 @@ 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 from src.migrations import * # migrations after logging
try: try:
import exceptions import extensions
except ImportError: except ImportError:
logger.critical("No extensions module found. What's going on?") logger.critical("No extensions module found. What's going on?")
raise
sys.exit(1) sys.exit(1)
storage = datafile storage = datafile