[Twisted-Python] IRC protocol rewrite?

Kevin Turner acapnotic at twistedmatrix.com
Wed Jan 2 19:11:34 EST 2002


On Wed, 2002-01-02 at 15:18, Ivo van der Wijk wrote:

> it takes actions/decisions the client builder
> would rather like to implement (i.e. irc_ERR_NICKNAMEINUSE will generate
> a new nickname by appending a _ - who says I want this in my client?),
> ctcp_PING immediately sends a ping reply - this won't work with my
> ignore list, etc.

Ah, this is the information I was looking for.  (The bit about
supporting & channels is a minor detail, worth fixing but not  grounds
for reimplementation.)  In reply, let me just say that subclassing is a
wonderful and powerful thing.  You are invited, encouraged even, to
override any methods which don't do what you want in your subclass. 
Default implementations are provided in the base class for things like
irc_ERR_NICKNAMEINUSE because every IRC client needs to have *some*
implementation of them, or else it will likely be so broken that it
won't be able to sign on.  But again, don't hesitate to override the
default methods with something else.  This class uses the
"""getattr(self, "prefix_%s" % command)()""" idiom, so you can always
add methods for more IRC or CTCP message types (i.e. Zircon extensions)
in your subclass too.

> There's is quite some DCC support in the IRCClient class that I have here
> (twisted 0.12.3), i.e. ctcpQuery_DCC which initiates DCC, maintains a list
> of sessions, etc

That's because it's a CTCP query which initiates the DCC connection. 
The DCC connection itself (as opposed to things talking about DCC
connections) has its own class and instance.

As for maintaining a list of sessions, I think that this does belong in
a "client" implementation, but I agree that this is not state that a
"protocol" class should be concerned with.  It's only there because I
couldn't see another way for a subclass to figure out which DCC sessions
were created, which is something you probably want to know for your
interface.  Perhaps the default ctcpQuery_DCC method should pass back
the DCC session as its return value?

-- 
The moon is waning gibbous, 86.3% illuminated, 18.3 days old.






More information about the Twisted-Python mailing list