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. """ if len(set(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 async with ctx.typing(): async with ctx.db as connection: coros = [] for user in users: if user == ctx.author: await OptInStatus.is_opted_in(connection, ctx) else: await OptInStatus.is_public(connection, ctx, user) coros.append( MessageLog.get_user_log(connection, user, is_nsfw)) query = ("mum", 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 connection: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ("cgm", is_nsfw, 2, ctx.guild.id) coro = MessageLog.get_guild_log(connection, ctx.guild, is_nsfw) 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 connection: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ("gm", is_nsfw, 3, ctx.guild.id) coro = MessageLog.get_guild_log(connection, ctx.guild, is_nsfw) 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 connection: is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ("gm", is_nsfw, 3, ctx.guild.id) coro = MessageLog.get_guild_log(connection, ctx.guild, is_nsfw, False) 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 = cast(discord.User, user or ctx.author) async with ctx.typing(): async with ctx.db as connection: await OptInStatus.is_public(connection, ctx, user) is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ("cum", is_nsfw, 2, user.id) coro = MessageLog.get_user_log(connection, user, is_nsfw) 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 = cast(discord.User, user or ctx.author) async with ctx.typing(): async with ctx.db as connection: await OptInStatus.is_public(connection, ctx, user) is_nsfw = ctx.channel.is_nsfw() if ctx.guild is not None else False query = ("um", is_nsfw, 2, user.id) coro = MessageLog.get_user_log(connection, user, is_nsfw) model = await self.get_model(query, coro, order=2) await self.send_markov(ctx, model, 2)