Add very rough host lookup functionality.
Currently just based on running host on the machine.
This commit is contained in:
parent
a356b7631d
commit
79487dc3cd
4 changed files with 18 additions and 0 deletions
BIN
.vscode/.browse.VC.db
vendored
Normal file
BIN
.vscode/.browse.VC.db
vendored
Normal file
Binary file not shown.
BIN
.vscode/.browse.VC.db-shm
vendored
Normal file
BIN
.vscode/.browse.VC.db-shm
vendored
Normal file
Binary file not shown.
BIN
.vscode/.browse.VC.db-wal
vendored
Normal file
BIN
.vscode/.browse.VC.db-wal
vendored
Normal file
Binary file not shown.
18
src/main.rs
18
src/main.rs
|
@ -113,6 +113,19 @@ fn handle_privmsg(target: &String, message_body: &String, message_obj: &Message,
|
||||||
},
|
},
|
||||||
None => (),
|
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") {
|
} else if inner_message.starts_with("bot-quit") {
|
||||||
if server.config().is_owner(source_nick) {
|
if server.config().is_owner(source_nick) {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
@ -189,3 +202,8 @@ fn get_stocks(symbol: &String) -> String {
|
||||||
}
|
}
|
||||||
reply_message
|
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()
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue