> On Apr 6, 2015, at 20:27, Laurens Vets <laur...@daemon.be> wrote:
> 
> On 2015-03-30 13:39, Glyph Lefkowitz wrote:
>>> On Mar 26, 2015, at 11:18 AM, Laurens Vets <laur...@daemon.be> wrote:
>>> Hello,
>>> I'm trying to get to know the Twisted framework by extending the 
>>> ircLogBot.py example. I want to be able to get a list of all names in a 
>>> channel (by sending NAMES) and I want to rerun this every 5 minutes.
>>> I've been able to get the NAMES on a channel join by doing this in LogBot:
>>> def joined(self, channel):
>>>   self.names(channel)
>>> def names(self, channel):
>>>   self.sendLine("NAMES %s" % channel)
>>> def irc_unknown(self, prefix, command, params):
>>>   if command == 'RPL_NAMREPLY':
>>>       self.handle_namereply(*params)
>>> def handle_namereply(self, myname, channeltype, channelname, users):
>>>   self.logger.log("Handling namereply %r %r %r %r" % (myname, channeltype, 
>>> channelname, users))
>>> The problem I face is that I have no idea where to put a LoopingCall to run 
>>> this same command every 5 minutes. Where would be the best place to place 
>>> this?
>> I would probably start such a LoopingCall in LogBot.connectionMade,
>> and make sure to stop it in LogBot.connectionLost.  That way only an
>> active connection will attempt to send NAMES to itself.
>> Does that make sense for your application?
>> Thanks for using Twisted,
> 
> I created the call in LogBot.joined as I need to be joined in a channel 
> before I can send the NAMES command. Does that sound right? I'll also stop it 
> in in connectionLost. I did not think of that, thanks! :)

Yup, that all sounds right.

> Next stop: adding a database connection.

Good luck!

> Thank you for making Twisted! :)

Thank you for using it!

-glyph


_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to