diff options
author | 2019-10-24 10:45:14 +0800 | |
---|---|---|
committer | 2019-10-24 10:45:14 +0800 | |
commit | 28985df9fd98ae2d22b9606f80f63a96040424cf (patch) | |
tree | 2a97996f8b4743f6106f46323d9b35845c77b63c | |
parent | Deployment trigger (diff) |
Prepend emoji indicative of success of !eval
-rw-r--r-- | bot/cogs/snekbox.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 81185cf3e..7316f9583 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -115,6 +115,16 @@ class Snekbox(Cog): return msg, error + @staticmethod + def get_status_emoji(results: dict) -> str: + """Return an emoji corresponding to the status code or lack of output in result.""" + if not results["stdout"].strip(): # No output + return ":warning:" + elif results["returncode"] == 0: # No error + return ":white_check_mark:" + else: # Exception + return ":x:" + async def format_output(self, output: str) -> Tuple[str, Optional[str]]: """ Format the output and return a tuple of the formatted output and a URL to the full output. @@ -204,7 +214,8 @@ class Snekbox(Cog): else: output, paste_link = await self.format_output(results["stdout"]) - msg = f"{ctx.author.mention} {msg}.\n\n```py\n{output}\n```" + icon = self.get_status_emoji(results) + msg = f"{ctx.author.mention} {icon} {msg}.\n\n```py\n{output}\n```" if paste_link: msg = f"{msg}\nFull output: {paste_link}" |