mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Added some slightly modified code for reporting unknown events from RcGcDb contributed by @MarkusRost
This commit is contained in:
parent
62702229e7
commit
30426cb8f3
|
@ -54,7 +54,12 @@ def compact_formatter(post_type, post):
|
|||
else:
|
||||
message = _("[{author}]({author_url}) created a [reply](<{url}wiki/{article}?threadId={threadId}) to a [comment](<{url}wiki/{article}?commentId={commentId}&replyId={replyId}>) on [{article}](<{url}wiki/{article}>)").format(author=author, author_url=author_url, url=settings["fandom_discussions"]["wiki_url"], article=article_page, commentId=post["threadId"], replyId=post["id"])
|
||||
else:
|
||||
discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(post_type))
|
||||
discussion_logger.warning("No entry for {event} with params: {params}".format(event=post_type, params=post))
|
||||
if not settings["support"]:
|
||||
return
|
||||
else:
|
||||
content = _("Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(
|
||||
event=post_type, author=author, author_url=author_url, support=settings["support"])
|
||||
send_to_discord(DiscordMessage("compact", "discussion", settings["fandom_discussions"]["webhookURL"], content=message))
|
||||
|
||||
|
||||
|
@ -136,7 +141,16 @@ def embed_formatter(post_type, post):
|
|||
embed["title"] = _("Replied to a comment on {article}").format(article=article_page)
|
||||
embed["footer"]["text"] = article_page
|
||||
else:
|
||||
discussion_logger.warning("The type of {} is an unknown discussion post type. Please post an issue on the project page to have it added https://gitlab.com/piotrex43/RcGcDw/-/issues.".format(post_type))
|
||||
discussion_logger.warning("No entry for {event} with params: {params}".format(event=post_type, params=post))
|
||||
embed["title"] = _("Unknown event `{event}`").format(event=post_type)
|
||||
embed["color"] = 0
|
||||
if settings.get("support", None):
|
||||
change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(post, indent=2),
|
||||
support=settings["support"])
|
||||
if len(change_params) > 1000:
|
||||
embed.add_field(_("Report this on the support server"), settings["support"])
|
||||
else:
|
||||
embed.add_field(_("Report this on the support server"), change_params)
|
||||
embed.finish_embed()
|
||||
send_to_discord(embed)
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import re
|
|||
import time
|
||||
import logging
|
||||
import datetime
|
||||
import json
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
@ -321,7 +322,12 @@ def compact_formatter(action, change, parsed_comment, categories, recent_changes
|
|||
content = _("An action has been hidden by administration.")
|
||||
else:
|
||||
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
||||
return
|
||||
if not settings.get("support", None):
|
||||
return
|
||||
else:
|
||||
content = _(
|
||||
"Unknown event `{event}` by [{author}]({author_url}), report it on the [support server](<{support}>).").format(
|
||||
event=action, author=author, author_url=author_url, support=settings["support"])
|
||||
send_to_discord(DiscordMessage("compact", action, settings["webhookURL"], content=content))
|
||||
|
||||
|
||||
|
@ -751,6 +757,16 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
|
|||
embed["author"]["name"] = _("Unknown")
|
||||
else:
|
||||
logger.warning("No entry for {event} with params: {params}".format(event=action, params=change))
|
||||
link = create_article_path("Special:RecentChanges")
|
||||
embed["title"] = _("Unknown event `{event}`").format(event=action)
|
||||
embed["color"] = 0
|
||||
if settings.get("support", None):
|
||||
change_params = "[```json\n{params}\n```]({support})".format(params=json.dumps(change, indent=2),
|
||||
support=settings["support"])
|
||||
if len(change_params) > 1000:
|
||||
embed.add_field(_("Report this on the support server"), settings["support"])
|
||||
else:
|
||||
embed.add_field(_("Report this on the support server"), change_params)
|
||||
embed["author"]["icon_url"] = settings["appearance"]["embed"][action]["icon"]
|
||||
embed["url"] = link
|
||||
if parsed_comment is not None:
|
||||
|
|
Loading…
Reference in a new issue