@bot.message_handler(func=lambda message: True, content_types=['text'])
def msg(message):
file_name = str(message.from_user.last_name) + str(message.from_user.first_name) + ".txt"
f = open(file_name, 'a')
f.write(message.text)
f.close()