diff options
| -rw-r--r-- | bot/exts/utils/snekbox/_cog.py | 22 | ||||
| -rw-r--r-- | bot/exts/utils/snekbox/_eval.py | 16 | 
2 files changed, 28 insertions, 10 deletions
| diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py index 605f0fa15..a46fb8f44 100644 --- a/bot/exts/utils/snekbox/_cog.py +++ b/bot/exts/utils/snekbox/_cog.py @@ -350,12 +350,26 @@ class Snekbox(Cog):              # Filter file extensions              allowed, blocked = self._filter_files(ctx, result.files) +            # Also scan failed files for blocked extensions +            failed_files = [FileAttachment(name, b"") for name in result.failed_files] +            blocked.extend(self._filter_files(ctx, failed_files).blocked)              # Add notice if any files were blocked              if blocked: -                msg += ( -                    f"\n{Emojis.failmail} Some files with disallowed extensions can't be uploaded: " -                    f"**{', '.join(f.suffix for f in blocked)}**" -                ) +                blocked_sorted = sorted(set(f.suffix for f in blocked)) +                # Only no extension +                if len(blocked_sorted) == 1 and blocked_sorted[0] == "": +                    blocked_msg = "Files with no extension can't be uploaded." +                # Both +                elif "" in blocked_sorted: +                    blocked_str = ", ".join(ext for ext in blocked_sorted if ext) +                    blocked_msg = ( +                        f"Files with no extension or disallowed extensions can't be uploaded: **{blocked_str}**" +                    ) +                else: +                    blocked_str = ", ".join(blocked_sorted) +                    blocked_msg = f"Files with disallowed extensions can't be uploaded: **{blocked_str}**" + +                msg += f"\n{Emojis.failmail} {blocked_msg}"              filter_cog: Filtering | None = self.bot.get_cog("Filtering")              if filter_cog and (await filter_cog.filter_snekbox_output(msg, ctx.message)): diff --git a/bot/exts/utils/snekbox/_eval.py b/bot/exts/utils/snekbox/_eval.py index b88225adc..93262959a 100644 --- a/bot/exts/utils/snekbox/_eval.py +++ b/bot/exts/utils/snekbox/_eval.py @@ -66,7 +66,7 @@ class EvalResult:      def status_emoji(self) -> str:          """Return an emoji corresponding to the status code or lack of output in result."""          # If there are attachments, skip empty output warning -        if not self.stdout.strip() and not self.files:  # No output +        if not self.stdout.strip() and not (self.files or self.failed_files):              return ":warning:"          elif self.returncode == 0:  # No error              return ":white_check_mark:" @@ -92,14 +92,18 @@ class EvalResult:          failed_files = f"({self.get_failed_files_str()})"          n_failed = len(self.failed_files) -        files = f"file{'s' if n_failed > 1 else ''}" -        msg = f"{Emojis.failmail} Failed to upload {n_failed} {files} {failed_files}" +        s_upload = "uploads" if n_failed > 1 else "upload" +        msg = f"{Emojis.failmail} {n_failed} file {s_upload} {failed_files} failed" + +        # Exceeded file count limit          if (n_failed + len(self.files)) > FILE_COUNT_LIMIT: -            it_they = "they" if n_failed > 1 else "it" -            msg += f" as {it_they} exceeded the {FILE_COUNT_LIMIT} file limit." +            s_it = "they" if n_failed > 1 else "it" +            msg += f" as {s_it} exceeded the {FILE_COUNT_LIMIT} file limit." +        # Exceeded file size limit          else: -            msg += f". File sizes should each not exceed {sizeof_fmt(FILE_SIZE_LIMIT)}." +            s_each_file = "each file's" if n_failed > 1 else "its file" +            msg += f" because {s_each_file} size exceeds {sizeof_fmt(FILE_SIZE_LIMIT)}."          return msg | 
