This commit is contained in:
legitnull 2023-02-18 22:00:55 -07:00
parent c63bf39766
commit 1aa5c4dc66
4 changed files with 6 additions and 6 deletions

View File

@ -14,3 +14,4 @@ regex = "1.7.1"
toml = "0.7.2" toml = "0.7.2"
serde = "1.0.152" serde = "1.0.152"
tokio-openssl = "0.6.3" tokio-openssl = "0.6.3"
colored = "2"

View File

@ -4,6 +4,7 @@ use std::io::Write;
use openssl::ssl::{SslMethod, SslConnector}; use openssl::ssl::{SslMethod, SslConnector};
use toml::Value; use toml::Value;
use serde::Deserialize; use serde::Deserialize;
use colored::*;
mod modules { mod modules {
pub trait Command { pub trait Command {
fn handle(&self, message: &str) -> Vec<String>; fn handle(&self, message: &str) -> Vec<String>;
@ -74,7 +75,7 @@ fn main() {
// RESPOND TO PINGS // RESPOND TO PINGS
if message.starts_with("PING") { 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(); ssl_stream.write_all("PONG ircd.chat\r\n".as_bytes()).unwrap();
continue; // skip processing the PING message further 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 parts: Vec<&str> = message.splitn(2, ' ').collect(); // Check if user is admin_user
let username = parts[0].trim_start_matches(':').split("!").next().unwrap(); let username = parts[0].trim_start_matches(':').split("!").next().unwrap();
if !admin_users.contains(&username.to_string()) { if !admin_users.contains(&username.to_string()) {
println!("[!] UNAUTHORIZED: {}", username); println!("[!] UNAUTHORIZED: {}", username.red());
continue; // ... continue; // ...
} }
if message.contains(":%ping") { 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 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(); let username = parts[0].trim_start_matches(':').split("!").next().unwrap();
if ignored_users.contains(&username.to_string()) { if ignored_users.contains(&username.to_string()) {
println!("[!] IGNORED: {}", username); println!("[!] IGNORED: {}", username.red());
continue; continue;
} }
for response in ai.handle(message, ) { for response in ai.handle(message, ) {
@ -129,7 +130,7 @@ fn main() {
}, },
Err(e) => { Err(e) => {
println!("Error: {}", e); println!("[!] ERROR: {}", e);
break; break;
}, },
} }

View File

@ -6,7 +6,6 @@ use std::net::TcpStream;
use openssl::ssl::{SslConnector, SslMethod}; use openssl::ssl::{SslConnector, SslMethod};
use serde::Deserialize; use serde::Deserialize;
use toml::Value; use toml::Value;
#[derive(Clone, Deserialize)] #[derive(Clone, Deserialize)]
struct Config { struct Config {
invaders: Vec<String>, invaders: Vec<String>,

View File

@ -1,7 +1,6 @@
use std::time::{Instant}; use std::time::{Instant};
use crate::modules::Command; use crate::modules::Command;
pub struct PingCommand; pub struct PingCommand;
impl Command for PingCommand { impl Command for PingCommand {
fn handle(&self, message: &str) -> Vec<String> { fn handle(&self, message: &str) -> Vec<String> {