Skip to content

Commit

Permalink
Trim result
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Feb 17, 2024
1 parent cf29ada commit f6f789a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/util/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
import util.utils as utils
import util.validators as validators
from itertools import islice

log = utils.getLog(__name__)

Expand Down Expand Up @@ -69,6 +70,14 @@ def scape_markdown(message):
return utils.escape_special_symbols(message, SPECIAL_SYMBOLS)

async def send_message_validators(message_base, validators_list, notify):
if len(validators_str) <= 20:
validators_to_notify = validators_str
message_end = ""
else:
validators_to_notify = islice(validators_str, 20)
message_end = f"...and {len(validators_list)} more."


validators_str = ", ".join([str(index) for index in validators_list])
validators_markdown = ", ".join(
[
Expand All @@ -82,7 +91,7 @@ async def send_message_validators(message_base, validators_list, notify):
if notify:
try:
message_base_safe = scape_markdown(message_base)
await send_message(message_base_safe + validators_markdown)
await send_message(message_base_safe + validators_markdown + message_end)
except:
log.error("Error notifying change")

Expand Down

0 comments on commit f6f789a

Please sign in to comment.