def decorated_command(plugin_obj, data, user_data): parser = argparse.ArgumentParser(prog=kwargs["name"], description=kwargs["description"], usage=kwargs["usage"]) # Dynamically add in the required and optional arguments: arg_type = ["required", "optional"] for at in arg_type: if kwargs.get(at): for argument in kwargs[at]: # If there is a list of available values, then ensure that they are added in for argparse to # process properly. This can be done 1 of two ways: # 1.) [Not recommended] Use argparse directly by passing in a fixed list within # `properties["choices"]` # # 2.) [Recommended] Add `choices` outside of `properties` where you can define where # the list of values appear within the Plugin's command config. This is # preferred, because it reflects how the command is actually configured after the plugin's # `setup()` method is run. # # To make use of this properly, you need to have the help text contain: "{values}" # This will then ensure that the list of values are properly in there. ## if argument.get("choices"): # Add the dynamic choices: argument["properties"]["choices"] = plugin_obj.commands[kwargs["name"]][argument["choices"]] # Fix the help text: argument["properties"]["help"] = argument["properties"]["help"].format( values=", ".join(plugin_obj.commands[kwargs["name"]][argument["choices"]]) ) parser.add_argument(argument["name"], **argument["properties"]) # Remove the command from the command string: split_args = shlex.split(data["text"])[1:] try: args = vars(parser.parse_args(split_args)) except SystemExit as _: send_info(data["channel"], format_help_text(data, user_data, **kwargs), markdown=True, ephemeral_user=user_data["id"]) return # Perform additional verification: try: args = perform_additional_verification(plugin_obj, args, **kwargs) except ParseException as pe: send_error(data["channel"], pe.format_proper_usage(user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) return except Exception as e: send_error(data["channel"], "An exception was encountered while running validation for the input. " "The exception details are: `{}`".format(str(e)), markdown=True) return # Run the next function: data["command_name"] = kwargs["name"] return func(plugin_obj, data, user_data, **args)
def decorated_command(plugin_obj, data, user_data): parser = argparse.ArgumentParser(prog=kwargs["name"], description=kwargs["description"], usage=kwargs["usage"]) # Dynamically add in the required and optional arguments: arg_type = ["required", "optional"] for at in arg_type: if kwargs.get(at): for argument in kwargs[at]: # If there is a list of available values, then ensure that they are added in for argparse to # process properly. This can be done 1 of two ways: # 1.) [Not recommended] Use argparse directly by passing in a fixed list within # `properties["choices"]` # # 2.) [Recommended] Add `choices` outside of `properties` where you can define where # the list of values appear within the Plugin's command config. This is # preferred, because it reflects how the command is actually configured after the plugin's # `setup()` method is run. # # To make use of this properly, you need to have the help text contain: "{values}" # This will then ensure that the list of values are properly in there. ## if argument.get("choices"): # Add the dynamic choices: argument["properties"]["choices"] = plugin_obj.commands[kwargs["name"]][argument["choices"]] # Fix the help text: argument["properties"]["help"] = argument["properties"]["help"].format( values=", ".join(plugin_obj.commands[kwargs["name"]][argument["choices"]]) ) parser.add_argument(argument["name"], **argument["properties"]) # Remove the command from the command string: split_args = shlex.split(data["text"])[1:] try: args = vars(parser.parse_args(split_args)) except SystemExit as _: send_info(data["channel"], format_help_text(data, user_data, **kwargs), markdown=True, ephemeral_user=user_data["id"]) return # Perform additional verification: try: args = perform_additional_verification(plugin_obj, args, **kwargs) except ParseException as pe: send_error(data["channel"], pe.format_proper_usage(user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) return except Exception as e: send_error(data["channel"], "An exception was encountered while running validation for the input. " "The exception details are: `{}`".format(str(e)), markdown=True) return # Run the next function: data["command_name"] = kwargs["name"] return func(plugin_obj, data, user_data, **args)
def listachat(self, data, user_data, history, for_user): session = DBSession() today = datetime.date.today() if history < 1: send_error(data['channel'], "Non non non, history doit être > 1 <@{0}> ;)".format( user_data['id']), markdown=True) return user = None if for_user: user = self.get_db_user(session, for_user) if not user: send_error(data['channel'], 'Erreur zjaifnazgoizangoiazg') delta = datetime.timedelta(days=history) start_date = today - delta query = session.query(Expense).filter(Expense.date >= start_date) if user: query = query.filter(Expense.user_id == user.id) expenses = query.all() outputs = [] if not expenses: if user: outputs.append( "Pas d'achat dans les {0} derniers jours pour {1}.".format( history, user.name)) else: outputs.append( "Pas d'achat dans les {0} derniers jours.".format(history)) else: if user: outputs.append( "Liste des achats depuis {0} jours par {1} :".format( history, user.name)) else: outputs.append( "Liste des achats depuis {0} jours :".format(history)) for expense in expenses: if user: text = "- Le {0} : {1} €".format(expense.date, expense.amount) else: text = "- {0}, le {1} : {2} €".format( expense.user.name, expense.date, expense.amount) if expense.description: text += " pour {0}".format(expense.description) outputs.append(text) send_info(data['channel'], text='\n'.join(outputs), markdown=True, thread=data["ts"])
def test_send_error(slack_client, markdown): from hubcommander.bot_components.slack_comm import send_error attachment = {"text": "ʕ•ᴥ•ʔ", "color": "danger"} if markdown: attachment["mrkdwn_in"] = ["text"] send_error("some_channel", attachment["text"], markdown) actually_said("some_channel", [attachment], slack_client)
def decorated_command(github_plugin, data, user_data, *args, **kwargs): # Check if the specified GitHub team exists: kwargs['team_id'] = github_plugin.find_team_id_by_name(kwargs[org_arg], kwargs[team_arg]) if not kwargs.get("team_id"): send_error(data["channel"], "@{}: The GitHub team: {} does not exist.".format(user_data["name"], kwargs[team_arg]), thread=data["ts"]) return # Run the next function: return func(github_plugin, data, user_data, *args, **kwargs)
def decorated_command(github_plugin, data, user_data, *args, **kwargs): # Check if the branch exists on the repo.... if not (github_plugin.check_for_repo_branch(kwargs[repo_arg], kwargs[org_arg], kwargs[branch_arg])): send_error(data["channel"], "@{}: This repository does not have the branch: `{}`.".format(user_data["name"], kwargs[branch_arg]), markdown=True, thread=data["ts"]) return # Run the next function: return func(github_plugin, data, user_data, *args, **kwargs)
def decorated_command(github_plugin, data, user_data, *args, **kwargs): # Check if the branch exists on the repo.... if not (github_plugin.check_for_repo_branch(kwargs[repo_arg], kwargs[org_arg], kwargs[branch_arg])): send_error(data["channel"], "@{}: This repository does not have the branch: `{}`.".format(user_data["name"], kwargs[branch_arg]), markdown=True) return # Run the next function: return func(github_plugin, data, user_data, *args, **kwargs)
def authenticate(self, data, user_data, **kwargs): send_info(data["channel"], "🎟 @{}: Sending a Duo notification to your device. You must approve!" .format(user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) try: result = self._perform_auth(user_data) except InvalidDuoResponseError as idre: send_error(data["channel"], "💀 @{}: There was a problem communicating with Duo. Got this status: {}. " "Aborting..." .format(user_data["name"], str(idre)), markdown=True) return False except CantDuoUserError as _: send_error(data["channel"], "💀 @{}: I can't Duo authenticate you. Please consult with your identity team." " Aborting..." .format(user_data["name"]), markdown=True) return False except Exception as e: send_error(data["channel"], "💀 @{}: I encountered some issue with Duo... Here are the details: ```{}```" .format(user_data["name"], str(e)), markdown=True) return False if not result: send_error(data["channel"], "💀 @{}: Your Duo request was rejected. Aborting..." .format(user_data["name"]), markdown=True, thread=data["ts"]) return False # All Good: send_success(data["channel"], "🎸 @{}: Duo approved! Completing request..." .format(user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) return True
def cancelmanger(self, data, user_data, for_user): session = DBSession() day = self.get_db_day(session) if not day: day = Day(date=datetime.date.today()) session.add(day) session.commit() outputs = [] if for_user: user = self.get_db_user(session, for_user) else: user = self.get_db_user(session, user_data['name']) if not user: send_error(data['channel'], 'Erreur zjaifnazgoizangoiazg', thread=data["ts"]) presence = session.query(Presence).filter( Presence.user_id == user.id, Presence.day_id == day.id).first() if not presence: if for_user: outputs.append( "@{0} n'étais pas inscrit, pas de soucis <@{1}> !".format( user.name, user_data['id'])) else: outputs.append( "Tu n'étais pas inscrit, pas de soucis <@{0}> !".format( user_data['id'])) else: session.query(Presence).filter_by(id=presence.id).delete() session.commit() if for_user: outputs.append("J'ai supprimé l'inscription de @{0}.".format( user.name)) else: outputs.append( "J'ai supprimé ta demande <@{0}>, dommage ça allait être trop bon !" .format(user_data['id'])) outputs.append("Si besoin tu !Manger à nouveau :)") send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=user_data["id"]) data['text'] = '!QuiMange' self.quimange(data, user_data)
def decorated_command(github_plugin, data, user_data, *args, **kwargs): # Check if the given GitHub user actually exists: try: found_user = github_plugin.get_github_user(kwargs[user_arg]) if not found_user: send_error(data["channel"], "@{}: The GitHub user: {} does not exist.".format(user_data["name"], kwargs[user_arg])) return except Exception as e: send_error(data["channel"], "@{}: A problem was encountered communicating with GitHub to verify the user's GitHub " "id. Here are the details:\n{}".format(user_data["name"], str(e))) return # Run the next function: return func(github_plugin, data, user_data, *args, **kwargs)
def cuisiner(self, data, user_data): session = DBSession() day = self.get_db_day(session) if not day: day = Day(date=datetime.date.today()) session.add(day) session.commit() outputs = [] user = self.get_db_user(session, user_data['name']) if not user: send_error(data['channel'], 'Erreur il faut ```python manage.py sync``` d\'abort !', thread=data["ts"]) presence = session.query(Presence).filter( Presence.user_id == user.id, Presence.day_id == day.id).first() if not presence: presence = Presence(user_id=user.id, day_id=day.id, cook=1) session.add(presence) session.commit() outputs.append( "J'ai pris en compte le fait que tu cuisinais aujourd'hui") else: presence.cook = 1 session.add(presence) session.commit() outputs.append( "J'ai pris en compte le fait que tu cuisinais aujourd'hui") send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=user_data["id"]) data['text'] = '!QuiMange' self.quimange(data, user_data)
def process_the_command(data, command_prefix): """ Will perform all command_plugins duties if a command_plugins arrived. :param data: :param command_prefix: :return: """ # Reach out to slack to get the user's information: user_data, error = get_user_data(data) if error: send_error(data["channel"], "ERROR: Unable to communicate with the Slack API. Error:\n{}".format(error)) return # Execute the message: if COMMANDS[command_prefix]["user_data_required"]: COMMANDS[command_prefix]["func"](data, user_data) else: COMMANDS[command_prefix]["func"](data)
def decorated_command(github_plugin, data, user_data, *args, **kwargs): # Check if the given GitHub user actually exists: try: found_user = github_plugin.get_github_user(kwargs[user_arg]) if not found_user: send_error(data["channel"], "@{}: The GitHub user: {} does not exist.".format(user_data["name"], kwargs[user_arg]), thread=data["ts"]) return except Exception as e: send_error(data["channel"], "@{}: A problem was encountered communicating with GitHub to verify the user's GitHub " "id. Here are the details:\n{}".format(user_data["name"], str(e)), thread=data["ts"]) return # Run the next function: return func(github_plugin, data, user_data, *args, **kwargs)
def authenticate(self, data, user_data, **kwargs): send_info( data["channel"], "🎟 @{}: Sending a Duo notification to your device. You must approve!" .format(user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) try: result = self._perform_auth(user_data) except InvalidDuoResponseError as idre: send_error( data["channel"], "💀 @{}: There was a problem communicating with Duo. Got this status: {}. " "Aborting...".format(user_data["name"], str(idre)), markdown=True) return False except CantDuoUserError as _: send_error( data["channel"], "💀 @{}: I can't Duo authenticate you. Please consult with your identity team." " Aborting...".format(user_data["name"]), markdown=True) return False except Exception as e: send_error( data["channel"], "💀 @{}: I encountered some issue with Duo... Here are the details: ```{}```" .format(user_data["name"], str(e)), markdown=True) return False if not result: send_error( data["channel"], "💀 @{}: Your Duo request was rejected. Aborting...".format( user_data["name"]), markdown=True, thread=data["ts"]) return False # All Good: send_success(data["channel"], "🎸 @{}: Duo approved! Completing request...".format( user_data["name"]), markdown=True, ephemeral_user=user_data["id"]) return True
def process_the_command(data, command_prefix): """ Will perform all command_plugins duties if a command_plugins arrived. :param data: :param command_prefix: :return: """ # Reach out to slack to get the user's information: user_data, error = get_user_data(data) if error: send_error( data["channel"], "ERROR: Unable to communicate with the Slack API. Error:\n{}". format(error)) return # Execute the message: if COMMANDS[command_prefix]["user_data_required"]: COMMANDS[command_prefix]["func"](data, user_data) else: COMMANDS[command_prefix]["func"](data)
def cancelcuisiner(self, data, user_data): session = DBSession() day = self.get_db_day(session) if not day: day = Day(date=datetime.date.today()) session.add(day) session.commit() outputs = [] user = self.get_db_user(session, user_data['name']) if not user: send_error(data['channel'], 'Erreur zjaifnazgoizangoiazg', thread=data["ts"]) presence = session.query(Presence).filter( Presence.user_id == user.id, Presence.day_id == day.id).first() if not presence: outputs.append( "Tu n'étais pas inscrit, pas de soucis <@{0}> !".format( user_data['id'])) else: presence.cook = 0 session.add(presence) session.commit() outputs.append("J'ai supprimé le fait que tu avais cuisiné") send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=user_data["id"]) data['text'] = '!QuiMange' self.quimange(data, user_data)
def enable_travis_command(self, data, user_data, org, repo): """ Enables Travis CI on a repository within the organization. Command is as follows: !enabletravis <organization> <repo> :param repo: :param org: :param user_data: :param data: :return: """ from hubcommander.command_plugins.enabled_plugins import COMMAND_PLUGINS github_plugin = COMMAND_PLUGINS["github"] # Output that we are doing work: send_info(data["channel"], "@{}: Working, Please wait...".format(user_data["name"]), thread=data["ts"]) # Get the repo information from GitHub: try: repo_result = github_plugin.check_gh_for_existing_repo(repo, org) if not repo_result: send_error(data["channel"], "@{}: This repository does not exist in {}!".format(user_data["name"], org), thread=data["ts"]) return except Exception as e: send_error(data["channel"], "@{}: I encountered a problem:\n\n{}".format(user_data["name"], e), thread=data["ts"]) return which = "pro" if repo_result["private"] else "public" try: # Sync with Travis CI so that it knows about the repo: send_info(data["channel"], ":skull: Need to sync Travis CI with GitHub. Please wait...", thread=data["ts"]) self.sync_with_travis(which) send_info(data["channel"], ":guitar: Synced! Going to enable Travis CI on the repo now...", thread=data["ts"]) travis_data = self.look_for_repo(which, repo_result) if not travis_data: send_error(data["channel"], "@{}: Couldn't find the repo in Travis for some reason...\n\n".format( user_data["name"]), thread=data["ts"]) return # Is it already enabled? if travis_data["active"]: send_success(data["channel"], "@{}: Travis CI is already enabled on {}/{}.\n\n".format( user_data["name"], org, repo), thread=data["ts"]) return # Enable it: self.enable_travis_on_repo(which, repo_result) except Exception as e: send_error(data["channel"], "@{}: I encountered a problem communicating with Travis CI:\n\n{}".format(user_data["name"], e), thread=data["ts"]) return message = "@{}: Travis CI has been enabled on {}/{}.\n\n".format(user_data["name"], org, repo) send_success(data["channel"], message, thread=data["ts"])
def enable_travis_command(self, data, user_data, org, repo): """ Enables Travis CI on a repository within the organization. Command is as follows: !enabletravis <organization> <repo> :param repo: :param org: :param user_data: :param data: :return: """ from hubcommander.command_plugins.enabled_plugins import COMMAND_PLUGINS github_plugin = COMMAND_PLUGINS["github"] # Output that we are doing work: send_info(data["channel"], "@{}: Working, Please wait...".format(user_data["name"])) # Get the repo information from GitHub: try: repo_result = github_plugin.check_gh_for_existing_repo(repo, org) if not repo_result: send_error( data["channel"], "@{}: This repository does not exist in {}!".format( user_data["name"], org)) return except Exception as e: send_error( data["channel"], "@{}: I encountered a problem:\n\n{}".format( user_data["name"], e)) return which = "pro" if repo_result["private"] else "public" try: # Sync with Travis CI so that it knows about the repo: send_info( data["channel"], ":skull: Need to sync Travis CI with GitHub. Please wait...") self.sync_with_travis(which) send_info( data["channel"], ":guitar: Synced! Going to enable Travis CI on the repo now..." ) travis_data = self.look_for_repo(which, repo_result) if not travis_data: send_error( data["channel"], "@{}: Couldn't find the repo in Travis for some reason...\n\n" .format(user_data["name"])) return # Is it already enabled? if travis_data["active"]: send_success( data["channel"], "@{}: Travis CI is already enabled on {}/{}.\n\n".format( user_data["name"], org, repo)) return # Enable it: self.enable_travis_on_repo(which, repo_result) except Exception as e: send_error( data["channel"], "@{}: I encountered a problem communicating with Travis CI:\n\n{}" .format(user_data["name"], e)) return message = "@{}: Travis CI has been enabled on {}/{}.\n\n".format( user_data["name"], org, repo) send_success(data["channel"], message)
def enable_travis_command(self, data, user_data): """ Enables Travis CI on a repository within the organization. Command is as follows: !enabletravis <organization> <repo> :param data: :return: """ from hubcommander.command_plugins.enabled_plugins import GITHUB_PLUGIN try: parser = argparse.ArgumentParser() parser.add_argument('org', type=str) parser.add_argument('repo', type=str) args, unknown = parser.parse_known_args( args=preformat_args(data["text"])) if len(unknown) > 0: raise SystemExit() args = vars(args) repo_to_set = extract_repo_name(args["repo"]) # Check that we can use this org: real_org = GITHUB_PLUGIN.org_lookup[args["org"]][0] except KeyError as _: send_error( data["channel"], '@{}: Invalid orgname sent in. Run `!ListOrgs` to see the valid orgs.' .format(user_data["name"]), markdown=True) return except SystemExit as _: send_info( data["channel"], "@{}: `!EnableTravis` usage is:\n```!EnableTravis <Organization> <Repo>" "```\nNo special characters or spaces in the variables. " "Run `!ListOrgs` to see the list of GitHub Organizations that I manage." .format(user_data["name"]), markdown=True) return # Auth? if self.commands["!EnableTravis"].get("auth"): if not self.commands["!EnableTravis"]["auth"][ "plugin"].authenticate( data, user_data, ** self.commands["!EnableTravis"]["auth"]["kwargs"]): return # Output that we are doing work: send_info(data["channel"], "@{}: Working, Please wait...".format(user_data["name"])) # Get the repo information from GitHub: try: repo_result = GITHUB_PLUGIN.check_gh_for_existing_repo( repo_to_set, real_org) if not repo_result: send_error( data["channel"], "@{}: This repository does not exist in {}!".format( user_data["name"], real_org)) return except Exception as e: send_error( data["channel"], "@{}: I encountered a problem:\n\n{}".format( user_data["name"], e)) return which = "pro" if repo_result["private"] else "public" try: # Check that the repo even exists: send_info( data["channel"], ":skull: Need to sync Travis CI with GitHub. Please wait...") self.sync_with_travis(which) send_info( data["channel"], ":guitar: Synced! Going to enable Travis CI on the repo now..." ) travis_data = self.look_for_repo(which, repo_result) if not travis_data: send_error( data["channel"], "@{}: Couldn't find the repo in Travis for some reason...\n\n" .format(user_data["name"])) return # Is it already enabled? if travis_data["active"]: send_success( data["channel"], "@{}: Travis CI is already enabled on {}/{}.\n\n".format( user_data["name"], real_org, repo_to_set)) return # Enable it: self.enable_travis_on_repo(which, repo_result) except Exception as e: send_error( data["channel"], "@{}: I encountered a problem communicating with Travis CI:\n\n{}" .format(user_data["name"], e)) return message = "@{}: Travis CI has been enabled on {}/{}.\n\n".format( user_data["name"], real_org, repo_to_set) send_success(data["channel"], message)
def mybalance(self, data, user_data, history, for_user): today = datetime.date.today() session = DBSession() if history < 1: send_error(data['channel'], "Non non non, history doit être > 1 <@{0}> ;)".format( user_data['id']), markdown=True) return if for_user: user = self.get_db_user(session, for_user) else: user = self.get_db_user(session, user_data['name']) if not user: send_error(data['channel'], 'Erreur zjaifnazgoizangoiazg') delta = datetime.timedelta(days=history) start_date = today - delta expenses = session.query(Expense).filter( Expense.user_id == user.id, Expense.date >= start_date).all() outputs = [] if not expenses: outputs.append( "Pas d'achat dans les {0} derniers jours pour {1}".format( history, user.name)) else: if for_user: outputs.append( "Liste des achats depuis {0} jours par {1} :".format( history, user.name)) else: outputs.append( "Liste de tes achats depuis {0} jours :".format(history)) for expense in expenses: text = "- Le {0} : {1} €".format(expense.date, expense.amount) if expense.description: text += " pour {0}".format(expense.description) outputs.append(text) presences = session.query(Presence).filter( Presence.user_id == user.id).join(Day).filter( Day.date >= start_date).all() if not presences: outputs.append( "Pas de repas compatibilisé dans les {0} derniers jours pour {1}" .format(history, user.name)) else: if for_user: outputs.append( "Liste des repas depuis {0} jours de {1} :".format( history, user.name)) else: outputs.append( "Liste de tes repas depuis {0} jours :".format(history)) for presence in presences: text = "- Le {0} : {1} repas à {2} €".format( presence.day.date, presence.meals, presence.day.price) outputs.append(text) if for_user: outputs.append( "Du coup, en tout, voici la balance de {0} : {1} €".format( user.name, user.balance)) else: outputs.append("Du coup, en tout, voici ta balance : {0} €".format( user.balance)) send_info(data['channel'], text='\n'.join(outputs), markdown=True, thread=data["ts"])
def manger(self, data, user_data, guest, for_user): session = DBSession() if guest < 0: send_error( data['channel'], "Touche à ton cul avec ton nombre négatif <@{0}> ;)".format( user_data['id']), markdown=True, thread=data["ts"]) return day = self.get_db_day(session) if not day: day = Day(date=datetime.date.today()) session.add(day) session.commit() outputs = [] if for_user: user = self.get_db_user(session, for_user) from_user = self.get_db_user(session, user_data['name']) else: user = self.get_db_user(session, user_data['name']) if not user: send_error(data['channel'], 'Erreur il faut ```python manage.py sync``` d\'abort !', thread=data["ts"]) presence = session.query(Presence).filter( Presence.user_id == user.id, Presence.day_id == day.id).first() if not presence: presence = Presence(user_id=user.id, day_id=day.id, meals=guest + 1) session.add(presence) session.commit() if for_user: outputs.append( "Demande enregistrée par <@{0}> pour <@{1}>".format( from_user.slackid, user.slackid)) if guest > 0: outputs.append("Je compterai {0} part(s)".format(guest + 1)) else: outputs.append("J'ai pris en compte ta demande <@{0}>".format( user_data['id'])) if guest > 0: outputs.append( "Je te compterai {0} part ce jour".format(guest + 1)) else: if presence.meals != guest + 1: presence.meals = guest + 1 session.add(presence) session.commit() if for_user: if guest > 0: outputs.append( "Demande modifiée par <@{0}> pour <@{1}>, {2} invité(s) rajoutés" .format(from_user.slackid, user.slackid, guest)) else: outputs.append( "Demande modifiée par <@{0}> pour <@{1}>, les invités ont été supprimés" .format(from_user.slackid, user.slackid, guest)) else: if guest > 0: outputs.append( "J'ai modifié ta demande, et rajouté {0} invité(s) <@{1}>" .format(guest, user.slackid)) else: outputs.append( "J'ai modifié ta demande, et enlevé les invités <@{1}>" .format(guest, user.slackid)) else: if for_user: outputs.append( "Rien n'a changé, <@{0}> était déjà inscrit <@{1}> :)". format(user.slackid, from_user.slackid)) else: outputs.append( "Rien n'a changé, tu étais déjà inscrit <@{0}> :)". format(user.slackid)) outputs.append( "Si besoin tu peux !CancelManger ou !Manger avec des invités :)") if for_user: send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=user.slackid) send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=from_user.slackid) else: send_info(data['channel'], text='\n'.join(outputs), markdown=True, ephemeral_user=user_data["id"]) data['text'] = '!QuiMange' self.quimange(data, user_data)