From 87a53e3a8498e4d1bf3fe768deca271323446183 Mon Sep 17 00:00:00 2001 From: Frisk Date: Thu, 2 May 2019 17:21:09 +0200 Subject: [PATCH] Fixed #72 --- rcgcdw.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 60f51e0..97fffd9 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -20,7 +20,7 @@ # WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT # You have been warned -import time, logging, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys +import time, logging, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys, ipaddress from bs4 import BeautifulSoup from collections import defaultdict, Counter from urllib.parse import quote_plus @@ -574,10 +574,15 @@ def embed_formatter(action, change, parsed_comment, categories): embed["title"] = _("Moved protection settings from {redirect}{article} to {title}").format(redirect="⤷ " if "redirect" in change else "", article=change["logparams"]["oldtitle_title"], title=change["title"]) elif action == "block/block": - link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"], - user=change["title"].replace(" ", "_").replace(')', - '\)')) user = change["title"].split(':')[1] + try: + ipaddress.ip_address(user) + link = "https://{wiki}.gamepedia.com/Special:Contributions/{user}".format(wiki=settings["wiki"], + user=user) + except ValueError: + link = "https://{wiki}.gamepedia.com/{user}".format(wiki=settings["wiki"], + user=change["title"].replace(" ", "_").replace(')', + '\)')) if change["logparams"]["duration"] == "infinite": block_time = _("infinity and beyond") else: