bot/exts/markov.py
async def hivemind(
        self,
        ctx: commands.Context,
        channels: commands.Greedy[discord.TextChannel] = None,
        text: Optional[str] = None
    ):
        """Generate some text based off users in the server

        Optionally provide:
            Channels: which channels to use (default: current channel)
            Text: what should the message start with"""
        models: list[InformalText] = []
        if not channels:
            channels = [ctx.channel]

        for channel in channels:
            for data in self.db.table('chains').search(where('channel') == channel.id):
                models.append(InformalText.from_dict(data['model']))

        if not models:
            await ctx.send('No data!')
            return

        model = markovify.combine(models)

        try:
            if text:
                generated = model.make_sentence_with_start(text, strict=False, tries=500)
            else:
                generated = model.make_sentence(tries=500)

            if generated is None or not generated.strip():
                raise ValueError('Failed to generate message')

        except (KeyError, ValueError, markovify.text.ParamError) as e:
            raise BrokenChain from e

        await ctx.send(generated)
Generate some text based off users in the server

        Optionally provide:
            Channels: which channels to use (default: current channel)
            Text: what should the message start with
Generate some text based off users in the server
Optionally provide:
Channels: which channels to use (default: current channel)
Text: what should the message start with
Generate some text based off users in the server Optionally provide : Channels : which channels to use ( default : current channel ) Text : what should the message start with
async def hivemind(
        self,
        ctx: commands.Context,
        channels: commands.Greedy[discord.TextChannel] = None,
        text: Optional[str] = None
    ):
        models: list[InformalText] = []
        if not channels:
            channels = [ctx.channel]
        for channel in channels:
            for data in self.db.table('chains').search(where('channel') == channel.id):
                models.append(InformalText.from_dict(data['model']))
        if not models:
            await ctx.send('No data!')
            return
        model = markovify.combine(models)
        try:
            if text:
                generated = model.make_sentence_with_start(text, strict=False, tries=500)
            else:
                generated = model.make_sentence(tries=500)
            if generated is None or not generated.strip():
                raise ValueError('Failed to generate message')
        except (KeyError, ValueError, markovify.text.ParamError) as e:
            raise BrokenChain from e
        await ctx.send(generated)
async def hivemind ( self , ctx : commands . Context , channels : commands . Greedy [ discord . TextChannel ] = None , text : Optional [ str ] = None ) : models : list [ InformalText ] = [ ] if not channels : channels = [ ctx . channel ] for channel in channels : for data in self . db . table ( 'chains' ) . search ( where ( 'channel' ) == channel . id ) : models . append ( InformalText . from_dict ( data [ 'model' ] ) ) if not models : await ctx . send ( 'No data!' ) return model = markovify . combine ( models ) try : if text : generated = model . make_sentence_with_start ( text , strict = False , tries = 500 ) else : generated = model . make_sentence ( tries = 500 ) if generated is None or not generated . strip ( ) : raise ValueError ( 'Failed to generate message' ) except ( KeyError , ValueError , markovify . text . ParamError ) as e : raise BrokenChain from e await ctx . send ( generated )
Generate some text based off users in the server
Optionally provide:
Channels: which channels to use (default: current channel)
Text: what should the message start with
Generate some text based off users in the server Optionally provide : Channels : which channels to use ( default : current channel ) Text : what should the message start with
"""Generate some text based off users in the server

        Optionally provide:
            Channels: which channels to use (default: current channel)
            Text: what should the message start with"""
self
ctx
commands.Context
channels
commands.Greedy[discord.TextChannel]
text
Optional[str]