use moer portable tls lib and start shaping text interface

master
lance 4 years ago
parent dd409bc238
commit a0e6fd0037

2
.gitignore vendored

@ -6,3 +6,5 @@
**/*.rs.bk
config.toml
/certs

51
Cargo.lock generated

@ -38,7 +38,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
name = "bones"
version = "0.0.1"
dependencies = [
"http",
"irc",
"openssl",
]
[[package]]
@ -63,6 +65,12 @@ dependencies = [
"iovec",
]
[[package]]
name = "bytes"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
[[package]]
name = "cc"
version = "1.0.50"
@ -307,6 +315,17 @@ dependencies = [
"libc",
]
[[package]]
name = "http"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b"
dependencies = [
"bytes 0.5.4",
"fnv",
"itoa",
]
[[package]]
name = "iovec"
version = "0.1.4"
@ -323,7 +342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eb7666c9ae95dc77b874467e347bde3789773b6f48887fb3384bfe29552b466"
dependencies = [
"bufstream",
"bytes",
"bytes 0.4.12",
"chrono",
"encoding",
"failure",
@ -341,6 +360,12 @@ dependencies = [
"toml",
]
[[package]]
name = "itoa"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]]
name = "kernel32-sys"
version = "0.2.2"
@ -516,6 +541,15 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
name = "openssl-src"
version = "111.6.1+1.1.1d"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c91b04cb43c1a8a90e934e0cd612e2a5715d976d2d6cff4490278a0cddf35005"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.54"
@ -525,6 +559,7 @@ dependencies = [
"autocfg",
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]
@ -807,7 +842,7 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"mio",
"num_cpus",
@ -831,7 +866,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"tokio-io",
]
@ -842,7 +877,7 @@ version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"iovec",
"log",
@ -892,7 +927,7 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"log",
]
@ -942,7 +977,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"iovec",
"mio",
@ -1006,7 +1041,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"log",
"mio",
@ -1021,7 +1056,7 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798"
dependencies = [
"bytes",
"bytes 0.4.12",
"futures",
"iovec",
"libc",

@ -6,3 +6,5 @@ edition = "2018"
[dependencies]
irc = "0.13.6"
http = "0.2"
openssl = { version = "0.10", features = ["vendored"] }

@ -1,25 +1,51 @@
use irc::client::prelude::{IrcClient, ClientExt, Client, Command};
extern crate irc;
use irc::client::prelude::{Client, ClientExt, Command, IrcClient};
fn main() {
println!("[DEBUG] Connecting to IRC server...");
let client = IrcClient::new("config.toml").unwrap();
client.identify().unwrap();
client.for_each_incoming(|irc_msg| {
// Debug
// println!("{}", &irc_msg);
client.for_each_incoming(|im| {
if let Command::NOTICE(channel, message) = &irc_msg.command {
println!("[{:?}][{}]: {}", &irc_msg.response_target(), &channel, &message)
if let Command::NOTICE(channel, message) = &im.command {
println!("[{:?}][{}]: {}", &im.response_target(), &channel, &message)
}
if let Command::PRIVMSG(channel, message) = &irc_msg.command {
if let Command::PRIVMSG(channel, message) = &im.command {
let help_msg = vec![
format!("Hey there {}, here's what you can do.", &im.source_nickname().unwrap()),
"Say 'create:' to create a new listing, ie, 'create:This will be the title of your new post on the site'.".to_string(),
"Say 'delete:' to delete an existing listing, ie, 'delete:Name or ID of your post to delete'.".to_string(),
];
let help_msg = help_msg.join(" ");
// Print all messages
println!("[{}][{}]: {}", &irc_msg.response_target().unwrap(), &irc_msg.source_nickname().unwrap(), message);
println!(
"[{}][{}]: {}",
&im.response_target().unwrap(),
&im.source_nickname().unwrap(),
message
);
if message.contains(&format!("hey {}", client.current_nickname())) {
let _ = client.send_privmsg(&channel, format!("hey there {}", &irc_msg.source_nickname().unwrap()));
if message.starts_with("create:") {
let _ = client.send_privmsg(
&channel,
"This feature is still being worked on.",
);
} else if message.starts_with("delete:") {
let _ = client.send_privmsg(
&channel,
"This feature is still being worked on.",
);
} else if message.contains("help") {
let _ = client.send_privmsg(
&channel,
&help_msg,
);
}
}
}).unwrap();
})
.unwrap();
}

Loading…
Cancel
Save