Open temotodochi opened 7 years ago
To clarify on this issue, IRC messages have a maximum size of 512 bytes, including the two line ending bytes \r\n
at the end of the message, which means 510 usable bytes. This is an example message that may be cut off:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
Although this message is under 510 bytes - 494 bytes to be precise - the actual message sent could be as follows:
PRIVMSG #somechannelname :The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
.
The length of this full message is 520 bytes, so the intended message will be cut off. To make matters worse, we could send the following message:
PRIVMSG #somechannelname :The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog
. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.`
This length of this full message is only 475 bytes. However, the message that the server broadcasts to other clients could be as follows:
:ALongIRCNickname!username@ip-5-102-53-178.pool.some-isp.net PRIVMSG #somechannelname :The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The length of this message from the server is 536 bytes, which will be cut off.
As such, the bot could retrieve information from the server about max nick length, max username length, max hostname length, and max channel name length, in order to calculate how many bytes are safe to send.
Alternatively, the bot could calculate this byte count based on its own nick/username/hostname and the destination to which it is sending the message. This may be a better solution as it will allow as many bytes to be sent as can fit in the IRC message.
For example when terminus is used in IRCNet, help messages and other longer private messages get cut up by, max line length seems to be around 465 characters + bot nick
terminus should send multiple private messages when line length exceeds 400 characters.