[Twisted-Python] IRCClient (ircLogBot.py) send a message every 5 minutes
![](https://secure.gravatar.com/avatar/1e6b06d67e97abea9a8fb143c7374c94.jpg?s=120&d=mm&r=g)
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? Thanks in advance!
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
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, -glyph
![](https://secure.gravatar.com/avatar/1e6b06d67e97abea9a8fb143c7374c94.jpg?s=120&d=mm&r=g)
On 2015-03-30 13:39, Glyph Lefkowitz wrote:
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! :) Next stop: adding a database connection. Thank you for making Twisted! :) -Laurens
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
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, -glyph
![](https://secure.gravatar.com/avatar/1e6b06d67e97abea9a8fb143c7374c94.jpg?s=120&d=mm&r=g)
On 2015-03-30 13:39, Glyph Lefkowitz wrote:
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! :) Next stop: adding a database connection. Thank you for making Twisted! :) -Laurens
participants (3)
-
Glyph
-
Glyph Lefkowitz
-
Laurens Vets