Note that there are some explanatory texts on larger screens.

plurals
  1. POTwisted IRC Bot connection lost repeatedly to localhost
    primarykey
    data
    text
    <p>I am trying to implement an IRC Bot on a local server. The bot that I am using is identical to the one found at <a href="http://eflorenzano.com/blog/2008/11/16/writing-markov-chain-irc-bot-twisted-and-python/" rel="nofollow">Eric Florenzano's Blog</a>. This is the simplified code (which should run)</p> <pre><code>import sys import re from twisted.internet import reactor from twisted.words.protocols import irc from twisted.internet import protocol class MomBot(irc.IRCClient): def _get_nickname(self): return self.factory.nickname nickname = property(_get_nickname) def signedOn(self): print "attempting to sign on" self.join(self.factory.channel) print "Signed on as %s." % (self.nickname,) def joined(self, channel): print "attempting to join" print "Joined %s." % (channel,) def privmsg(self, user, channel, msg): if not user: return if self.nickname in msg: msg = re.compile(self.nickname + "[:,]* ?", re.I).sub('', msg) prefix = "%s: " % (user.split('!', 1)[0], ) else: prefix = '' self.msg(self.factory.channel, prefix + "hello there") class MomBotFactory(protocol.ClientFactory): protocol = MomBot def __init__(self, channel, nickname='YourMomDotCom', chain_length=3, chattiness=1.0, max_words=10000): self.channel = channel self.nickname = nickname self.chain_length = chain_length self.chattiness = chattiness self.max_words = max_words def startedConnecting(self, connector): print "started connecting on {0}:{1}" .format(str(connector.host),str(connector.port)) def clientConnectionLost(self, connector, reason): print "Lost connection (%s), reconnecting." % (reason,) connector.connect() def clientConnectionFailed(self, connector, reason): print "Could not connect: %s" % (reason,) if __name__ == "__main__": chan = sys.argv[1] reactor.connectTCP("localhost", 6667, MomBotFactory('#' + chan, 'YourMomDotCom', 2, chattiness=0.05)) reactor.run() </code></pre> <p>I added the startedConnection method in the client factory, which it is reaching and printing out the proper address:host. It then disconnects and enters the clientConnectionLost and prints the error:</p> <pre><code>Lost connection ([Failure instance: Traceback (failure with no frames): &lt;class 'twisted.internet.error.ConnectionDone'&gt;: Connection was closed cleanly. ]), reconnecting. </code></pre> <p>If working properly it should log into the appropriate channel, specified as the first arg in the command (e.g. python module2.py botwar. would be channel #botwar.). It should respond with "hello there" if any one in the channel sends anything.</p> <p>I have <a href="http://ngircd.barton.de/" rel="nofollow">NGIRC</a> running on the server, and it works if I connect from mIRC or any other IRC client.</p> <p>I am unable to find a resolution as to why it is continually disconnecting. Any help on why would be greatly appreciated. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload