Skip to content

Commit

Permalink
Merge pull request #206 from aatxe/develop
Browse files Browse the repository at this point in the history
Release 0.14!
  • Loading branch information
aatxe authored May 8, 2020
2 parents a086e09 + 0f675e7 commit c706fc6
Show file tree
Hide file tree
Showing 28 changed files with 1,393 additions and 1,582 deletions.
61 changes: 54 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@
language: rust
rust: stable
sudo: false
script:
- cargo test --all --features "toml yaml json"
- cargo build
# No idea how to fix this, since we don't depend on futures-preview directly.
# - rustdoc --test README.md --extern irc=target/debug/libirc.rlib -L target/debug/deps --edition 2018
- cargo run --example build-bot

jobs:
allow_failures:
- stage: test
rust: beta
env: FEATURES=default
- stage: test
rust: nightly
env: FEATURES=default

include:
# Default features
- &test
rust: stable
env: FEATURES=default
script:
- cargo test --all --no-default-features --features "$FEATURES"
- cargo build --no-default-features --features "$FEATURES"
- cargo run --no-default-features --features "$FEATURES" --example build-bot

# No features
- <<: *test
env: FEATURES=

# CTCP on without toml
- <<: *test
env: FEATURES=ctcp
# CTCP on w/toml (this is the same as default)
#- <<: *test
# env: FEATURES=ctcp toml_config
# nochanlists on without toml
- <<: *test
env: FEATURES=nochanlists
# nochanlists on w/toml
- <<: *test
env: FEATURES=nochanlists toml_config
# tls-rust: disabled until testing server supports TLS 1.3
# - <<: *test
# env: FEATURES=tls-rust

# Beta
- <<: *test
rust: beta
env: FEATURES=default
# Nightly
- <<: *test
rust: nightly
env: FEATURES=default

# No idea how to fix this, since we don't depend on futures-preview directly.
# - rustdoc --test README.md --extern irc=target/debug/libirc.rlib -L target/debug/deps --edition 2018

notifications:
email: false
irc:
on_failure: always
on_success: never
channels:
- "ircs://irc.pdgn.co:6697/#commits"
template:
Expand Down
93 changes: 64 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "irc"
version = "0.13.6"
version = "0.14.0"
description = "the irc crate – usable, async IRC for Rust "
authors = ["Aaron Weiss <awe@pdgn.co>"]
license = "MPL-2.0"
Expand All @@ -11,46 +11,81 @@ repository = "https://github.com/aatxe/irc"
readme = "README.md"
edition = "2018"


[badges]
travis-ci = { repository = "aatxe/irc" }
is-it-maintained-issue-resolution = { repository = "aatxe/irc" }
is-it-maintained-open-issues = { repository = "aatxe/irc" }


[workspace]
members = [ "./", "irc-proto" ]
members = [ "./", "irc-proto/" ]


[features]
default = ["ctcp", "toml"]
default = ["ctcp", "tls-native", "toml_config"]
ctcp = []
nochanlists = []
json = ["serde_json"]
yaml = ["serde_yaml"]

json_config = ["serde", "serde/derive", "serde_derive", "serde_json"]
toml_config = ["serde", "serde/derive", "serde_derive", "toml"]
yaml_config = ["serde", "serde/derive", "serde_derive", "serde_yaml"]
# Temporary transitionary features
json = ["json_config"]
yaml = ["yaml_config"]

proxy = ["tokio-socks"]

tls-native = ["native-tls", "tokio-tls"]
tls-rust = ["tokio-rustls", "webpki-roots"]


