# moduleargs are additional arguments to be passed into the module's process function after the request object. Example use: Gitea webhook secret key
#moduleargs = []
# overlongmode determines what happens to messages that are too long to be sent to the channel. The value may be 'split' (split into multiple messages on spaces or codepoints) or 'truncate' (truncate everything exceeding the limit).
if usermaskPrefixLength + len(b'PRIVMSG ' + channelB + b' :' + messageB) > 510:
self.logger.debug(f'Splitting up into smaller messages')
# Message too long, need to split. First try to split on spaces, then on codepoints. Ideally, would use graphemes between, but that's too complicated.
# Message too long, need to split or truncate. First try to split on spaces, then on codepoints. Ideally, would use graphemes between, but that's too complicated.
self.logger.debug(f'Message too long, overlongmode = {overlongmode}')
prefix = b'PRIVMSG ' + channelB + b' :'
prefixLength = usermaskPrefixLength + len(prefix) # Need to account for the origin prefix included by the ircd when sending to others
maxMessageLength = 510 - prefixLength # maximum length of the message part within each line
if overlongmode == 'truncate':
maxMessageLength -= 3 # Make room for an ellipsis at the end
messages = []
while message:
if overlongmode == 'truncate' and messages:
break # Only need the first message on truncation
if len(messageB) <= maxMessageLength:
messages.append(message)
break
@@ -425,8 +436,11 @@ class IRCClientProtocol(asyncio.Protocol):