The IRC protocol state that packets must be no more than 512 bytes (characters) in length, including the new line and line feed characters at the end. When sending a message to a channel, you must consider the packet must include: the source nick, user, and host, command to be performed, the channel name, and the text to be delivered. These are calculated from the maximum length each of these strings can be.
Nicks are limited to 30 characters, usernames are limited to 10 characters, hosts are limited to 63 characters. channels are limited to no more than 32 characters. You must then add the appropriate characters for format and spacing. There's a : at the beginning of the packet, a ! between nick and user, and a @ between user and host, and another : where the text to be delivered begins. The command is PRIVMSG, which is another 7 characters. There are 3 spaces, and the newline characters at the end. Add these numbers together, and you get 151. This leaves 361 characters available for the text portion, which would be the most you can send to a channel, any more may break strictly coded clients.
In other words:
Code: Select all
: + NICK + ! + USER + @ + HOST + <space> + PRIVMSG + <space> + CHAN + <space> + : + \r\n
1 + 30 + 1 + 10 + 1 + 63 + 1 + 7 + 1 + 32 + 1 + 1 + 2
The required formatting in it's maximum usage is 151. 512 - 151 = 361