[dependencies]
thiserror = "1.0.2"
bufstream = "0.1"
bytes = "0.4"
chrono = "0.4"
encoding = "0.2"
irc-proto = { version = "*", path = "irc-proto" }
log = "0.4"
native-tls = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
tokio = { version = "0.2.4", features = ["time", "net", "stream", "macros", "stream"] }
tokio-util = { version = "0.2.0", features = ["codec"] }
tokio-tls = "0.3.0"
serde_json = { version = "1.0", optional = true }
serde_yaml = { version = "0.7", optional = true }
toml = { version = "0.4", optional = true }
bufstream = "0.1.0"
bytes = "0.5.0"
chrono = "0.4.0"
encoding = "0.2.0"
futures-channel = "0.3.0"
futures-util = { version = "0.3.0", features = ["sink"] }
irc-proto = { version = "0.14.0", path = "irc-proto" }
log = "0.4.0"
parking_lot = "0.10.0"
pin-utils = "0.1.0-alpha.4"
parking_lot = "0.9.0"
futures-channel = "0.3.1"
futures-util = { version = "0.3.1", features = ["sink"] }
thiserror = "1.0.0"
tokio = { version = "0.2.0", features = ["macros", "net", "stream", "time"] }
tokio-util = { version = "0.3.0", features = ["codec"] }

# Feature - Config
serde = { version = "1.0.0", optional = true }
serde_derive = { version = "1.0.0", optional = true }
serde_json = { version = "1.0.0", optional = true }
serde_yaml = { version = "0.8.0", optional = true }
toml = { version = "0.5.0", optional = true }

# Feature - Proxy
tokio-socks = { version = "0.2.0", optional = true }

# Feature - TLS
native-tls = { version = "0.2.0", optional = true }
tokio-rustls = { version = "0.13.0", optional = true }
tokio-tls = { version = "0.3.0", optional = true }
webpki-roots = { version = "0.19.0", optional = true }


[dev-dependencies]
futures = "0.3.1"
anyhow = "1.0.13"
args = "2.0"
getopts = "0.2"
env_logger = "0.6.2"
anyhow = "1.0.0"
args = "2.0.0"
env_logger = "0.7.0"
futures = "0.3.0"
getopts = "0.2.0"


[[example]]
name = "simple_proxy"
path = "examples/simple_proxy.rs"
required-features = ["proxy"]

