mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Completed the work on #61?
This commit is contained in:
parent
e03362ad26
commit
79df8e331a
267
rcgcdw.py
267
rcgcdw.py
|
@ -158,7 +158,6 @@ def compact_formatter(action, change, parsed_comment, categories):
|
|||
author_url = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=change["user"].replace(" ", "_"))
|
||||
author = change["user"]
|
||||
parsed_comment = "" if parsed_comment is None else " (*"+parsed_comment+"*)"
|
||||
content = "[{author}]({author_url}) {action} ".format(author=author, author_url=author_url, action=action_list[action])
|
||||
if action in ["edit", "new"]:
|
||||
edit_link = "https://{wiki}.gamepedia.com/index.php?title={article}&curid={pageid}&diff={diff}&oldid={oldrev}".format(
|
||||
wiki=settings["wiki"], pageid=change["pageid"], diff=change["revid"], oldrev=change["old_revid"],
|
||||
|
@ -170,22 +169,277 @@ def compact_formatter(action, change, parsed_comment, categories):
|
|||
sign = ""
|
||||
else:
|
||||
sign = "-"
|
||||
content += "[{article}]({edit_link}){comment} ({sign}{edit_size})".format(article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size)
|
||||
elif action in ("upload/overwrite", "upload/upload"):
|
||||
if action == "edit":
|
||||
content = _("[{author}]({author_url}) edited [{article}]({edit_link}){comment} ({sign}{edit_size})").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size)
|
||||
else:
|
||||
content = _("[{author}]({author_url}) created [{article}]({edit_link}){comment} ({sign}{edit_size})").format(author=author, author_url=author_url, article=change["title"], edit_link=edit_link, comment=parsed_comment, edit_size=edit_size)
|
||||
elif action =="upload/upload":
|
||||
file_link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content += "[{file}]({file_link}){comment}".format(file=change["title"], file_link=file_link, comment=parsed_comment)
|
||||
content = _("[{author}]({author_url}) uploaded [{file}]({file_link}){comment}").format(author=author,
|
||||
author_url=author_url,
|
||||
file=change["title"],
|
||||
file_link=file_link,
|
||||
comment=parsed_comment)
|
||||
elif action == "upload/overwrite":
|
||||
file_link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) uploaded a new version of [{file}]({file_link}){comment}").format(author=author, author_url=author_url, file=change["title"], file_link=file_link, comment=parsed_comment)
|
||||
elif action == "delete/delete":
|
||||
page_link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content += "[{page}]({page_link}){comment}".format(page=change["title"], page_link=page_link,
|
||||
content = _("[{author}]({author_url}) deleted [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link,
|
||||
comment=parsed_comment)
|
||||
elif action == "delete/delete_redir":
|
||||
page_link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content += "[{page}]({page_link}){comment}".format(page=change["title"], page_link=page_link,
|
||||
content = _("[{author}]({author_url}) deleted redirect by overwriting [{page}]({page_link}){comment}").format(author=author, author_url=author_url, page=change["title"], page_link=page_link,
|
||||
comment=parsed_comment)
|
||||
elif action == "move/move":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["logparams"]['target_title'].replace(" ",
|
||||
"_"))
|
||||
parsed_comment = "{supress}. {desc}".format(desc=parsed_comment,
|
||||
supress=_("No redirect has been made") if "suppressredirect" in
|
||||
change[
|
||||
"logparams"] else _(
|
||||
"A redirect has been made"))
|
||||
content = _("[{author}]({author_url}) moved {redirect}{article} to [{target}]({target_url}){comment}").format(author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "", article=change["title"],
|
||||
target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment)
|
||||
elif action == "move/move_redir":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["logparams"]["target_title"].replace(" ",
|
||||
"_"))
|
||||
content = _("[{author}]({author_url}) moved {redirect}{article} over redirect to [{target}]({target_url}){comment}").format(author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "", article=change["title"],
|
||||
target=change["logparams"]['target_title'], target_url=link, comment=parsed_comment)
|
||||
elif action == "protect/move_prot":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["logparams"]["oldtitle_title"].replace(
|
||||
" ", "_"))
|
||||
content = _(
|
||||
"[{author}]({author_url}) moved protection settings from {redirect}{article} to [{target}]({target_url}){comment}").format(author=author, author_url=author_url, redirect="⤷ " if "redirect" in change else "", article=change["logparams"]["oldtitle_title"],
|
||||
target=change["title"], target_url=link, comment=parsed_comment)
|
||||
elif action == "block/block":
|
||||
link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"],
|
||||
user=change["title"].replace(" ", "_").replace(')',
|
||||
'\)'))
|
||||
user = change["title"].split(':')[1]
|
||||
if change["logparams"]["duration"] == "infinite":
|
||||
block_time = _("infinity and beyond")
|
||||
else:
|
||||
english_length = re.sub(r"(\d+)", "", change["logparams"][
|
||||
"duration"]) # note that translation won't work for millenia and century yet
|
||||
english_length_num = re.sub(r"(\D+)", "", change["logparams"]["duration"])
|
||||
try:
|
||||
english_length = english_length.rstrip("s").strip()
|
||||
block_time = "{num} {translated_length}".format(num=english_length_num,
|
||||
translated_length=ngettext(english_length,
|
||||
english_length + "s",
|
||||
int(english_length_num)))
|
||||
except AttributeError:
|
||||
logging.error("Could not strip s from the block event, seems like the regex didn't work?")
|
||||
return
|
||||
content = _(
|
||||
"[{author}]({author_url}) blocked [{user}]({user_url}) for {time}{comment}").format(author=author, author_url=author_url, user=user, time=block_time, user_url=link, comment=parsed_comment)
|
||||
elif action == "block/reblock":
|
||||
link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"],
|
||||
user=change["title"].replace(" ", "_").replace(')',
|
||||
'\)'))
|
||||
user = change["title"].split(':')[1]
|
||||
content = _("[{author}]({author_url}) changed block settings for [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment)
|
||||
elif action == "block/unblock":
|
||||
link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"],
|
||||
user=change["title"].replace(" ", "_").replace(')',
|
||||
'\)'))
|
||||
user = change["title"].split(':')[1]
|
||||
content = _("[{author}]({author_url}) unblocked [{blocked_user}]({user_url}){comment}").format(author=author, author_url=author_url, blocked_user=user, user_url=link, comment=parsed_comment)
|
||||
elif action == "curseprofile/comment-created":
|
||||
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
|
||||
commentid=change["logparams"]["4:comment_id"])
|
||||
content = _("[{author}]({author_url}) left a [comment]({comment}) on {target} profile").format(author=author, author_url=author_url, comment=link, target=change["title"].split(':')[1]+"'s" if change["title"].split(':')[1] != change["user"] else _("their own profile"))
|
||||
elif action == "curseprofile/comment-replied":
|
||||
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
|
||||
commentid=change["logparams"][
|
||||
"4:comment_id"])
|
||||
content = _("[{author}]({author_url}) replied to a [comment]({comment}) on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=change["title"].split(':')[1] + "'s" if change["title"].split(':')[1] !=change["user"] else _("their own profile"))
|
||||
elif action == "curseprofile/comment-edited":
|
||||
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
|
||||
commentid=change["logparams"][
|
||||
"4:comment_id"])
|
||||
content = _("[{author}]({author_url}) edited a [comment]({comment}) on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
comment=link,
|
||||
target=change["title"].split(':')[1] + "'s" if change["title"].split(':')[1] !=change["user"] else _("their own profile"))
|
||||
elif action == "curseprofile/comment-deleted":
|
||||
link = "https://{wiki}.gamepedia.com/Special:CommentPermalink/{commentid}".format(wiki=settings["wiki"],
|
||||
commentid=change["logparams"]["4:comment_id"])
|
||||
# link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"], target=params["target"].replace(" ", "_").replace(')', '\)'))
|
||||
content = _("[{author}]({author_url}) deleted a comment on {target} profile").format(author=author,
|
||||
author_url=author_url,
|
||||
target=change["title"].split(':')[1] + "'s" if change["title"].split(':')[1] !=change["user"] else _("their own profile"))
|
||||
|
||||
elif action == "curseprofile/profile-edited":
|
||||
link = "https://{wiki}.gamepedia.com/UserProfile:{target}".format(wiki=settings["wiki"],
|
||||
target=change["title"].split(':')[1].replace(" ",
|
||||
"_").replace(
|
||||
')', '\)'))
|
||||
if change["logparams"]['4:section'] == "profile-location":
|
||||
field = _("Location")
|
||||
elif change["logparams"]['4:section'] == "profile-aboutme":
|
||||
field = _("About me")
|
||||
elif change["logparams"]['4:section'] == "profile-link-google":
|
||||
field = _("Google link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-facebook":
|
||||
field = _("Facebook link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-twitter":
|
||||
field = _("Twitter link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-reddit":
|
||||
field = _("Reddit link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-twitch":
|
||||
field = _("Twitch link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-psn":
|
||||
field = _("PSN link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-vk":
|
||||
field = _("VK link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-xbl":
|
||||
field = _("XVL link")
|
||||
elif change["logparams"]['4:section'] == "profile-link-steam":
|
||||
field = _("Steam link")
|
||||
else:
|
||||
field = _("Unknown")
|
||||
content = _("[{author}]({author_url}) edited {field} of [{target}]({target_url}) profile to {desc}").format(author=author,
|
||||
author_url=author_url,
|
||||
target=change["title"].split(':')[1]+"'s" if change["title"].split(':')[1] != author else _("their own"),
|
||||
target_url=link,
|
||||
field=field,
|
||||
desc=BeautifulSoup(change["parsedcomment"], "lxml").get_text())
|
||||
elif action in ("rights/rights", "rights/autopromote"):
|
||||
link = "https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=change["title"].split(":")[1].replace(" ", "_"))
|
||||
old_groups = []
|
||||
new_groups = []
|
||||
for name in change["logparams"]["oldgroups"]:
|
||||
old_groups.append(_(name))
|
||||
for name in change["logparams"]["newgroups"]:
|
||||
new_groups.append(_(name))
|
||||
if len(old_groups) == 0:
|
||||
old_groups = [_("none")]
|
||||
if len(new_groups) == 0:
|
||||
new_groups = [_("none")]
|
||||
|
||||
if action == "rights/rights":
|
||||
content = "[{author}]({author_url}) changed group membership for [{target}]({target_url}) from {old_groups} to {new_groups}{comment}".format(author=author, author_url=author_url, target=change["title"].split(":")[1], target_url=link, old_groups=", ".join(old_groups), new_groups=', '.join(new_groups), comment=parsed_comment)
|
||||
else: # TODO Check what happens with author when the system autopromotes
|
||||
content = "{author} autopromoted [{target}]({target_url}) from {old_groups} to {new_groups}{comment}".format(
|
||||
author=_("System"), author_url=author_url, target=change["title"].split(":")[1], target_url=link,
|
||||
old_groups=", ".join(old_groups), new_groups=', '.join(new_groups),
|
||||
comment=parsed_comment)
|
||||
elif action == "protect/protect":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) protected [{article}]({article_url}) with the following settings: {settings}{comment}").format(author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
settings=change["logparams"]["description"]+_(" [cascading]") if "cascade" in change["logparams"] else "",
|
||||
comment=parsed_comment)
|
||||
elif action == "protect/modify":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _(
|
||||
"[{author}]({author_url}) modified protection settings of [{article}]({article_url}) to: {settings}{comment}").format(
|
||||
author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link,
|
||||
settings=change["logparams"]["description"] + _(" [cascading]") if "cascade" in change["logparams"] else "",
|
||||
comment=parsed_comment)
|
||||
elif action == "protect/unprotect":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) removed protection from [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment)
|
||||
elif action == "delete/revision":
|
||||
amount = len(change["logparams"]["ids"])
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = ngettext("[{author}]({author_url}) changed visibility of revision on page [{article}]({article_url}){comment}",
|
||||
"[{author}]({author_url}) changed visibility of {amount} revisions on page [{article}]({article_url}){comment}", amount).format(author=author, author_url=author_url,
|
||||
article=change["title"], article_url=link, amount=amount, comment=parsed_comment)
|
||||
elif action == "import/upload":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = ngettext("[{author}]({author_url}) imported [{article}]({article_url}) with {count} revision{comment}",
|
||||
"[{author}]({author_url}) imported [{article}]({article_url}) with {count} revisions{comment}", change["logparams"]["count"]).format(
|
||||
author=author, author_url=author_url, article=change["title"], article_url=link, count=change["logparams"]["count"], comment=parsed_comment)
|
||||
elif action == "delete/restore":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) restored [{article}]({article_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, comment=parsed_comment)
|
||||
elif action == "delete/event":
|
||||
content = _("[{author}]({author_url}) changed visibility of log events{comment}").format(author=author, author_url=author_url, comment=parsed_comment)
|
||||
elif action == "import/interwiki":
|
||||
content = _("[{author}]({author_url}) imported interwiki{comment}").format(author=author, author_url=author_url, comment=parsed_comment)
|
||||
elif action == "abusefilter/modify":
|
||||
link = "https://{wiki}.gamepedia.com/Special:AbuseFilter/history/{number}/diff/prev/{historyid}".format(wiki=settings["wiki"], number=change["logparams"]['newId'], historyid=change["logparams"]["historyId"])
|
||||
content = _("[{author}]({author_url}) edited abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link)
|
||||
elif action == "abusefilter/create":
|
||||
link = "https://{wiki}.gamepedia.com/Special:AbuseFilter/{number}".format(wiki=settings["wiki"], number=change["logparams"]['newId'])
|
||||
content = _("[{author}]({author_url}) created abuse filter [number {number}]({filter_url})").format(author=author, author_url=author_url, number=change["logparams"]['newId'], filter_url=link)
|
||||
elif action == "merge/merge":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
link_dest = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["logparams"]["dest_title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) merged revision histories of [{article}]({article_url}) into [{dest}]({dest_url}){comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, dest_url=link_dest,
|
||||
dest=change["logparams"]["dest_title"], comment=parsed_comment)
|
||||
elif action == "interwiki/iw_add":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) added an entry to the [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment,
|
||||
prefix=change["logparams"]['0'],
|
||||
website=change["logparams"]['1'],
|
||||
table_url=link)
|
||||
elif action == "interwiki/iw_edit":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) edited an entry in [interwiki table]({table_url}) pointing to {website} with {prefix} prefix").format(author=author, author_url=author_url, desc=parsed_comment,
|
||||
prefix=change["logparams"]['0'],
|
||||
website=change["logparams"]['1'],
|
||||
table_url=link)
|
||||
elif action == "interwiki/iw_delete":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Interwiki".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) deleted an entry in [interwiki table]({table_url})").format(author=author, author_url=author_url, table_url=link)
|
||||
elif action == "contentmodel/change":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) changed the content model of the page [{article}]({article_url}) from {old} to {new}{comment}").format(author=author, author_url=author_url, article=change["title"], article_url=link, old=change["logparams"]["oldmodel"],
|
||||
new=change["logparams"]["newmodel"], comment=parsed_comment)
|
||||
elif action == "sprite/sprite":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) edited the sprite for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
elif action == "sprite/sheet":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) created the sprite sheet for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
elif action == "sprite/slice":
|
||||
link = "https://{wiki}.gamepedia.com/{article}".format(wiki=settings["wiki"],
|
||||
article=change["title"].replace(" ", "_"))
|
||||
content = _("[{author}]({author_url}) edited the slice for [{article}]({article_url})").format(author=author, author_url=author_url, article=change["title"], article_url=link)
|
||||
elif action == "managetags/create":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Tags".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) created a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
|
||||
recent_changes.init_info()
|
||||
elif action == "managetags/delete":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Tags".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) deleted a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
|
||||
recent_changes.init_info()
|
||||
elif action == "managetags/activate":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Tags".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) activated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
|
||||
elif action == "managetags/deactivate":
|
||||
link = "https://{wiki}.gamepedia.com/Special:Tags".format(wiki=settings["wiki"])
|
||||
content = _("[{author}]({author_url}) deactivated a [tag]({tag_url}) \"{tag}\"").format(author=author, author_url=author_url, tag=change["logparams"]["tag"], tag_url=link)
|
||||
elif action == "suppressed":
|
||||
link = "https://{wiki}.gamepedia.com/".format(wiki=settings["wiki"])
|
||||
content = _("An action has been hidden by administration.")
|
||||
send_to_discord({'content': content})
|
||||
|
||||
def embed_formatter(action, change, parsed_comment, categories):
|
||||
data = {"embeds": []}
|
||||
|
@ -1050,7 +1304,6 @@ if settings["appearance"]["mode"] == "embed":
|
|||
appearance_mode = embed_formatter
|
||||
elif settings["appearance"]["mode"] == "compact":
|
||||
appearance_mode = compact_formatter
|
||||
action_list = {"edit": _("edited"), "new": _("created"), "upload/upload": _("uploaded"), "upload/overwrite": _("uploaded a new version of"), "delete/delete": _("deleted"), "delete/delete_redir": _("deleted redirect by overwriting")}
|
||||
else:
|
||||
logging.critical("Unknown formatter!")
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in a new issue