Hi, I'm trying to build a very simple irc bot for now but it seems like my bot won't join the channel. Can someone point out what's wrong with the following code:
from twisted.internet import reactor, protocol
from twisted.words.protocols import irc
class IRCProtocol(irc.IRCClient):
nickname = "botnick"
def connectionMade(self):
print 'connectionMade!'
def signedOn(self):
print 'Signed On to server'
self.join(self.factory.channels)
print 'Joined channel'
self.say(self.factory.channels, "hello", 1024)
class IRCFactory(protocol.ClientFactory):
protocol = IRCProtocol
channels = "#testingircbot"
def clientConnectionFailed(self, connector, reason):
print "Connection failed because of %s" % reason
reactor.stop()
def clientConnectionLost(self, connector, reason):
print "Connection lost: %s" % reason
connector.connect()
if __name__ == "__main__":
host, port = "irc.freenode.net", 6667
fact = IRCFactory()
reactor.connectTCP(host, port, fact)
reactor.run()
This is the output when I run the script:
connectionMade!
Connection lost: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]
connectionMade!
Connection lost: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]
connectionMade!
Connection lost: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]