mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-24 00:34:10 +00:00
Fix #171
This commit is contained in:
parent
a57d0f58a9
commit
077a103d35
|
@ -129,11 +129,13 @@ def send_to_discord_webhook(data: Optional[DiscordMessage], metadata: DiscordMes
|
||||||
result = requests.Session().send(req, timeout=10)
|
result = requests.Session().send(req, timeout=10)
|
||||||
update_ratelimit(result)
|
update_ratelimit(result)
|
||||||
if AUTO_SUPPRESSION_ENABLED and metadata.method == "POST":
|
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:
|
try:
|
||||||
add_message_redaction_entry(*metadata.dump_ids(), repr(data), result.json().get("id"))
|
add_message_redaction_entry(*metadata.dump_ids(), repr(data), result.json().get("id"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.error("Couldn't get json of result of sending Discord message.")
|
logger.error("Couldn't get json of result of sending Discord message.")
|
||||||
|
else:
|
||||||
|
pass
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
logger.warning("Timeouted while sending data to the webhook.")
|
logger.warning("Timeouted while sending data to the webhook.")
|
||||||
return 3
|
return 3
|
||||||
|
|
|
@ -974,6 +974,8 @@ def embed_formatter(action, change, parsed_comment, categories, recent_changes):
|
||||||
else:
|
else:
|
||||||
tag_displayname.append(tag)
|
tag_displayname.append(tag)
|
||||||
embed.add_field(_("Tags"), ", ".join(tag_displayname))
|
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))
|
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):
|
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 ""
|
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 ""
|
||||||
|
|
Loading…
Reference in a new issue