Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 96f91cf

Browse files
committed
Reduce the maximum number of output lines to 2 in playbot
1 parent 30e83e4 commit 96f91cf

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/bin/playbot.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,23 @@ fn main() {{
140140
return Ok(String::from("output too long, bailing out :("));
141141
}
142142

143-
// Print outputs up to 3 lines in length. Above that, print the first 2 lines followed by a
143+
// Print outputs up to 2 lines in length. Above that, print the first line followed by a
144144
// shortened playpen link.
145145
let lines: Vec<&str> = out.lines().collect();
146-
if lines.len() <= 3 {
146+
if lines.len() <= 2 {
147147
return Ok(lines.join("\n"));
148148
}
149149

150-
// Take the first 2 lines and append the URL
151-
let mut response = lines[..3].join("\n");
152-
match self.pastebin(&code) {
153-
Ok(short_url) => response.push_str(&format!("\n(output truncated; full output at {})",
154-
short_url)),
150+
// Take the first line and append the URL
151+
let response = lines[0];
152+
Ok(match self.pastebin(&code) {
153+
Ok(short_url) => format!("{}\n(output truncated; full output at {})",
154+
response, short_url),
155155
Err(e) => {
156156
error!("shortening url failed: {}", e);
157-
response.push_str("\n(output truncated; shortening URL failed)");
157+
format!("{}\n(output truncated; shortening URL failed)", response)
158158
}
159-
}
160-
161-
Ok(response)
159+
})
162160
}
163161

164162
fn handle_cmd(&mut self, response_to: &str, msg: &str) {

0 commit comments

Comments
 (0)