new_contents: import sys
  
  from twisted.words.protocols import irc
  from twisted.internet import protocol, reactor
  
  class Client(irc.IRCClient):
      def _get_nickname(self):
          return self.factory.nickname
      nickname = property(_get_nickname)
      
      def signedOn(self):
          self.join(self.factory.channel)
          print("Signed on as {0}.".format(self.nickname))
          
      def joined(self, channel):
          print("Joined {0}.".format(channel))
  
      def privmsg(self, user, channel, msg):
          print(msg)
  
  
  class ClientFactory(protocol.ClientFactory):
      protocol = Client
  
      def __init__(self, channel, nickname='hashi'):
          self.channel = channel
          self.nickname = nickname
  
      def clientConnectionLost(self, connector, reason):
          print("Lost connection ({0}), reconnecting.".format(reason))
          connector.connect()
  
      def clientConnectionFailed(self, connector, reason):
          print("Could not connect: {0}" % (reason))
  
  
  if __name__ == "__main__":
      chan = sys.argv[1]
      server = sys.argv[2]
      reactor.connectTCP(server, 6667, ClientFactory('#' + chan))
      reactor.run()
  
subject: Add a dumb IRC client implementation.