diff options
author | 2019-10-24 13:48:47 +1000 | |
---|---|---|
committer | 2019-10-24 13:48:47 +1000 | |
commit | e05ed5341b94099829a3ba9e39e74c4dbc7c0485 (patch) | |
tree | dbe06ea821a6973906d4235eebb460e6152f9e36 | |
parent | Merge pull request #547 from python-discord/#540-dont-show-infraction-total (diff) | |
parent | Merge branch 'master' into eval-emojis (diff) |
Prepend emoji indicative of success of !eval (#552)
Prepend emoji indicative of success of !eval
Co-authored-by: null <[email protected]>
-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 c0390cb1e..362968bd0 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. @@ -201,7 +211,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}" |