bot icon indicating copy to clipboard operation
bot copied to clipboard

Don't upload to pastebin when no truncation

Open vivekashok1221 opened this issue 9 months ago • 0 comments

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. image image

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 from str.split("\n") to str.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 lines

New behaviour: image image

vivekashok1221 avatar May 12 '24 22:05 vivekashok1221