Updated examples

This commit is contained in:
famfo 2021-12-28 15:06:59 +01:00
parent 1ede9a1b03
commit e5022403e4
18 changed files with 556 additions and 142 deletions

View file

@ -25,7 +25,7 @@ optional = true
[dependencies.tokio]
version = "1.15"
features = ["io-std", "net", "macros", "rt-multi-thread"]
features = ["io-util", "net", "macros", "rt-multi-thread"]
[dependencies.async-native-tls]
version= "0.4"

View file

@ -8,6 +8,7 @@ version = "0.1.5"
dependencies = [
"async-native-tls",
"tokio",
"tracing",
]
[[package]]
@ -483,6 +484,38 @@ dependencies = [
"syn",
]
[[package]]
name = "tracing"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
[[package]]
name = "unicode-bidi"
version = "0.3.7"

View file

@ -10,4 +10,3 @@ features = ["macros", "rt-multi-thread"]
[dependencies.async-circe]
path = "../.."

View file

@ -3,7 +3,7 @@ use async_circe::{commands::Command, Client, Config};
#[tokio::main]
async fn main() -> Result<(), tokio::io::Error> {
let config = Config::new(
&["#main", "#no-normies"],
&["#no-normies"],
"karx.xyz",
Some("+B"),
Some("async-circe"),

View file

@ -2,6 +2,30 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "async-circe"
version = "0.1.5"
dependencies = [
"async-native-tls",
"serde",
"serde_derive",
"tokio",
"toml",
"tracing",
]
[[package]]
name = "async-native-tls"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d57d4cec3c647232e1094dc013546c0b33ce785d8aeb251e1f20dfaf8a9a13fe"
dependencies = [
"native-tls",
"thiserror",
"tokio",
"url",
]
[[package]]
name = "autocfg"
version = "1.0.1"
@ -14,6 +38,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bytes"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cc"
version = "1.0.72"
@ -26,21 +56,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "circe"
version = "0.1.3"
dependencies = [
"native-tls",
"serde",
"serde_derive",
"toml",
]
[[package]]
name = "config-from-toml"
version = "0.1.0"
dependencies = [
"circe",
"async-circe",
"tokio",
]
[[package]]
@ -74,6 +95,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
dependencies = [
"matches",
"percent-encoding",
]
[[package]]
name = "getrandom"
version = "0.2.3"
@ -85,6 +116,26 @@ dependencies = [
"wasi",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "idna"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -106,6 +157,40 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "memchr"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "mio"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
]
[[package]]
name = "native-tls"
version = "0.2.8"
@ -124,6 +209,25 @@ dependencies = [
"tempfile",
]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
]
[[package]]
name = "num_cpus"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "once_cell"
version = "1.8.0"
@ -163,6 +267,18 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-project-lite"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
[[package]]
name = "pkg-config"
version = "0.3.22"
@ -326,6 +442,68 @@ dependencies = [
"winapi",
]
[[package]]
name = "thiserror"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tinyvec"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
dependencies = [
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"pin-project-lite",
"tokio-macros",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "toml"
version = "0.5.8"
@ -335,12 +513,71 @@ dependencies = [
"serde",
]
[[package]]
name = "tracing"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
[[package]]
name = "unicode-bidi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f"
[[package]]
name = "unicode-normalization"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "url"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
dependencies = [
"form_urlencoded",
"idna",
"matches",
"percent-encoding",
]
[[package]]
name = "vcpkg"
version = "0.2.15"

View file

@ -4,5 +4,10 @@ name = "config-from-toml"
version = "0.1.0"
edition = "2021"
[dependencies.circe]
[dependencies.tokio]
version = "1.15"
features = ["macros", "rt-multi-thread"]
[dependencies.async-circe]
path = "../.."
features = ["toml_support"]

View file

@ -1,6 +1,5 @@
host = "karx.xyz"
port = 6697
username = "circe"
channels = ["#main", "#no-normies"]
username = "async-circe"
channels = ["#no-normies"]
mode = "+B"

View file

@ -1,14 +1,15 @@
use circe::{commands::Command, Client, Config};
use async_circe::{commands::Command, Client, Config};
fn main() -> Result<(), std::io::Error> {
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let config = Config::from_toml("Config.toml")?;
let mut client = Client::new(config).unwrap();
client.identify().unwrap();
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
loop {
if let Ok(ref command) = client.read() {
if let Command::OTHER(line) = command {
print!("{}", line);
if let Ok(ref command) = client.read().await {
if let Command::PRIVMSG(nick, channel, message) = command {
println!("{} in {}: {}", nick, channel, message);
}
}
}

View file

@ -0,0 +1,16 @@
[package]
authors = ["famfo", "karx"]
name = "basic-config"
version = "0.1.0"
edition = "2021"
[dependencies.tokio]
version = "1.15"
features = ["macros", "rt-multi-thread"]
[dependencies.tracing-subscriber]
version = "0.3"
features = ["env-filter"]
[dependencies.async-circe]
path = "../.."

View file

@ -0,0 +1,29 @@
use async_circe::{commands::Command, Client, Config};
#[tokio::main]
async fn main() -> Result<(), tokio::io::Error> {
// This tells tracing to show the debug log when the binary is run with
// CIRCE_LOG="debug"
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_env("CIRCE_LOG"))
.init();
let config = Config::new(
&["#no-normies"],
"karx.xyz",
Some("+B"),
Some("async-circe"),
6697,
"circe",
);
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
loop {
if let Ok(ref command) = client.read().await {
if let Command::PRIVMSG(nick, channel, message) = command {
println!("{} in {}: {}", nick, channel, message);
}
}
}
}

View file

@ -3,21 +3,116 @@
version = 3
[[package]]
name = "circe"
version = "0.1.3"
name = "async-circe"
version = "0.1.5"
dependencies = [
"serde",
"serde_derive",
"toml",
"tokio",
"tracing",
]
[[package]]
name = "bytes"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "config-from-toml"
version = "0.1.0"
dependencies = [
"circe",
"async-circe",
"tokio",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "log"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "mio"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
]
[[package]]
name = "num_cpus"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "pin-project-lite"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
[[package]]
name = "proc-macro2"
version = "1.0.32"
@ -36,23 +131,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "serde"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
[[package]]
name = "serde_derive"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "syn"
version = "1.0.81"
@ -65,12 +143,62 @@ dependencies = [
]
[[package]]
name = "toml"
version = "0.5.8"
name = "tokio"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
dependencies = [
"serde",
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"pin-project-lite",
"tokio-macros",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
[[package]]
@ -78,3 +206,25 @@ name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -4,6 +4,10 @@ name = "config-from-toml"
version = "0.1.0"
edition = "2021"
[dependencies.circe]
[dependencies.tokio]
version = "1.15"
features = ["macros", "rt-multi-thread"]
[dependencies.async-circe]
path = "../.."
default-features = false

View file

@ -1,6 +0,0 @@
host = "192.168.178.100"
port = 6667
username = "circe"
channels = ["#main", "#no-normies"]
mode = "+B"

View file

@ -1,14 +1,22 @@
use circe::{commands::Command, Client, Config};
use async_circe::{commands::Command, Client, Config};
fn main() -> Result<(), std::io::Error> {
let config = Config::from_toml("Config.toml")?;
let mut client = Client::new(config).unwrap();
client.identify().unwrap();
#[tokio::main]
async fn main() -> Result<(), tokio::io::Error> {
let config = Config::new(
&["#main", "#no-normies"],
"192.168.178.100",
Some("+B"),
Some("async-circe"),
6667,
"async-circe",
);
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
loop {
if let Ok(ref command) = client.read() {
if let Command::OTHER(line) = command {
print!("{}", line);
if let Ok(ref command) = client.read().await {
if let Command::PRIVMSG(nick, channel, message) = command {
println!("{} in {}: {}", nick, channel, message);
}
}
}

View file

@ -197,16 +197,20 @@ impl Command {
let command = parts[1].to_string();
return Self::PONG(command);
} else if parts.get(1) == Some(&"PRIVMSG") {
let nick = parts[0];
let index = {
let index = nick.chars().position(|c| c == '!');
if let Some(index) = index {
index
let nick_realname = parts[0];
let nick: String;
let index = nick_realname.chars().position(|c| c == '!');
if let Some(index) = index {
if index > 0 {
nick = String::from(&nick_realname[1..index]);
} else {
1
nick = String::new();
}
};
let nick = String::from(&nick[1..index]);
} else {
nick = String::new();
}
let target = parts[2];
let mut builder = String::new();

View file

@ -169,6 +169,7 @@ impl Client {
.await?;
}
tracing::info!("circe has identified");
Ok(())
}
@ -588,13 +589,8 @@ impl Client {
)))
.await?;
}
#[cfg(not(feature = "tls"))]
self.stream.shutdown(tokio::net::Shutdown::Both)?;
#[cfg(feature = "tls")]
tracing::info!("circe shutting down");
self.stream.shutdown().await?;
Ok(())
}
}

View file

@ -1,44 +0,0 @@
use async_circe::{commands::Command, Client, Config};
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
//let config = Config::from_toml("config.toml")?;
let config = Default::default();
/*let config = Config::new(
&["#main"],
"karx.xyz",
Some("+B"),
Some("async-circe"),
6697,
"circe",
);*/
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
client
.write_command(Command::PRIVMSG(
"".to_string(),
"#main".to_string(),
"Hello".to_string(),
))
.await?;
loop {
if let Ok(ref command) = client.read().await {
if let Command::OTHER(line) = command {
print!("{}", line);
}
if let Command::PRIVMSG(nick, channel, message) = command {
if message.contains("!quit") {
client.quit(None).await?;
break;
}
if message.contains("!close") {
client.part("#main").await?;
}
println!("PRIVMSG received from {}: {} {:#?}", nick, channel, message);
}
}
}
Ok(())
}

View file

@ -1,17 +0,0 @@
use circe::{Client, Config};
#[test]
fn connect() -> Result<(), std::io::Error> {
let config = Config::new(
vec![""],
"karx.xyz",
Some("+B"),
Some("circe-tests"),
6697,
"circe-tests",
);
let mut client = Client::new(config).unwrap();
client.identify().unwrap();
Ok(())
}