[[example]]
name = "simple_plaintext"
path = "examples/simple_plaintext.rs"
required-features = ["tls-native"]
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ programmatic configuration. Runtime loading is done via the function `Config::lo
sufficient for most IRC bots. Programmatic configuration is convenient for writing tests, but can
also be useful when defining your own custom configuration format that can be converted to `Config`.
The primary configuration format is TOML, but if you are so inclined, you can use JSON and/or YAML
via the optional `json` and `yaml` features respectively. At the minimum, a configuration requires
`nickname` and `server` to be defined, and all other fields are optional. You can find detailed
explanations of the various fields on [docs.rs][config-fields].
via the optional `json_config` and `yaml_config` features respectively. At the minimum, a configuration
requires `nickname` and `server` to be defined, and all other fields are optional. You can find
detailed explanations of the various fields on [docs.rs][config-fields].

[config-fields]: https://docs.rs/irc/*/irc/client/data/config/struct.Config.html#fields

Expand All @@ -104,7 +104,12 @@ realname = "Test User"
server = "chat.freenode.net"
port = 6697
password = ""
use_ssl = true
proxy_type = "None"
proxy_server = "127.0.0.1"
proxy_port = "1080"
proxy_username = ""
proxy_password = ""
use_tls = true
cert_path = "cert.der"
client_cert_path = "client.der"
client_cert_pass = "password"
Expand Down
10 changes: 6 additions & 4 deletions examples/build-bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ async fn main() -> irc::error::Result<()> {
let branch = env::var("TRAVIS_BRANCH").unwrap();
let commit = env::var("TRAVIS_COMMIT").unwrap();
let commit_message = env::var("TRAVIS_COMMIT_MESSAGE").unwrap();
let features = env::var("FEATURES").unwrap();

let config = Config {
nickname: Some("irc-crate-ci".to_owned()),
server: Some("irc.pdgn.co".to_owned()),
use_ssl: true,
alt_nicks: vec!["[irc-crate-ci]".to_owned()],
..Default::default()
};

Expand All @@ -27,15 +28,16 @@ async fn main() -> irc::error::Result<()> {

while let Some(message) = stream.next().await.transpose()? {
match message.command {
Command::Response(Response::RPL_ISUPPORT, _, _) => {
Command::Response(Response::RPL_ISUPPORT, _) => {
client.send_privmsg(
"#commits",
format!(
"[{}/{}] ({}) {}",
"[{}/{}] ({}) {} [{}]",
repository_slug,
branch,
&commit[..7],
commit_message
commit_message,
features,
),
)?;

Expand Down
12 changes: 5 additions & 7 deletions examples/multiserver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate irc;

use futures::prelude::*;
use irc::{client::prelude::*, error};

Expand All @@ -9,30 +7,30 @@ async fn main() -> irc::error::Result<()> {

let cfg1 = Config {
nickname: Some("pickles".to_owned()),
server: Some("irc.mozilla.org".to_owned()),
server: Some("irc.pdgn.co".to_owned()),
channels: vec!["#rust-spam".to_owned()],
..Default::default()
};

let cfg2 = Config {
nickname: Some("bananas".to_owned()),
server: Some("irc.mozilla.org".to_owned()),
server: Some("irc.pdgn.co".to_owned()),
channels: vec!["#rust-spam".to_owned()],
..Default::default()
};

let configs = vec![cfg1, cfg2];
let mut senders = Vec::new();
let mut streams = Vec::new();
let mut senders = Vec::new();

for config in configs {
// Immediate errors like failure to resolve the server's domain or to establish any connection will
// manifest here in the result of prepare_client_and_connect.
let mut client = Client::from_config(config).await?;
client.identify()?;

senders.push(client.sender());
streams.push(client.stream()?);
senders.push(client.sender());
}

loop {
Expand All @@ -45,7 +43,7 @@ async fn main() -> irc::error::Result<()> {
}

fn process_msg(sender: &Sender, message: Message) -> error::Result<()> {
// print!("{}", message);
print!("{}", message);

match message.command {
Command::PRIVMSG(ref target, ref msg) => {
Expand Down
9 changes: 4 additions & 5 deletions examples/repeater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use irc::client::prelude::*;
#[tokio::main]
async fn main() -> irc::error::Result<()> {
let config = Config {
nickname: Some("repeater".to_owned()),
alt_nicks: vec!["blaster".to_owned(), "smg".to_owned()],
server: Some("irc.mozilla.org".to_owned()),
use_ssl: true,
nickname: Some("pickles".to_owned()),
server: Some("irc.pdgn.co".to_owned()),
channels: vec!["#rust-spam".to_owned()],
burst_window_length: Some(4),
max_messages_in_burst: Some(4),
Expand All @@ -18,6 +16,7 @@ async fn main() -> irc::error::Result<()> {
client.identify()?;

let mut stream = client.stream()?;
let sender = client.sender();

loop {
let message = stream.select_next_some().await?;
Expand All @@ -29,7 +28,7 @@ async fn main() -> irc::error::Result<()> {
let n = tokens[0].len() + tokens[1].len() + 2;
if let Ok(count) = tokens[1].parse::<u8>() {
for _ in 0..count {
client.send_privmsg(
sender.send_privmsg(
message.response_target().unwrap_or(target),
&msg[n..],
)?;
Expand Down
19 changes: 12 additions & 7 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use irc::client::prelude::*;
async fn main() -> irc::error::Result<()> {
let config = Config {
nickname: Some("pickles".to_owned()),
alt_nicks: vec!["bananas".to_owned(), "apples".to_owned()],
server: Some("irc.mozilla.org".to_owned()),
server: Some("irc.pdgn.co".to_owned()),
channels: vec!["#rust-spam".to_owned()],
..Default::default()
};
Expand All @@ -15,14 +14,20 @@ async fn main() -> irc::error::Result<()> {
client.identify()?;

let mut stream = client.stream()?;
let sender = client.sender();

loop {
let message = stream.select_next_some().await?;
while let Some(message) = stream.next().await.transpose()? {
print!("{}", message);

if let Command::PRIVMSG(ref target, ref msg) = message.command {
if msg.contains("pickles") {
client.send_privmsg(target, "Hi!").unwrap();
match message.command {
Command::PRIVMSG(ref target, ref msg) => {
if msg.contains(client.current_nickname()) {
sender.send_privmsg(target, "Hi!")?;
}
}
_ => (),
}
}

Ok(())
}
Loading

0 comments on commit c706fc6

Please sign in to comment.