[Twisted-Python] Re: Where is best place to put my custom code?
Eric Mangold
teratorn at world-net.net
Wed Dec 31 20:43:15 MST 2003
On Wednesday 31 December 2003 04:58 pm, JD wrote:
> Hi,
>
> I'm open for suggestions on where I can put my customized code. I
> seem to have a choice
> between putting it in the "factory" or in the "protocol", and I
> cannot seem to decide where the
> best place would be.
Since this is IRC you shouldn't go issuing commands until your signed
on, thus the signedOn method of your protocol would be the right place.
>
> My application is simple..... here is all it should do....
>
> 1) establish a connection to an IRC server.
> 2) send an IRC command, like a "who" command, and extract the info
> 3) then exit the client
>
> I could put my code in the IRCClient's "connectionMade" method. Or
> I could put it in the
> factory's "startedConnecting" method. The code would be simple,
> issue a
> "who" command, and take it's output and return it. So, in my
> connectionMade method
> I would issue the command... then call reactor.stop() which would
> exit from my reactor.run().
>
> I think the factory's "startedConnecting" might get called first,
> then somewhere down in
> this mess, the Client would call me back with the "connectionMade",
> and I could do it there.
> I just need to know the appropriate place to put my code. None of
> these examples in
> the 'examples' directories make this clear.
>
> My next task is to know how to extract the 'who' data back from my
> initial "who"
Yeah, it's not obvious how to do that. I'll send another mail when I've
a chance to test something, but New Years is coming up right now... :)
>
> The ONLY callback I see is the "action()" method, where it has the
> "msg" as the argument.
> Is that the one I sub-class to read back the result of the "who"?
No. An ACTION in IRC terms is a user doing an /me.
> Which I assume is called back
> from a deferred.
>
> There are a number of other callbacks for the private messages and
> such. Which one
> do I use? When testing the code, I'm not getting any callbacks to
> the "action()" method.
> Is this because something else is fucked up.
Yeah, your code.
>
> I don't suppose anyone on this last has an Mac OS-X system, do they?
> If so, I would love
> to establish a VIOP meeting if anyone has the time to help me out.
> My "iChat" AIM handle is
> 'jdcrunchman'
>
> John
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-Eric
More information about the Twisted-Python
mailing list