Track usermask and account for it in the message splitting
Since the ircd will prefix each message with the origin usermask when broadcasting to the other users, it will have to split or truncate the message sent by the user. Charybdis and ratbox silently truncate it.
@@ -527,6 +542,28 @@ class IRCClientProtocol(asyncio.Protocol):
asyncio.create_task(self.send_messages())
asyncio.create_task(self.confirm_messages())
# JOIN success
elif message.startswith(b'JOIN ') and not self.usermask:
# If this is my own join message, it should contain the usermask in the prefix
if rawMessage.startswith(b':' + self.config['irc']['nick'].encode('utf-8') + b'!') and b' ' in rawMessage:
usermask = rawMessage.split(b' ', 1)[0][1:]
self._maybe_set_usermask(usermask)
# Services host change
elif message.startswith(b'396 '):
words = message.split(b' ')
if len(words) >= 3:
# Sanity check inspired by irssi src/irc/core/irc-servers.c
if not any(x in words[2] for x in (b'*', b'?', b'!', b'#', b'&', b' ')) and not any(words[2].startswith(x) for x in (b'@', b':', b'-')) and words[2][-1:] != b'-':