Compare commits

...

2 Commits

Author SHA1 Message Date
legitnull 3b929bfc3c fix scream to accept in qoutes for valid spacing 2023-03-18 00:03:41 -06:00
legitnull df3c5be437 fix invade nick collisions to leet 2023-03-17 22:24:06 -06:00
3 changed files with 18 additions and 10 deletions

View File

@ -18,7 +18,7 @@ colored = "2"
tokio-socks = "0.5.1"
socks = "0.3.4"
random_word = "0.3.0"
#leetspeak = "0.2.0"
leetspeak = "0.2.0"
irc = "0.15.0"
futures = "0.3.27"
futures-util = "0.3.27"

View File

@ -53,7 +53,7 @@ async fn ai(user_message: &str, username: &str, channel: &str, config: &Config)
.messages([
ChatCompletionRequestMessageArgs::default()
.role(Role::System)
.content(format!("Respond {} as you are chatting as {}, The following is a chat message to you from {} dont mention that you are who you are they can see that:", config.accents, config.personalities, username))
.content(format!("Respond {} as you are chatting as {}, {} sent you a message, dont respond for them:", config.accents, config.personalities, username))
.build()
.unwrap(),
ChatCompletionRequestMessageArgs::default()
@ -69,8 +69,11 @@ async fn ai(user_message: &str, username: &str, channel: &str, config: &Config)
let response = client.chat().create(request).await.unwrap();
let response_text = response.choices.first().unwrap().message.content.trim().to_string();
let regex = Regex::new(r#""|[gG][1iI][rR]\s"#).unwrap(); // THIS IS FUCKING UP EVERYTHING
let regex2 = Regex::new(r#""|[gG][1iI][rR]:\s"#).unwrap(); // THIS IS FUCKING UP EVERYTHING
let response_text = regex.replace_all(&response_text, "").trim().to_string();
let response_text = regex2.replace_all(&response_text, "").trim().to_string();
println!("{}", response_text);
let response_lines = response_text.split("\n").filter(|line| !line.trim().is_empty());
let mut responses = Vec::new();

View File

@ -6,6 +6,8 @@ use openssl::ssl::{SslConnector, SslMethod};
use serde::Deserialize;
use toml::{Value, to_string};
use colored::*;
use leetspeak;
use regex::Regex;
//use anyhow::Result;
//use socks5_proxy::{client, Addr};
@ -20,10 +22,6 @@ struct Config {
//invaders: Vec<String>,
server: String,
port: u16,
proxy_server: String,
proxy_port: u16,
}
pub struct InvadeCommand;
@ -33,6 +31,7 @@ impl Command for InvadeCommand {
let mut response = vec![];
if message.contains("PRIVMSG") && message.contains(":%invade") {
let parts: Vec<&str> = message.split_whitespace().collect();
let num_invaders = parts[4].parse::<u32>().unwrap_or(1) as usize;
let channel = parts[2];
@ -50,6 +49,7 @@ impl Command for InvadeCommand {
let config_clone = config.clone();
let screaming = scream.to_string();
let command_channel = channel.to_string();
let thread_invader = random_word::gen(); // change to leetspeak on nick collision
std::thread::spawn(move || {
@ -88,6 +88,11 @@ impl Command for InvadeCommand {
println!("{} {}","[%] PONG:".bold().green(), thread_invader.blue());
ssl_stream.write_all(response.as_bytes()).unwrap();
}
if message.starts_with("433") { // Numeric reply for nickname in use
let leet_nick = leetspeak::translate(&thread_invader);
let nick_command = format!("NICK {}\r\n", leet_nick);
ssl_stream.write_all(nick_command.as_bytes()).unwrap();
}
// turn to mods
// setup so these will only run from the server admin to avoid handle/host conflicts
let commandi = format!("PRIVMSG {} :%%",command_channel); // & check for admin and verify with server
@ -106,10 +111,10 @@ impl Command for InvadeCommand {
ssl_stream.write_all(response.as_bytes()).unwrap();
}
if message.contains("PRIVMSG") && message.contains(":%%scream") {
let parts: Vec<&str> = message.splitn(3, ":%%scream ").collect();
let invade_channel = parts[1];
if parts.len() == 2 {
let scream = parts[1];
let re = Regex::new(r#"%%scream\s+([^"]+?)\s+"([^"]*?)"\s*"#).unwrap();
if let Some(captures) = re.captures(message) {
let invade_channel = captures.get(1).map_or("", |m| m.as_str());
let scream = captures.get(2).map_or("", |m| m.as_str());
let response = format!("PRIVMSG {} :{}\r\n", invade_channel, scream);
ssl_stream.write_all(response.as_bytes()).unwrap();
}