async def multi_user_markov(self, ctx: Context, *users: discord.User): """Generate a markov chain based off a list of users messages. `users`: The list of users who's messages should be used to generate the markov chain. """ users = set(users) # type: ignore if len(users) < 2: raise commands.BadArgument( 'You need to specify at least two users.') is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False coros = list() async with ctx.typing(): async with ctx.db as conn: for user in users: if user == ctx.author: await Opt_In_Status.is_opted_in(ctx, connection=conn) else: await Opt_In_Status.is_public(ctx, user, connection=conn) coros.append( Message_Log.get_user_log(user, is_nsfw, connection=conn)) query = (is_nsfw, 3) + tuple(user.id for user in users) model = await self.get_model(query, *coros, order=3) await self.send_markov(ctx, model, 3)
async def code_guild_markov(self, ctx: Context): """Generate a markov chain code block. """ async with ctx.typing(): async with ctx.db as conn: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('cgm', is_nsfw, 2, ctx.guild.id) coro = Message_Log.get_guild_log(ctx.guild, is_nsfw, connection=conn) model = await self.get_model(query, coro, order=2) await self.send_markov(ctx, model, 2, callable=make_code)
async def guild_markov(self, ctx: Context): """Generate a markov chain based off messages in the server. """ async with ctx.typing(): async with ctx.db as conn: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('gm', is_nsfw, 3, ctx.guild.id) coro = Message_Log.get_guild_log(ctx.guild, is_nsfw, connection=conn) model = await self.get_model(query, coro, order=3) await self.send_markov(ctx, model, 3)
async def seeded_guild_markov(self, ctx: Context, *, seed: str): """Generate a markov chain based off messages in the server which starts with a given seed. `seed`: The string to attempt to seed the markov chain with. """ async with ctx.typing(): async with ctx.db as conn: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('sgm', is_nsfw, 3, ctx.guild.id) coro = Message_Log.get_guild_log(ctx.guild, is_nsfw, False, connection=conn) model = await self.get_model(query, coro, order=3) await self.send_markov(ctx, model, 3, seed=seed.lower())
async def code_user_markov(self, ctx: Context, user: Optional[discord.User] = None): """Generate a markov chain code block. """ user = user or ctx.author async with ctx.typing(): async with ctx.db as conn: await Opt_In_Status.is_public(ctx, user, connection=conn) is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('cum', is_nsfw, 2, user.id) coro = Message_Log.get_user_log(user, is_nsfw, connection=conn) model = await self.get_model(query, coro, order=2) await self.send_markov(ctx, model, 2, callable=make_code)
async def user_markov(self, ctx: Context, *, user: Optional[discord.User] = None): """Generate a markov chain based off a users messages. `user`: The user who's messages should be used to generate the markov chain, defaults to you. """ user = user or ctx.author async with ctx.typing(): async with ctx.db as conn: await Opt_In_Status.is_public(ctx, user, connection=conn) is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('um', is_nsfw, 2, user.id) coro = Message_Log.get_user_log(user, is_nsfw, connection=conn) model = await self.get_model(query, coro, order=2) await self.send_markov(ctx, model, 2)
async def seeded_user_markov(self, ctx: Context, user: Optional[discord.User] = None, *, seed: str): """Generate a markov chain based off a users messages which starts with a given seed. `user`: The user who's messages should be used to generate the markov chain, defaults to you. `seed`: The string to attempt to seed the markov chain with. """ user = user or ctx.author async with ctx.typing(): async with ctx.db as conn: await Opt_In_Status.is_public(ctx, user, connection=conn) is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ('sum', is_nsfw, 2, user.id) coro = Message_Log.get_user_log(user, is_nsfw, connection=conn) model = await self.get_model(query, coro, order=2) await self.send_markov(ctx, model, 2, seed=seed.lower())