All pastes #384547 Raw Edit

CJLucas

public python v1 · immutable
·published 2007-03-07 04:13 UTC
rendered paste body
from twisted.words.protocols import ircfrom twisted.internet import reactor, protocolimport time, sys, osclass JokBot(irc.IRCClient):  '''The Jokosher IRC bot.'''  nickname = 'jokbot'  channel = 'cjlucas'  def setPeer(self):	self.peer = p  def connectionMade(self): irc.IRCClient.connectionMade(self)  def connectionLost(self, reason):    irc.IRCClient.connectionLost(self, reason)  def signedOn(self): self.join(self.channel)  def irc_INVITE(self, prefix, params):	print prefix, params	print "Invited"	join(chan)  def privmsg(self, user, channel, msg):    print user, channel, msg    '''This will get called when the bot receives a message.'''    user = user.split('!', 1)[0]    if channel.lower() == '#cjlucas':		self.factory.peer.protoInstance.msg(channel, msg)    # Check to see if they're sending me a private message    # Otherwise check to see if it is a message directed at me    if msg.startswith(self.nickname + ':'):      self.msg(channel, '%s said %s' % (user,                        msg[len(self.nickname + ':'):]))      returnclass JokBotFactory(protocol.ClientFactory):  protocol = JokBot  def __init__(self): pass  def clientConnectionLost(self, connector, reason): connector.connect()  def clientConnectionFailed(self, connector, reason): reactor.stop()  def buildProtocol(self, addr):	p = protocol.ClientFactory.buildProtocol(self, addr)	self.protoInstance = p  if __name__ == '__main__':  f = JokBotFactory()  reactor.connectTCP('irc.blackened.com', 6667, f)  g = JokBotFactory()  reactor.connectTCP('irc.freenode.net', 6667, g)  reactor.run()