J'essaye de construire un bot irc très simple pour le moment mais il semble que mon bot ne rejoindra pas le canal. Quelqu'un peut-il pointer ce qui ne va pas avec le code suivant:IRCBot ne va pas rejoindre un canal
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()
C'est la sortie quand je lance le 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.
]