<commit_before>"""Markov Chain Sentence Generator

This module uses words from the database to construct fun sentences.
"""
import multiprocessing
import random
import re
import string

import discord
from discord.ext import commands

from utils import checks
from utils.mysql import getmsgs, getmsgsuser, delword


class MarkovChain(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    """
    @commands.Cog.listener()
    async def on_message(self, message):
        if message.author.bot:
            return

        if (
            self.bot.user.name.lower() in message.content.lower() or
            self.bot.user.mentioned_in(message)
        ):
            response = self.create_chain()
            try:
                embed = discord.Embed(colour=message.me.color)
            except Exception:
                embed = discord.Embed(color=discord.Color.blue())
            embed.add_field(name=f'*{self.bot.user.name} 9000*', value=f'**{response}**')
            await message.channel.send(embed=embed)
    """

    @commands.command()
    async def markovuser(self, message, user:discord.Member=None):
        if message.author.bot:
            return

        if user is None:
            userid = str(message.author.id)
        else:
            userid = str(user.id)

        try:
            embed = discord.Embed(colour=message.me.color)
        except Exception:
            embed = discord.Embed(color=discord.Color.blue())

        def multiprocess(uid):
            response = self.create_user_chain(uid)
            return response
            embed.add_field(name=f'*{self.bot.user.name} 9000* ({message.author.name} edition)',
                            value=f'**{response}**')

        processes = []
        for i in range(0,10):
            p = multiprocessing.Process(target=multiprocess(userid), args=(i,))
            processes.append(p)
            p.start()

        for process in processes:
            process.join()

        await message.channel.send(embed=embed)

    @commands.command()
    @checks.is_dev()
    async def wipeentry(self, message: str):
        """League of Legends sucks dick, kurt"""
        if message.author.bot:
            return
        delword(message)
        await message.channel.send("Deleted.")

    def format_sentence(self, unformatted_sentence):
        """Adds formatting to generated sentence.

        Args:
            unformatted_sentence (str): Unformatted generated sentence.

        Returns:
            formatted_sentence (str): Formatted generated sentence with
                                      first word capitalized and punctation at end.
        """
        punctuation_list = ['!', '?', '.']
        chance = [0.2, 0.1, 0.9]
        formatted_sentence = unformatted_sentence.capitalize()<commit_msg>Revert "idk what im doing"<commit_after>"""Markov Chain Sentence Generator

This module uses words from the database to construct fun sentences.
"""


import random
import re
import string

import discord
from discord.ext import commands

from utils import checks
from utils.mysql import getmsgs, getmsgsuser, delword


class MarkovChain(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    """
    @commands.Cog.listener()
    async def on_message(self, message):
        if message.author.bot:
            return

        if (
            self.bot.user.name.lower() in message.content.lower() or
            self.bot.user.mentioned_in(message)
        ):
            response = self.create_chain()
            try:
                embed = discord.Embed(colour=message.me.color)
            except Exception:
                embed = discord.Embed(color=discord.Color.blue())
            embed.add_field(name=f'*{self.bot.user.name} 9000*', value=f'**{response}**')
            await message.channel.send(embed=embed)
    """

    @commands.command()
    async def markovuser(self, message, user:discord.Member=None):
        if message.author.bot:
            return

        if user is None:
            userid = str(message.author.id)
        else:
            userid = str(user.id)

        response = self.create_user_chain(userid)
        try:
            embed = discord.Embed(colour=message.me.color)
        except Exception:
            embed = discord.Embed(color=discord.Color.blue())
        embed.add_field(name=f'*{self.bot.user.name} 9000* ({message.author.name} edition)', value=f'**{response}**')
        await message.channel.send(embed=embed)

    @commands.command()
    @checks.is_dev()
    async def wipeentry(self, message: str):
        """League of Legends sucks dick, kurt"""
        if message.author.bot:
            return
        delword(message)
        await message.channel.send("Deleted.")

    def format_sentence(self, unformatted_sentence):
        """Adds formatting to generated sentence.

        Args:
            unformatted_sentence (str): Unformatted generated sentence.

        Returns:
            formatted_sentence (str): Formatted generated sentence with
                                      first word capitalized and punctation at end.
        """
        punctuation_list = ['!', '?', '.']
        chance = [0.2, 0.1, 0.9]
        formatted_sentence = unformatted_sentence.capitalize()
{'fraction_non_alphanumeric': 0.10933940774487472, 'fraction_numerical': 0.005884586180713743, 'mean_word_length': 2.156980227681246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2531613', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1461, 'n_words': 344}