<commit_before>import markovify
import random
import re

loads = {}

def listen(message):
    if(len(message.content.split(" ")) < 4):
        return

    user = message.author.id
    if(user in loads):
        loads[user] += "\n" + message.content

    filename = "./data/markov/" + str(message.author.id) + ".txt"
    with open(filename, "a", encoding="utf-8") as mfile:
            mfile.write(message.content + "\n")

async def mimic(client, message, args):
    async with message.channel.typing():
        if(args):
            user = re.sub("<@!*|>", "", args[0])
        else:
            user = message.author.id

        if(not user in loads):
            filename = "./data/markov/" + str(user) + ".txt"
            with open(filename, "r", encoding="utf-8") as mfile:
                loads[user] = mfile.read()

        model = markovify.Text(loads[user], well_formed=True)

        for i in range(3):
            sentence = model.make_sentence(tries=1000000, max_words=random.randint(4, 25))
            await message.channel.send(sentence)
    
        <commit_msg>Update mimic.py (#52)<commit_after>import markovify
import random
import re

loads = {}

def listen(message):
    if(len(message.content.split(" ")) < 4):
        return

    user = message.author.id
    if(user in loads):
        loads[user] += "\n" + message.content

    filename = "./data/markov/" + str(message.author.id) + ".txt"
    with open(filename, "a", encoding="utf-8") as mfile:
            mfile.write(message.content + "\n")

async def mimic(client, message, args):
    async with message.channel.typing():
        if(args):
            user = re.sub("<@!*|>", "", args[0])
        else:
            user = message.author.id

        if(not user in loads):
            filename = "./data/markov/" + str(user) + ".txt"
            with open(filename, "r", encoding="utf-8") as mfile:
                loads[user] = mfile.read()

        model = markovify.Text(loads[user], well_formed=True)

        for i in range(3):
            sentence = model.make_sentence(tries=1000000, max_words=random.randint(4, 40))
            await message.channel.send(sentence)
    
        
{'fraction_non_alphanumeric': 0.15526802218114602, 'fraction_numerical': 0.014787430683918669, 'mean_word_length': 2.250750750750751, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7219707', 'n_tokens_mistral': 704, 'n_tokens_neox': 677, 'n_words': 154}