Don't upload to pastebin when no truncation #3046
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes issue #2492
(PR description ripped from #3045)
If the output generated by snekbox has 11 lines, the output sent to Discord as well as the contents uploaded to our pastebin is the exact same.
This is because we always truncate the output to 11 lines, but we check if the number of lines is more than 10 to decide if we need upload to the pastebin. Basically, the current logic for deciding if the output is uploaded to pastebin or not relies on the extra 11th line of output. This works when the output has 12 lines or more (11 lines displayed, full output sent to pastebin), or if it the output has 10 lines or less. But when it is 11, the 11th line is included in the output as well as uploaded to the pastebin (we truncate to 11 lines but upload to the pastebin if the output has more than 10 lines). I'd say this is because of the incorrect fix for #709 but don't quote me on that.
Another thing I noticed is that we display 11 lines in Discord when
MAX_OUTPUT_BLOCK_LINES
is 10. I initially thought this was introduced in this commit when we switched fromstr.split("\n")
tostr.splitlines()
but it seems like ever since we started truncating eval output, we've been displaying 11 lines. If we indeed intend to display 11 lines of output, we should consider updating MAX_OUTPUT_BLOCK_LINES. In this PR, I've truncated the output to 10 linesNew behaviour: