async def process_wordcloud(self, ctx, subject, data_uid, filters, dirty=False): """Function for handling wordcloud plots. Need to make this separate from the command so it can be called by df!generate""" wordcloud_file_name = str(uuid.uuid4().hex) + '-word-cloud.png' response_file_name = wordcloud_file_name.replace('.png', '.json') payload = {'data_uid': data_uid, 'filters': filters, 'wordcloud_file_name': wordcloud_file_name, 'dirty': dirty} # Invoke the lambda function ok = await self.get_lambda_files(config.lambda_wordcloud_name, payload, [wordcloud_file_name, response_file_name], 10, self.wordcloud_response, ctx, subject, wordcloud_file_name, response_file_name, dirty) if not ok: await ctx.send( f'Wordcloud request timed out. Maybe try again. You can also report this here:' f' {config.report_issue_url}' ) elif ctx.invoked_with == 'generate': # Start the last step in the process... await ctx.send('Starting task 4 of 4...') state_size, newline = db_queries.get_markov_settings(self.parent_cog.session, ctx, subject) markov_cog = self.bot.get_cog('ModelCommands') await ctx.send('Markovify request submitted...') await markov_cog.process_markovify(ctx, subject, data_uid, filters, state_size, newline)
async def off(self, ctx, *, subject: discord.Member): if subject: state_size, _ = db_queries.get_markov_settings( self.session, ctx, subject) db_queries.update_markov_settings(self.session, ctx, subject, state_size, False) await ctx.send(f'markovify newline off for user {subject.name}') else: await ctx.send('Usage: `df!markovify newline off <User#0000>`')
async def settings(self, ctx, *, subject: discord.Member): """Displays the current markovify settings.""" if subject: state_size, newline = db_queries.get_markov_settings( self.session, ctx, subject) await ctx.send(f'state size: {state_size}') await ctx.send(f'newline: {newline}') else: await ctx.send('Usage: `df!markovify settings <User#0000>`')
async def state_size(self, ctx, subject: discord.Member, new_value: int): """Changes the state size. Default value is 3. Smaller values tend to generate more chaotic sentences.""" old_value, newline = db_queries.get_markov_settings( self.session, ctx, subject) db_queries.update_markov_settings(self.session, ctx, subject, new_value, newline) await ctx.send( f'Markovify state size changed from {old_value} to {new_value} for {subject.name}' )
async def generate(self, ctx, *, subject: discord.Member): """Generates a markov chain model and sample responses in the style of your subject""" if subject: data_id = await db_queries.get_latest_dataset( self.session, ctx, subject) filters = db_queries.find_filters(self.session, ctx, subject) if data_id: state_size, newline = db_queries.get_markov_settings( self.session, ctx, subject) await ctx.send('Markovify request submitted...') await self.process_markovify(ctx, subject, data_id, filters, state_size, newline) else: await ctx.message.channel.send(f'Usage: `df!markovify User#0000`')
async def state_size(self, ctx, subject: discord.Member = None, new_value: int = None): """Changes the state size. Default value is 3. Smaller values tend to generate more chaotic sentences.""" if subject and new_value: old_value, newline = db_queries.get_markov_settings( self.session, ctx, subject) db_queries.update_markov_settings(self.session, ctx, subject, new_value, newline) await ctx.send( f'Markovify state size changed from {old_value} to {new_value} for {subject.name}' ) else: await ctx.send( 'Usage: `df!markovify state_size <User#0000> <value>`')