From 1aa5c4dc662ae36b404d434826b55ee810c4698b Mon Sep 17 00:00:00 2001 From: legitnull Date: Sat, 18 Feb 2023 22:00:55 -0700 Subject: [PATCH] color --- Cargo.toml | 1 + src/main.rs | 9 +++++---- src/modules/invade.rs | 1 - src/modules/ping.rs | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ee864e..a17c21e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ regex = "1.7.1" toml = "0.7.2" serde = "1.0.152" tokio-openssl = "0.6.3" +colored = "2" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ec094b2..a096a20 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use std::io::Write; use openssl::ssl::{SslMethod, SslConnector}; use toml::Value; use serde::Deserialize; +use colored::*; mod modules { pub trait Command { fn handle(&self, message: &str) -> Vec; @@ -74,7 +75,7 @@ fn main() { // RESPOND TO PINGS if message.starts_with("PING") { - println!("[%] PONG {}", config.nick); + println!("[%] PONG {}", config.nick.blue()); ssl_stream.write_all("PONG ircd.chat\r\n".as_bytes()).unwrap(); continue; // skip processing the PING message further } @@ -90,7 +91,7 @@ fn main() { let parts: Vec<&str> = message.splitn(2, ' ').collect(); // Check if user is admin_user let username = parts[0].trim_start_matches(':').split("!").next().unwrap(); if !admin_users.contains(&username.to_string()) { - println!("[!] UNAUTHORIZED: {}", username); + println!("[!] UNAUTHORIZED: {}", username.red()); continue; // ... } if message.contains(":%ping") { @@ -118,7 +119,7 @@ fn main() { let parts: Vec<&str> = message.splitn(2, ' ').collect(); // split the message into two parts at the first space let username = parts[0].trim_start_matches(':').split("!").next().unwrap(); if ignored_users.contains(&username.to_string()) { - println!("[!] IGNORED: {}", username); + println!("[!] IGNORED: {}", username.red()); continue; } for response in ai.handle(message, ) { @@ -129,7 +130,7 @@ fn main() { }, Err(e) => { - println!("Error: {}", e); + println!("[!] ERROR: {}", e); break; }, } diff --git a/src/modules/invade.rs b/src/modules/invade.rs index eb0ae1c..6ae5b39 100644 --- a/src/modules/invade.rs +++ b/src/modules/invade.rs @@ -6,7 +6,6 @@ use std::net::TcpStream; use openssl::ssl::{SslConnector, SslMethod}; use serde::Deserialize; use toml::Value; - #[derive(Clone, Deserialize)] struct Config { invaders: Vec, diff --git a/src/modules/ping.rs b/src/modules/ping.rs index 73db193..80ace04 100644 --- a/src/modules/ping.rs +++ b/src/modules/ping.rs @@ -1,7 +1,6 @@ use std::time::{Instant}; use crate::modules::Command; - pub struct PingCommand; impl Command for PingCommand { fn handle(&self, message: &str) -> Vec {