# Open a file to store the logs in # We will append data to this file ( "a" ) logFile = open ( 'channelLog.txt', 'a' ) # Subclass SimpleIRCClient class ClientClass ( irclib.SimpleIRCClient ): # Handle private messages def on_pubmsg ( self, connection, event ): # Write to the log source = event.source().split ( '!' ) [ 0 ] text = event.arguments() [ 0 ] logFile.write ( source + '-> ' + text + '\n' )