From b2f11ca60a085b26832893345df5dcbcb8c378f9 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Sun, 9 Feb 2025 21:27:01 +0300 Subject: [PATCH] spam command --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 714a6d9..dc1b14a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -180,8 +180,14 @@ fn format_message(message: String) -> Option { } fn on_command(host: &str, command: &str) -> Result<(), Box> { - if command == "/clear" { - send_message(host, &"\n".repeat(MAX_MESSAGES))?; + let command = command.trim_start_matches("/"); + let (command, args) = command.split_once(" ").unwrap_or((&command, "")); + let args = args.split(" ").collect::>(); + + if command == "clear" { + send_message(host, &format!("\r\x1B[1A{}", " ".repeat(64)).repeat(MAX_MESSAGES))?; + } else if command == "spam" { + send_message(host, &format!("\r\x1B[1A{}{}", args.join(" "), " ".repeat(10)).repeat(MAX_MESSAGES))?; } Ok(())