Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut long messages in multiple lines #92

Open
temotodochi opened this issue Aug 30, 2017 · 1 comment
Open

Cut long messages in multiple lines #92

temotodochi opened this issue Aug 30, 2017 · 1 comment

Comments

@temotodochi
Copy link

temotodochi commented Aug 30, 2017

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.

@ori-sky
Copy link
Member

ori-sky commented Aug 30, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants