if msg [1] == 'PRIVMSG':#この行を変更しました filetxt = open('../msg.txt', 'a+') #open an arbitrary file to store the messages nick_name = msg[0][:string.find(msg[0],"!")] #if a private message is sent to you catch it message = ' '.join(msg[3:]) filetxt.write(string.lstrip(nick_name, ':') + ' -> ' + string.lstrip(message, ':') + '\n') #write to the file filetxt.flush() #don't wait for next message, write it now!