[Twisted-Python] implementing NAMES in IRC

Glyph glyph at twistedmatrix.com
Tue Sep 11 12:46:47 EDT 2012

On Sep 11, 2012, at 9:12 AM, Tristan Seligmann <mithrandi at mithrandi.net> wrote:

> On Tue, Sep 11, 2012 at 3:43 PM,  <exarkun at twistedmatrix.com> wrote:
>> This is the excuse that is always given for not implementing a new
>> feature on `IRCClient`.  However, here's another equivalent way of
>> stating the objection:
>>  IRC is a terrible protocol and it is very difficult to implement a
>>  method like `names` reliably, due to the various vague and obscure
>>  corner cases presented.  Therefore, instead of Twisted tackling this
>>  problem and providing a single (perhaps imperfect) implementation,
>>  every single IRC application developer should instead rediscover this
>>  sad reality for themselves and then implement their own uniquely buggy
>>  version of this functionality.
> Actually, my recommendation would be to avoid trying to implement
> functionality of this nature in any application at all. The only way
> to reliably use the NAMES command is the way
> twisted.words.im.ircsupport and real IRC clients do: handle
> RPL_NAMREPLY / RPL_ENDOFNAMES without regard to any NAMES command you
> may or may not have issued, and then issue a NAMES command at certain
> points without any regard for a response that may or may not be sent
> to you by the IRC server. Having said that, I guess IRCClient could
> handle the parsing of RPL_NAMREPLY / RPL_ENDOFNAMES messages into a
> single list of names, which could then be delivered as a single event.

So... you're recommending exactly what twisted.words.im already does? :)  (This is another area of the code that could use a maintainer, but its design is less horrible than its lack of testing and lack of coding standard compliance might imply.)

Keep in mind that we can assume to have control over outgoing traffic on our own IRC connection.  If you've already issued one .names(), then another outgoing one doesn't have to send an additional command and try to do weird Deferred-stacking stuff.  It just has to delay sending the actual NAMES request until the previous one has come back, or perhaps just fire both Deferreds with a single response.


More information about the Twisted-Python mailing list