This commit is contained in:
Frisk 2020-11-18 21:27:11 +01:00
parent a57d0f58a9
commit 077a103d35
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
2 changed files with 9 additions and 5 deletions

View file

@ -129,11 +129,13 @@ def send_to_discord_webhook(data: Optional[DiscordMessage], metadata: DiscordMes
result = requests.Session().send(req, timeout=10)
update_ratelimit(result)
if AUTO_SUPPRESSION_ENABLED and metadata.method == "POST":
# TODO Prepare request with all of safety checks
if 199 < result.status_code < 300: # check if positive error log
try:
add_message_redaction_entry(*metadata.dump_ids(), repr(data), result.json().get("id"))
except ValueError:
logger.error("Couldn't get json of result of sending Discord message.")
else:
pass
except requests.exceptions.Timeout:
logger.warning("Timeouted while sending data to the webhook.")
return 3

View file

@ -974,6 +974,8 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
else:
tag_displayname.append(tag)
embed.add_field(_("Tags"), ", ".join(tag_displayname))
if len(embed["title"]) > 254:
embed["title"] = embed["title"][0:253]+""
logger.debug("Current params in edit action: {}".format(change))
if categories is not None and not (len(categories["new"]) == 0 and len(categories["removed"]) == 0):
new_cat = (_("**Added**: ") + ", ".join(list(categories["new"])[0:16]) + ("\n" if len(categories["new"])<=15 else _(" and {} more\n").format(len(categories["new"])-15))) if categories["new"] else ""