diff --git a/.vscode/.browse.VC.db b/.vscode/.browse.VC.db new file mode 100644 index 0000000..313e4ee Binary files /dev/null and b/.vscode/.browse.VC.db differ diff --git a/.vscode/.browse.VC.db-shm b/.vscode/.browse.VC.db-shm new file mode 100644 index 0000000..fdc4e88 Binary files /dev/null and b/.vscode/.browse.VC.db-shm differ diff --git a/.vscode/.browse.VC.db-wal b/.vscode/.browse.VC.db-wal new file mode 100644 index 0000000..9f6c12c Binary files /dev/null and b/.vscode/.browse.VC.db-wal differ diff --git a/src/main.rs b/src/main.rs index 207f74a..684ba81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -113,6 +113,19 @@ fn handle_privmsg(target: &String, message_body: &String, message_obj: &Message, }, None => (), } + } else if inner_message.starts_with("host") { + lazy_static! { static ref HOST_REGEX: Regex = Regex::new("(host )(.+)$").unwrap(); } + let mut host_target = String::new(); + match HOST_REGEX.captures(&inner_message) { + Some(capture) => { + match capture.at(2) { + Some(target_match) => host_target = String::from(target_match), + None => (), + } + server.send_privmsg(target, &format!("{}: {}", source_nick, &get_host(&host_target))).unwrap(); + }, + None => (), + } } else if inner_message.starts_with("bot-quit") { if server.config().is_owner(source_nick) { std::process::exit(0); @@ -189,3 +202,8 @@ fn get_stocks(symbol: &String) -> String { } reply_message } + +fn get_host(target: &String) -> String { + let command = std::process::Command::new("host").arg(target).output().expect("failed to execute process"); + String::from_utf8_lossy(&command.stdout).into_owned() +} \ No newline at end of file