From db6f753d6e69870acb46a610f8d32c973fde6ba7 Mon Sep 17 00:00:00 2001 From: Thelie Date: Tue, 18 May 2021 21:53:10 +0200 Subject: [PATCH] =?UTF-8?q?I=20just=20realized=20I=20need=20to=20do=20the?= =?UTF-8?q?=20detection=20of=20usernames=E2=80=A6=20Some=20other=20day.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/servers.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/servers.rs b/src/servers.rs index b40a097..48eded4 100644 --- a/src/servers.rs +++ b/src/servers.rs @@ -23,6 +23,7 @@ use irc_proto::command::{ CapSubCommand, Command, }; +use toml::map::Map; use irc_proto::message::Message; use toml::value::Value; @@ -142,7 +143,8 @@ pub fn handle_server(config: Value, tx: Sender<[String; 4]>) .ok_or("Could not get server adress from config")?; let nick = config.get("nickname").unwrap().as_str() .ok_or("Could not get nickname from config")?.to_owned(); - + let clients = config.get("clients").unwrap().as_table() + .get_or_insert(&Map::new()); let mut stream = super::connect::connect_irc(&config).unwrap(); let mut message_queue = get_irc_identify_messages(&config).unwrap(); @@ -178,16 +180,19 @@ pub fn handle_server(config: Value, tx: Sender<[String; 4]>) None => () } match data { - Some(d) => { - // There must be a better way to do this… - let d = [ - server_name.to_owned(), - d[0].clone(), - d[1].clone(), - d[2].clone() - ]; - tx.send(d)? - }, + Some(d) => match clients.get(d[0].clone()) { + Some(addr) => { + // There must be a better way to do this… + let out = [ + server_name.to_owned(), + d[0].clone(), + d[1].clone(), + d[2].clone(), + ]; + tx.send(out)? + }, + None => (), + }, None => (), } }