Is there a way to automate periodic tasks: like sending messages to other users or channels, etc. using python irclib or twisted-based youmomdotcom python irc bot.
Example of irclib based irc client:
from irc import client
class OurIRCClient(client.SimpleIRCClient):
def __init__(self):
client.SimpleIRCClient.__init__(self)
import sys
client = OurIRCClient()
try:
client.connect("irc.freenode.net", 6667, myUserId)
print "connected to irc.freenode.net"
except:
sys.exit(-1)
"error: coouldn't connect to irc server"
client.connection.join("#django-hotclub")
client.start()
As Glyph pointed out, i've overridden the instance method connectionMade of the irc client class and made it use LoopingCall.
def connectionMade(self):
irc.IRCClient.connectionMade(self)
task.LoopingCall(lambda : (self.msg(counterpartID, "hi there"))).start(5.0)