This commit is contained in:
Frisk 2018-06-24 20:28:42 +02:00
parent 5774c0821e
commit d21567e2fa
No known key found for this signature in database
GPG key ID: 0E9A7D3C0A01586C

View file

@ -123,20 +123,20 @@ def webhook_formatter(action, STATIC, **params):
return 0
content = list(article_content.values())[0]['revisions'][0]['*']
try:
matches = re.search(re.compile(settings["license_regex"]), content, re.IGNORECASE)
matches = re.search(re.compile(settings["license_regex"], re.IGNORECASE), content)
if matches is not None:
license = matches.group("license")
else:
if re.search(re.compile(settings["license_regex_detect"]), content, re.IGNORECASE) is None:
if re.search(re.compile(settings["license_regex_detect"], re.IGNORECASE), content) is None:
license = _("**No license!**")
else:
license = "?"
except sre_constants.error:
logging.error("Given regex for the license detection is incorrect. Please fix license_regex or license_regex_detect values in the config!")
license = "?"
except IndexError:
logging.error("Given regex for the license detection is incorrect. It does not have a capturing group called \"license\" specified. Please fix license_regex value in the config!")
license = "?"
except re.error:
logging.error("Given regex for the license detection is incorrect. Please fix license_regex or license_regex_detect values in the config!")
license = "?"
embed["fields"] = [{"name": _("Options"), "value": _("([preview]({link}))").format(link=embed["image"]["url"])}]
params["desc"] = _("{desc}\nLicense: {license}").format(desc=params["desc"], license=license)
elif action == 6: