Opened 8 years ago

Closed 8 years ago

#4591 enhancement closed duplicate (duplicate)

IRCClient should split messages by default.

Reported by: Screwtape Owned by:
Priority: normal Milestone:
Component: words Keywords:
Cc: Branch:


Currently, if you call IRCClient.msg, there are two possible behaviours:

  • If you pass a value for the length parameter, your message will be split into individual messages at or before the given length, *and* will be split on \n.
  • If you do not pass a value for the length parameter,your message will not be split at all, and all your newlines will be transmuted into "\x10n" (I can't find this escaping in the RFC, I think it's a weird Twisted thing).

This is frustrating for a few reasons:

  • One parameter (split on length) controls an unrelated feature (split on \n).
  • If a user tries to skip calculating message lengths and just send their blob of text, or tries to break it up into lines themselves with \n, they're likely to (a) get booted off their server for exceeding message length, (b) get unwanted control chars in their output, which is surely not what they intended.
  • If a user tries to calculate the message length themselves, they'll have to learn the intricacies of the IRCClient implementation, as the "length limit" includes the IRC command framing, the recipient name *and* the expansion caused by Twisted's \x10 escaping.

It seems to me that the humane thing to do, if no explicit length-limit is given, would be to:

  • \x10-escape the given message text.
  • Split the text into lines at \n.
  • Calculate the maximum message length for this recipient.
  • Split each line into individual messages at most $length bytes long.
  • Send each message.

The biggest flaw in this proposal is that currently \x10-escaping is the *last* thing done before sending; for backwards-compatibility reasons we might wind up leaving that at the end and having a risk of occasional line-overflow... which is still better than what we have now.

Change History (4)

comment:1 Changed 8 years ago by Screwtape

Seems #4416 was filed for the same problem... but I prefer the solution outlined here.

comment:2 Changed 8 years ago by Screwtape

Summary: IRCClient should split messages more sensibly.IRCClient should split messages by default.

comment:3 Changed 8 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Tickets are for problems, not solutions. :) Closing as a duplicate. Feel free to override the OP's solution on #4416 if you think what you described here is superior.

comment:4 Changed 8 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.