def check_user(self, msg, flow): """Checks to make sure that either the user started the flow, or is a bot admin""" if glob(get_acl_usr(msg), self.bot_config.BOT_ADMINS): return True elif glob(get_acl_usr(msg), flow.requestor.person): return True return False
def check_user(self, msg, flow): """Checks to make sure that either the user started the flow, or is a bot admin """ if glob(get_acl_usr(msg), self.bot_config.BOT_ADMINS): return True elif glob(get_acl_usr(msg), flow.requestor.person): return True return False
def flows_status(self, msg, args): """ Displays the list of started flows. """ with io.StringIO() as response: if not self._bot.flow_executor.in_flight: response.write('No Flow started.\n') else: if not [flow for flow in self._bot.flow_executor.in_flight if self.check_user(msg, flow)]: response.write('No Flow started for current user: \n{}\n'.format(get_acl_usr(msg))) else: if args: for flow in self._bot.flow_executor.in_flight: if self.check_user(msg, flow): if flow.name == args: self.recurse_node(response, [], flow.root, flow) else: for flow in self._bot.flow_executor.in_flight: if self.check_user(msg, flow): next_steps = ['\\*{}\\*'.format(str(step[1].command)) for step in flow._current_step.children if step[1].command] template = '\\>>> {} is using flow \\*{}\\* on step \\*{}\\*\nNext Step(s): \n{}' text = template.format(str(flow.requestor), flow.name, str(flow.current_step), '\n'.join(next_steps)) response.write(text) return response.getvalue()