MCPcopy Create free account
hub / github.com/CryptoSignal/Crypto-Signal / NotifierUtils

Class NotifierUtils

app/notifiers/utils.py:6–41  ·  view source on GitHub ↗

Utilities for notifiers

Source from the content-addressed store, hash-verified

4import structlog
5
6class NotifierUtils():
7 """ Utilities for notifiers
8 """
9
10 def __init__(self):
11 self.logger = structlog.get_logger()
12
13
14 def chunk_message(self, message, max_message_size):
15 """ Chunks message so that it meets max size of integration.
16
17 Args:
18 message (str): The message to chunk.
19 max_message_size (int): The max message length for the chunks.
20
21 Returns:
22 list: The chunked message.
23 """
24
25 chunked_message = list()
26 if len(message) > max_message_size:
27 split_message = message.splitlines(keepends=True)
28 chunk = ''
29
30 for message_part in split_message:
31 temporary_chunk = chunk + message_part
32
33 if max_message_size > len(temporary_chunk):
34 chunk += message_part
35 else:
36 chunked_message.append(chunk)
37 chunk = ''
38 else:
39 chunked_message.append(message)
40
41 return chunked_message

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected