From 5c45046794e3c93f875d69193bb12d6608d45a8c Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 7 Apr 2018 18:19:24 +0200 Subject: Add usefulness rating function to url titles --- src/plugins/emoji.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/emoji.rs') diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index f1d9376..4ec7265 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -6,8 +6,8 @@ use irc::client::prelude::*; use plugin::*; -use error::FrippyError; use error::ErrorKind as FrippyErrorKind; +use error::FrippyError; use failure::Fail; use failure::ResultExt; -- cgit v1.2.3-70-g09d2 From 87120d35c1e2ee7eff52e9fd2d0a8458206a4cb6 Mon Sep 17 00:00:00 2001 From: Jokler Date: Wed, 25 Apr 2018 17:46:33 +0200 Subject: Emoji: Do not send empty messages --- src/plugins/emoji.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/plugins/emoji.rs') diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index 4ec7265..b50b782 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -39,12 +39,17 @@ impl Emoji { Emoji {} } - fn emoji(&self, content: &str) -> String { - self.return_emojis(content) - .iter() - .map(|e| e.to_string()) - .collect::>() - .join(", ") + fn emoji(&self, content: &str) -> Option { + let emojis = self.return_emojis(content); + if emojis.is_empty() { + None + } else { + Some(emojis + .iter() + .map(|e| e.to_string()) + .collect::>() + .join(", ")) + } } fn return_emojis(&self, string: &str) -> Vec { @@ -100,11 +105,17 @@ impl Emoji { impl Plugin for Emoji { fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus { match message.command { - Command::PRIVMSG(_, ref content) => match client - .send_privmsg(message.response_target().unwrap(), &self.emoji(content)) - { - Ok(_) => ExecutionStatus::Done, - Err(e) => ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()), + Command::PRIVMSG(_, ref content) => { + if let Some(emojis) = self.emoji(content) { + match client + .send_privmsg(message.response_target().unwrap(), &emojis) + { + Ok(_) => ExecutionStatus::Done, + Err(e) => ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()), + } + } else { + ExecutionStatus::Done + } }, _ => ExecutionStatus::Done, } @@ -124,8 +135,7 @@ impl Plugin for Emoji { } fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result { - let emojis = self.emoji(&command.tokens[0]); - if emojis.is_empty() { + if let Some(emojis) = self.emoji(&command.tokens[0]) { Ok(emojis) } else { Err(String::from("No emojis were found.")) -- cgit v1.2.3-70-g09d2 From a6caefb849967324c07cb6d4a3d312a5b18f0fef Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 12 May 2018 16:30:23 +0200 Subject: Emoji: Add default to EmojiHandle --- src/plugins/emoji.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/plugins/emoji.rs') diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index b50b782..a2337ee 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -11,6 +11,7 @@ use error::FrippyError; use failure::Fail; use failure::ResultExt; +#[derive(Default, Debug)] struct EmojiHandle { symbol: char, count: i32, @@ -44,21 +45,20 @@ impl Emoji { if emojis.is_empty() { None } else { - Some(emojis - .iter() - .map(|e| e.to_string()) - .collect::>() - .join(", ")) + Some( + emojis + .iter() + .map(|e| e.to_string()) + .collect::>() + .join(", "), + ) } } fn return_emojis(&self, string: &str) -> Vec { let mut emojis: Vec = Vec::new(); - let mut current = EmojiHandle { - symbol: ' ', - count: 0, - }; + let mut current = EmojiHandle::default(); for c in string.chars() { if !self.is_emoji(&c) { @@ -107,16 +107,16 @@ impl Plugin for Emoji { match message.command { Command::PRIVMSG(_, ref content) => { if let Some(emojis) = self.emoji(content) { - match client - .send_privmsg(message.response_target().unwrap(), &emojis) - { - Ok(_) => ExecutionStatus::Done, - Err(e) => ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()), + match client.send_privmsg(message.response_target().unwrap(), &emojis) { + Ok(_) => ExecutionStatus::Done, + Err(e) => { + ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()) } + } } else { ExecutionStatus::Done } - }, + } _ => ExecutionStatus::Done, } } -- cgit v1.2.3-70-g09d2 From 9baade2a5d9fec54fe4d88216fbdb91c154ad348 Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 16 Jun 2018 15:35:49 +0200 Subject: Fix clippy warnings --- Cargo.lock | 538 +++++++++++++++++++++------------------ Cargo.toml | 20 +- src/error.rs | 2 +- src/lib.rs | 8 +- src/main.rs | 6 +- src/plugin.rs | 2 +- src/plugins/currency.rs | 24 +- src/plugins/emoji.rs | 6 +- src/plugins/factoids/database.rs | 2 +- src/plugins/factoids/mod.rs | 41 +-- src/plugins/factoids/utils.rs | 2 +- src/plugins/help.rs | 6 +- src/plugins/keepnick.rs | 6 +- src/plugins/remind/database.rs | 14 +- src/plugins/remind/mod.rs | 21 +- src/plugins/remind/parser.rs | 50 ++-- src/plugins/sed.rs | 10 +- src/plugins/tell/database.rs | 2 +- src/plugins/tell/mod.rs | 40 +-- src/plugins/url.rs | 31 ++- src/utils.rs | 5 +- 21 files changed, 448 insertions(+), 388 deletions(-) (limited to 'src/plugins/emoji.rs') diff --git a/Cargo.lock b/Cargo.lock index 902eb79..4b06dd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -34,28 +34,28 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.16" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "base64" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -89,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bytes" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,19 +98,19 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -120,7 +120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -135,11 +135,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clippy" -version = "0.0.200" +version = "0.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy_lints 0.0.200 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy_lints 0.0.207 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -147,20 +147,20 @@ dependencies = [ [[package]] name = "clippy_lints" -version = "0.0.200" +version = "0.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -172,7 +172,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -180,7 +180,7 @@ name = "core-foundation-sys" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -201,19 +201,19 @@ name = "crossbeam-deque" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -237,41 +237,41 @@ dependencies = [ [[package]] name = "diesel" -version = "1.2.2" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel_derives 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "mysqlclient-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "diesel_derives" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "diesel_infer_schema" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "infer_schema_macros 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "infer_schema_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "diesel_migrations" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "migrations_internals 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "migrations_macros 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "migrations_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "migrations_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -369,7 +369,7 @@ name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -377,7 +377,7 @@ name = "failure" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -396,7 +396,7 @@ name = "flate2" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -423,28 +423,28 @@ name = "frippy" version = "0.4.0" dependencies = [ "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "circular-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.200 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel_infer_schema 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel_migrations 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.207 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel_infer_schema 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel_migrations 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "frippy_derive 0.1.0", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "irc 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log4rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "r2d2-diesel 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "rlua 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "unicode_names 0.1.7 (git+https://github.com/Jokler/unicode_names?branch=update-to-latest-unicode)", ] @@ -516,32 +516,33 @@ name = "humantime" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hyper" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "base64 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "want 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -550,10 +551,10 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.26 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -575,19 +576,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "infer_schema_internals" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "diesel 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "infer_schema_macros" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "infer_schema_internals 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "infer_schema_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -597,7 +598,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -607,17 +608,17 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-mockstream 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -632,11 +633,6 @@ dependencies = [ "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itoa" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "itoa" version = "0.4.1" @@ -663,7 +659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -673,12 +669,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.40" +version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libflate" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -696,16 +692,16 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -719,21 +715,21 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde-value 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -746,7 +742,7 @@ name = "memchr" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -756,18 +752,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "migrations_internals" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "diesel 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "migrations_macros" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "migrations_internals 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "migrations_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -796,8 +792,8 @@ name = "miniz-sys" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -810,8 +806,8 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -835,7 +831,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -844,7 +840,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -858,8 +854,8 @@ version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -893,7 +889,7 @@ name = "num_cpus" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -903,20 +899,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.30 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl-sys" -version = "0.9.30" +version = "0.9.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -989,6 +985,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pulldown-cmark" version = "0.1.2" @@ -1000,7 +1004,7 @@ dependencies = [ [[package]] name = "quick-error" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1029,13 +1033,21 @@ dependencies = [ "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "r2d2" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "scheduled-thread-pool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1044,7 +1056,7 @@ name = "r2d2-diesel" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "diesel 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1054,7 +1066,7 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1064,13 +1076,13 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1092,7 +1104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1107,7 +1119,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1126,31 +1138,31 @@ name = "remove_dir_all" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "reqwest" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.26 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libflate 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libflate 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1160,7 +1172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1186,8 +1198,8 @@ name = "schannel" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1215,7 +1227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1225,7 +1237,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1234,7 +1246,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1244,7 +1256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.55" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1253,48 +1265,48 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.55" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.13.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_urlencoded" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_yaml" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1340,7 +1352,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.13.10" +version = "0.13.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1348,6 +1360,16 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synom" version = "0.11.3" @@ -1384,7 +1406,7 @@ name = "thread_local" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1393,26 +1415,36 @@ name = "time" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-fs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-fs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-udp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1420,17 +1452,17 @@ name = "tokio-core" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1443,22 +1475,22 @@ dependencies = [ [[package]] name = "tokio-fs" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-io" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1467,7 +1499,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1483,21 +1515,21 @@ dependencies = [ "smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-reactor" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1513,22 +1545,22 @@ name = "tokio-tcp" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-threadpool" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1545,7 +1577,7 @@ dependencies = [ [[package]] name = "tokio-timer" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1560,20 +1592,21 @@ dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-udp" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1581,7 +1614,7 @@ name = "toml" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1589,6 +1622,11 @@ name = "traitobject" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "try-lock" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "typemap" version = "0.3.3" @@ -1687,15 +1725,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uuid" -version = "0.5.1" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "vcpkg" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1708,6 +1747,16 @@ name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "want" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi" version = "0.2.8" @@ -1715,7 +1764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1760,34 +1809,34 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum backtrace 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea58cd16fd6c9d120b5bcb01d63883ae4cc7ba2aed35c1841b862a3c7ef6639" -"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" -"checksum base64 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9263aa6a38da271eec5c91a83ce1e800f093c8535788d403d626d8d5c3f8f007" +"checksum backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdd17cd962b570302f5297aea8648d5923e22e555c2ed2d8b2e34eca646bf6d" +"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" +"checksum base64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "85415d2594767338a74a30c1d370b2f3262ec1b4ed2d7bba5b3faf4de40467d9" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" -"checksum bytes 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2f1d50c876fb7545f5f289cd8b2aee3f359d073ae819eed5d6373638e2c61e59" -"checksum cargo_metadata 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebd6272a2ca4fd39dbabbd6611eb03df45c2259b3b80b39a9ff8fbdcf42a4b3" -"checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba" +"checksum bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dd32989a66957d3f0cba6588f15d4281a733f4e9ffc43fcd2385f57d3bf99ff" +"checksum cargo_metadata 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "682476b87b3e22cd3820d86b26cd8603cd84ab76dce7547b2631858347aa8967" +"checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d" "checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" -"checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6" +"checksum chrono 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a81892f0d5a53f46fc05ef0b917305a81c13f1f13bb59ac91ff595817f0764b1" "checksum circular-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be63960d0419728d75f18d0132e5da310d2db6ef31db808a733a8566afe5545" -"checksum clippy 0.0.200 (registry+https://github.com/rust-lang/crates.io-index)" = "927a1f79af10deb103df108347f23c6b7fa1731c953d6fb24d68be1748a0993f" -"checksum clippy_lints 0.0.200 (registry+https://github.com/rust-lang/crates.io-index)" = "d2432663f6bdb90255dcf9df5ca504f99b575bb471281591138f62f9d31f863b" +"checksum clippy 0.0.207 (registry+https://github.com/rust-lang/crates.io-index)" = "cc42a49b89319724199ff4fec0766a12764293a37cec12dd42c4a4b2d725666c" +"checksum clippy_lints 0.0.207 (registry+https://github.com/rust-lang/crates.io-index)" = "722c160a3f49291c83aee07397a5eeea143f806ac2407f53780da1268d5154d3" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum crossbeam-deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8153ef04a7594ded05b427ffad46ddeaf22e63fd48d42b3e1e3bb4db07cae7" -"checksum crossbeam-epoch 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b4e2817eb773f770dcb294127c011e22771899c21d18fce7dd739c0b9832e81" +"checksum crossbeam-epoch 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2af0e75710d6181e234c8ecc79f14a97907850a541b13b0be1dd10992f2e4620" "checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b" "checksum derive-error-chain 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c9ca9ade651388daad7c993f005d0d20c4f6fe78c1cdc93e95f161c6f5ede4a" -"checksum diesel 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24815a0c2094f2c8dafe74ab3b9e975892f44acbb94b4d4b4898025a7615efa4" -"checksum diesel_derives 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6471a2b637b414d3ee1504cf230409a550381c79204282f8fe06c527e4ae56be" -"checksum diesel_infer_schema 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ca3b65de2209668e7de12cb0b771e39bd37fbd652aa560d9843b730dbc17bd9" -"checksum diesel_migrations 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "992026fb46e684eaede3d9d05737de34bdcdcb7f97b389b3c0fa7999389d504e" +"checksum diesel 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e71e7a348ae6064e86c4cf0709f0e4c3ef6f30e8e7d3dc05737164af4ebd3511" +"checksum diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03bcaf77491f53e400d5ee3bdd57142ea4e1c47fe9217b3361ff9a76ca0e3d37" +"checksum diesel_infer_schema 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8a1dd088bb77bc1cdc144c3085068a61c4d9bd0780b77b2c1eb102c6aad986c" +"checksum diesel_migrations 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b42c35d1ce9e8d57a3e7001b4127f2bc1b073a89708bb7019f5be27c991c28" "checksum dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d6f0e2bb24d163428d8031d3ebd2d2bd903ad933205a97d0f18c7c1aade380f3" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" @@ -1817,34 +1866,33 @@ dependencies = [ "checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" "checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" -"checksum hyper 0.11.26 (registry+https://github.com/rust-lang/crates.io-index)" = "66b16eb6213713f3c72d0ed14ce56423ae84dced8df73d2a2c8675f0495ae7ea" +"checksum hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)" = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" "checksum hyper-tls 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a5aa51f6ae9842239b0fac14af5f22123b8432b4cc774a44ff059fcba0f675ca" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" -"checksum infer_schema_internals 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e29654a5ade7e34a51637f40b45fa128c7fd62b0d4c3e2a19efca7caf7d9abf6" -"checksum infer_schema_macros 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf0bd7c4960bcef19d34ff32de05c84c914a5eebcb80b9329dd55de764cda4fe" +"checksum infer_schema_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e0f1e381ff29feef92a7a4037d4d564007a43daca9aa79c578d99538e2a6623" +"checksum infer_schema_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2394a0407ac25980f6259e56f947e02748dbef3ecd44cf46f0a4f60bd369b599" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum irc 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a30eb0fe918d4aa89c28e19240dd0935ec2c1a667036dc3d41f0ee3ccc599288" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" -"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" -"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" +"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" -"checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" -"checksum libflate 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "1a429b86418868c7ea91ee50e9170683f47fd9d94f5375438ec86ec3adb74e8e" +"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" +"checksum libflate 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f70a41040e4ed915b462ffb9c8dd20ece3700565aa5e2e163288a0f7ca00487a" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" +"checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" "checksum log-mdc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" "checksum log4rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1f16090a553200fba94e104310b3e53e71f500fd9db7dc2143055aa3cc7ae63" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum migrations_internals 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54b8f3128f95b1e5b5f5d5d7ce2156b306b9d11dd50e23b594f25247e30ca83a" -"checksum migrations_macros 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a616c2538e1f09bf402efae6feb73c2711bb137c794b797f3fb8b3df84275d4b" +"checksum migrations_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cf7c8c4f83fa9f47440c0b4af99973502de55e6e7b875f693bd263e03f93e7e" +"checksum migrations_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "79f12499ef7353bdeca2d081bc61edd8351dac09a33af845952009b5a3d68c1a" "checksum mime 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b28683d0b09bbc20be1c9b3f6f24854efb1356ffcffee08ea3f6e65596e85fa" "checksum mime_guess 2.0.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130ea3c9c1b65dba905ab5a4d9ac59234a9585c24d135f264e187fe7336febbd" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" @@ -1859,7 +1907,7 @@ dependencies = [ "checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" -"checksum openssl-sys 0.9.30 (registry+https://github.com/rust-lang/crates.io-index)" = "73ae718c3562989cd3a0a5c26610feca02f8116822f6f195e6cf4887481e57f5" +"checksum openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)" = "d8abc04833dcedef24221a91852931df2f63e3369ae003134e70aff3645775cc" "checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum phf 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7d37a244c75a9748e049225155f56dbcb98fe71b192fd25fd23cb914b5ad62f2" @@ -1869,24 +1917,26 @@ dependencies = [ "checksum pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "110d5ee3593dbb73f56294327fe5668bcc997897097cbc76b51e7aed3f52452f" "checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" +"checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6" "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" -"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" "checksum r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f9078ca6a8a5568ed142083bb2f7dc9295b69d16f867ddcc9849e51b17d8db46" "checksum r2d2-diesel 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9c29bad92da76d02bc2c020452ebc3a3fe6fa74cfab91e711c43116e4fb1a3" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" +"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b" +"checksum regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05b06a75f5217880fc5e905952a42750bf44787e56a6c6d6852ed0992f5e1d54" "checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "241faa9a8ca28a03cbbb9815a5d085f271d4c0168a19181f106aa93240c22ddb" +"checksum reqwest 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2abe46f8e00792693a2488e296c593d1f4ea39bb1178cfce081d6793657575e4" "checksum rlua 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f4876476bf0ac0bb596c60153c5ba11ddfc5738df991baa9ec35b303dffb1ff" "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" @@ -1899,42 +1949,45 @@ dependencies = [ "checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)" = "97f6a6c3caba0cf8f883b53331791036404ce3c1bd895961cf8bb2f8cecfd84b" +"checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" "checksum serde-value 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "52903ade2290cbd61a0937a66a268f26cebf246e3ddd7964a8babb297111fb0d" -"checksum serde_derive 1.0.55 (registry+https://github.com/rust-lang/crates.io-index)" = "f51b0ef935cf8a41a77bce553da1f8751a739b7ad82dd73669475a22e6ecedb0" -"checksum serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f3ad6d546e765177cf3dded3c2e424a8040f870083a0e64064746b958ece9cb1" -"checksum serde_urlencoded 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce0fd303af908732989354c6f02e05e2e6d597152870f2c6990efb0577137480" -"checksum serde_yaml 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "107bb818146aaf922e7bbcf6a940f1db2f0dcf381779b451e400331b2c6f86db" +"checksum serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "0a90213fa7e0f5eac3f7afe2d5ff6b088af515052cc7303bd68c7e3b91a3fb79" +"checksum serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "fc97cccc2959f39984524026d760c08ef0dd5f0f5948c8d31797dbfae458c875" +"checksum serde_urlencoded 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e703cef904312097cfceab9ce131ff6bbe09e8c964a0703345a5f49238757bc1" +"checksum serde_yaml 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8099d3df28273c99a1728190c7a9f19d444c941044f64adf986bee7ec53051" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c97c05b8ebc34ddd6b967994d5c6e9852fa92f8b82b3858c39451f97346dcce5" -"checksum syn 0.13.10 (registry+https://github.com/rust-lang/crates.io-index)" = "77961dcdac942fa8bc033c16f3a790b311c8a27d00811b878ebd8cf9b7ba39d5" +"checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" +"checksum syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c67da57e61ebc7b7b6fff56bb34440ca3a83db037320b0507af4c10368deda7d" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" -"checksum tokio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d00555353b013e170ed8bc4e13f648a317d1fd12157dbcae13f7013f6cf29f5" +"checksum tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ee337e5f4e501fc32966fec6fe0ca0cc1c237b0b1b14a335f8bfe3c5f06e286" +"checksum tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "881e9645b81c2ce95fcb799ded2c29ffb9f25ef5bef909089a420e5961dd8ccb" "checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" "checksum tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cac2a7883ff3567e9d66bb09100d09b33d90311feca0206c7ca034bc0c55113" -"checksum tokio-fs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76766830bbf9a2d5bfb50c95350d56a2e79e2c80f675967fff448bc615899708" -"checksum tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af9eb326f64b2d6b68438e1953341e00ab3cf54de7e35d92bfc73af8555313a" +"checksum tokio-fs 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc42bae2f6e33865b99069d95bcddfc85c9f0849b4e7e7399eeee71956ef34d7" +"checksum tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a5c9635ee806f26d302b8baa1e145689a280d8f5aa8d0552e7344808da54cc21" "checksum tokio-mockstream 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41bfc436ef8b7f60c19adf3df086330ae9992385e4d8c53b17a323cad288e155" "checksum tokio-proto 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389" -"checksum tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3cedc8e5af5131dc3423ffa4f877cce78ad25259a9a62de0613735a13ebc64b" +"checksum tokio-reactor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e00ec63bbec2c97ce1178cb0587b2c438b2f6b09d3ee54a33c45a9cf0d530810" "checksum tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" "checksum tokio-tcp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec9b094851aadd2caf83ba3ad8e8c4ce65a42104f7b94d9e6550023f0407853f" -"checksum tokio-threadpool 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5783254b10c7c84a56f62c74766ef7e5b83d1f13053218c7cab8d3f2c826fa0e" +"checksum tokio-threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c3873a6d8d0b636e024e77b9a82eaab6739578a06189ecd0e731c7308fbc5d" "checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" -"checksum tokio-timer 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535fed0ccee189f3d48447587697ba3fd234b3dbbb091f0ec4613ddfec0a7c4c" +"checksum tokio-timer 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "028b94314065b90f026a21826cffd62a4e40a92cda3e5c069cc7b02e5945f5e9" "checksum tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913" -"checksum tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "137bda266504893ac4774e0ec4c2108f7ccdbcb7ac8dced6305fe9e4e0b5041a" +"checksum tokio-udp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43eb534af6e8f37d43ab1b612660df14755c42bd003c5f8d2475ee78cc4600c0" "checksum toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a0263c6c02c4db6c8f7681f9fd35e90de799ebd4cfdeab77a38f4ff6b3d8c0d9" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" +"checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" @@ -1949,12 +2002,13 @@ dependencies = [ "checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22" -"checksum vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ed0f6789c8a85ca41bbc1c9d175422116a9869bd1cf31bb08e1493ecce60380" +"checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" +"checksum vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cbe533e138811704c0e3cbde65a818b35d3240409b4346256c5ede403e082474" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum want 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index feab256..830c547 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,16 +24,16 @@ mysql = [ [dependencies] irc = "0.13.5" -log = "0.4.1" +log = "0.4.2" time = "0.1.40" humantime = "1.1.1" rlua = "0.13.0" -reqwest = "0.8.5" +reqwest = "0.8.6" regex = "1.0.0" -lazy_static = "1.0.0" -serde = "1.0.55" -serde_json = "1.0.17" -chrono = "0.4.2" +lazy_static = "1.0.1" +serde = "1.0.66" +serde_json = "1.0.20" +chrono = "0.4.3" glob = "0.2.11" circular-queue = "0.2.0" failure = "0.1.1" @@ -49,17 +49,17 @@ branch = 'update-to-latest-unicode' [dependencies.diesel] -version = "1.2.2" +version = "1.3.2" optional = true features = ["mysql", "chrono"] [dependencies.diesel_infer_schema] -version = "1.2.0" +version = "1.3.0" optional = true features = ["mysql"] [dependencies.diesel_migrations] -version = "1.2.0" +version = "1.3.0" optional = true features = ["mysql"] @@ -72,5 +72,5 @@ version = "1.0.0" optional = true [dependencies.clippy] -version = "0.0.200" +version = "*" optional = true diff --git a/src/error.rs b/src/error.rs index dc34eb7..251e812 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use failure::Fail; -pub fn log_error(e: FrippyError) { +pub fn log_error(e: &FrippyError) { let text = e.causes() .skip(1) .fold(format!("{}", e), |acc, err| format!("{}: {}", acc, err)); diff --git a/src/lib.rs b/src/lib.rs index 0e14e42..8655161 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -239,7 +239,7 @@ impl ThreadedPlugins { // Send the message to the plugin if the plugin needs it match plugin.execute(client, &message) { ExecutionStatus::Done => (), - ExecutionStatus::Err(e) => log_error(e), + ExecutionStatus::Err(e) => log_error(&e), ExecutionStatus::RequiresThread => { debug!( "Spawning thread to execute {} with {}", @@ -257,14 +257,14 @@ impl ThreadedPlugins { .name(name) .spawn(move || { if let Err(e) = plugin.execute_threaded(&client, &message) { - log_error(e); + log_error(&e); } else { debug!("{} sent response from thread", plugin.name()); } }) .context(ErrorKind::ThreadSpawn) { - log_error(e.into()); + log_error(&e.into()); } } } @@ -290,7 +290,7 @@ impl ThreadedPlugins { .name(name) .spawn(move || { if let Err(e) = plugin.command(&client, command) { - log_error(e); + log_error(&e); }; }) .context(ErrorKind::ThreadSpawn)?; diff --git a/src/main.rs b/src/main.rs index 61cc839..a21ff39 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,7 +102,7 @@ fn run() -> Result<(), Error> { mysql_url = options.get("mysql_url"); } - let prefix = prefix.map(|&ref s| s.clone()).unwrap_or(String::from(".")); + let prefix = prefix.cloned().unwrap_or_else(|| String::from(".")); let mut bot = frippy::Bot::new(&prefix); bot.add_plugin(Help::new()); @@ -166,5 +166,7 @@ fn run() -> Result<(), Error> { } // Run the bots until they throw an error - an error could be loss of connection - Ok(reactor.run()?) + reactor.run()?; + + Ok(()) } diff --git a/src/plugin.rs b/src/plugin.rs index 653ec02..5538313 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -82,7 +82,7 @@ impl PluginCommand { Some(PluginCommand { source: message.source_nickname().unwrap().to_string(), target: message.response_target().unwrap().to_string(), - tokens: tokens, + tokens, }) } else { None diff --git a/src/plugins/currency.rs b/src/plugins/currency.rs index 091c238..5790c70 100644 --- a/src/plugins/currency.rs +++ b/src/plugins/currency.rs @@ -7,8 +7,8 @@ use std::num::ParseFloatError; use irc::client::prelude::*; -use self::reqwest::Client; use self::reqwest::header::Connection; +use self::reqwest::Client; use self::serde_json::Value; use plugin::*; @@ -88,7 +88,7 @@ impl Currency { "{} {} => {:.4} {}", request.value, request.source.to_lowercase(), - response / 1.00000000, + response, request.target.to_lowercase() ); @@ -125,24 +125,28 @@ impl Plugin for Currency { fn command(&self, client: &IrcClient, mut command: PluginCommand) -> Result<(), FrippyError> { if command.tokens.is_empty() { - return Ok(client + client .send_notice(&command.source, &self.invalid_command()) - .context(FrippyErrorKind::Connection)?); + .context(FrippyErrorKind::Connection)?; + + return Ok(()); } match command.tokens[0].as_ref() { - "help" => Ok(client + "help" => client .send_notice(&command.source, self.help()) - .context(FrippyErrorKind::Connection)?), + .context(FrippyErrorKind::Connection)?, _ => match self.convert(&mut command) { - Ok(msg) => Ok(client + Ok(msg) => client .send_privmsg(&command.target, &msg) - .context(FrippyErrorKind::Connection)?), - Err(msg) => Ok(client + .context(FrippyErrorKind::Connection)?, + Err(msg) => client .send_notice(&command.source, &msg) - .context(FrippyErrorKind::Connection)?), + .context(FrippyErrorKind::Connection)?, }, } + + Ok(()) } fn evaluate(&self, _: &IrcClient, mut command: PluginCommand) -> Result { diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index a2337ee..e4dffdb 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -126,12 +126,14 @@ impl Plugin for Emoji { } fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client + client .send_notice( &command.source, "This Plugin does not implement any commands.", ) - .context(FrippyErrorKind::Connection)?) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result { diff --git a/src/plugins/factoids/database.rs b/src/plugins/factoids/database.rs index 6cd979e..ec8ed3e 100644 --- a/src/plugins/factoids/database.rs +++ b/src/plugins/factoids/database.rs @@ -45,7 +45,7 @@ pub trait Database: Send + Sync { } // HashMap -impl Database for HashMap<(String, i32), Factoid> { +impl Database for HashMap<(String, i32), Factoid, S> { fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidsError> { let factoid = Factoid { name: factoid.name.to_owned(), diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs index e3b28fc..eb9c10d 100644 --- a/src/plugins/factoids/mod.rs +++ b/src/plugins/factoids/mod.rs @@ -51,10 +51,10 @@ impl Factoids { let tm = time::now().to_timespec(); let factoid = database::NewFactoid { - name: name, + name, idx: count, - content: content, - author: author, + content, + author, created: NaiveDateTime::from_timestamp(tm.sec, 0u32), }; @@ -91,7 +91,7 @@ impl Factoids { } fn remove(&self, command: &mut PluginCommand) -> Result<&str, FactoidsError> { - if command.tokens.len() < 1 { + if command.tokens.is_empty() { Err(ErrorKind::InvalidCommand)?; } @@ -165,7 +165,7 @@ impl Factoids { } fn exec(&self, mut command: PluginCommand) -> Result { - if command.tokens.len() < 1 { + if command.tokens.is_empty() { Err(ErrorKind::InvalidIndex)? } else { let name = command.tokens.remove(0); @@ -251,24 +251,25 @@ impl Plugin for Factoids { tokens: t, }; - Ok(match self.exec(c) { - Ok(f) => client + if let Ok(f) = self.exec(c) { + client .send_privmsg(&message.response_target().unwrap(), &f) - .context(FrippyErrorKind::Connection)?, - Err(_) => (), - }) - } else { - Ok(()) + .context(FrippyErrorKind::Connection)?; + } } + + Ok(()) } fn command(&self, client: &IrcClient, mut command: PluginCommand) -> Result<(), FrippyError> { use self::FactoidResponse::{Private, Public}; if command.tokens.is_empty() { - return Ok(client + client .send_notice(&command.source, "Invalid command") - .context(FrippyErrorKind::Connection)?); + .context(FrippyErrorKind::Connection)?; + + return Ok(()); } let target = command.target.clone(); @@ -280,14 +281,14 @@ impl Plugin for Factoids { "fromurl" => self.add_from_url(&mut command) .map(|s| Private(s.to_owned())), "remove" => self.remove(&mut command).map(|s| Private(s.to_owned())), - "get" => self.get(&command).map(|s| Public(s)), - "info" => self.info(&command).map(|s| Public(s)), - "exec" => self.exec(command).map(|s| Public(s)), + "get" => self.get(&command).map(Public), + "info" => self.info(&command).map(Public), + "exec" => self.exec(command).map(Public), "help" => Ok(Private(self.help().to_owned())), _ => Err(ErrorKind::InvalidCommand.into()), }; - Ok(match result { + match result { Ok(v) => match v { Public(m) => client .send_privmsg(&target, &m) @@ -303,7 +304,9 @@ impl Plugin for Factoids { .context(FrippyErrorKind::Connection)?; Err(e).context(FrippyErrorKind::Factoids)? } - }) + } + + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/factoids/utils.rs b/src/plugins/factoids/utils.rs index 89f5d6c..48ec385 100644 --- a/src/plugins/factoids/utils.rs +++ b/src/plugins/factoids/utils.rs @@ -5,8 +5,8 @@ use std::time::Duration; use super::rlua::Error as LuaError; use super::rlua::Lua; -use utils::Url; use utils::error::ErrorKind::Connection; +use utils::Url; use failure::Fail; diff --git a/src/plugins/help.rs b/src/plugins/help.rs index b75086f..f048a8e 100644 --- a/src/plugins/help.rs +++ b/src/plugins/help.rs @@ -25,14 +25,16 @@ impl Plugin for Help { } fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client + client .send_notice( &command.source, "Available commands: help, currency, tell, factoids, remind\r\n\ For more detailed help call help on the specific command.\r\n\ Example: 'currency help'", ) - .context(FrippyErrorKind::Connection)?) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/keepnick.rs b/src/plugins/keepnick.rs index aa2e485..a728c63 100644 --- a/src/plugins/keepnick.rs +++ b/src/plugins/keepnick.rs @@ -56,12 +56,14 @@ impl Plugin for KeepNick { } fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client + client .send_notice( &command.source, "This Plugin does not implement any commands.", ) - .context(FrippyErrorKind::Connection)?) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/remind/database.rs b/src/plugins/remind/database.rs index e434ec0..97d93e8 100644 --- a/src/plugins/remind/database.rs +++ b/src/plugins/remind/database.rs @@ -1,5 +1,5 @@ -use std::collections::HashMap; use std::collections::hash_map::Entry; +use std::collections::HashMap; use std::fmt; #[cfg(feature = "mysql")] @@ -66,7 +66,7 @@ pub trait Database: Send + Sync { } // HashMap -impl Database for HashMap { +impl Database for HashMap { fn insert_event(&mut self, event: &NewEvent) -> Result { let mut id = 0; while self.contains_key(&id) { @@ -74,11 +74,11 @@ impl Database for HashMap { } let event = Event { - id: id, + id, receiver: event.receiver.to_owned(), content: event.content.to_owned(), author: event.author.to_owned(), - time: event.time.clone(), + time: *event.time, repeat: event.repeat, }; @@ -103,7 +103,7 @@ impl Database for HashMap { let mut events = Vec::new(); for (_, event) in self.iter() { - if &event.time < time { + if event.time < *time { events.push(event.clone()) } } @@ -132,9 +132,7 @@ impl Database for HashMap { } fn get_event(&self, id: i64) -> Result { - Ok(self.get(&id) - .map(|ev| ev.clone()) - .ok_or(ErrorKind::NotFound)?) + Ok(self.get(&id).cloned().ok_or(ErrorKind::NotFound)?) } fn delete_event(&mut self, id: i64) -> Result<(), RemindError> { diff --git a/src/plugins/remind/mod.rs b/src/plugins/remind/mod.rs index fada1fb..fa7cf70 100644 --- a/src/plugins/remind/mod.rs +++ b/src/plugins/remind/mod.rs @@ -98,7 +98,7 @@ impl Remind { let events = Arc::new(RwLock::new(db)); Remind { - events: events, + events, has_reminder: RwLock::new(false), } } @@ -106,17 +106,17 @@ impl Remind { fn user_cmd(&self, command: PluginCommand) -> Result { let parser = CommandParser::parse_target(command.tokens)?; - self.set(parser, &command.source) + self.set(&parser, &command.source) } fn me_cmd(&self, command: PluginCommand) -> Result { let source = command.source.clone(); let parser = CommandParser::with_target(command.tokens, command.source)?; - self.set(parser, &source) + self.set(&parser, &source) } - fn set(&self, parser: CommandParser, author: &str) -> Result { + fn set(&self, parser: &CommandParser, author: &str) -> Result { debug!("parser: {:?}", parser); let target = parser.get_target(); @@ -125,7 +125,7 @@ impl Remind { let event = database::NewEvent { receiver: target, content: &parser.get_message(), - author: author, + author, time: &time, repeat: parser .get_repeat(Duration::from_secs(600))? @@ -212,9 +212,10 @@ impl Plugin for Remind { fn command(&self, client: &IrcClient, mut command: PluginCommand) -> Result<(), FrippyError> { if command.tokens.is_empty() { - return Ok(client + client .send_notice(&command.source, &ErrorKind::InvalidCommand.to_string()) - .context(FrippyErrorKind::Connection)?); + .context(FrippyErrorKind::Connection)?; + return Ok(()); } let source = command.source.clone(); @@ -229,7 +230,7 @@ impl Plugin for Remind { _ => Err(ErrorKind::InvalidCommand.into()), }; - let result = match response { + match response { Ok(msg) => client .send_notice(&source, &msg) .context(FrippyErrorKind::Connection)?, @@ -242,9 +243,9 @@ impl Plugin for Remind { Err(e).context(FrippyErrorKind::Remind)? } - }; + } - Ok(result) + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/remind/parser.rs b/src/plugins/remind/parser.rs index eb39d04..d6e8574 100644 --- a/src/plugins/remind/parser.rs +++ b/src/plugins/remind/parser.rs @@ -99,36 +99,26 @@ impl CommandParser { use self::ParseState::*; let string = Some(string); match state { - &On if self.on_date.is_none() => { - return Ok(CommandParser { - on_date: string, - ..self - }) - } - &At if self.at_time.is_none() => { - return Ok(CommandParser { - at_time: string, - ..self - }) - } - &In if self.in_duration.is_none() => { - return Ok(CommandParser { - in_duration: string, - ..self - }) - } - &Msg if self.message.is_none() => { - return Ok(CommandParser { - message: string, - ..self - }) - } - &Every if self.every_time.is_none() => { - return Ok(CommandParser { - every_time: string, - ..self - }) - } + On if self.on_date.is_none() => Ok(CommandParser { + on_date: string, + ..self + }), + At if self.at_time.is_none() => Ok(CommandParser { + at_time: string, + ..self + }), + In if self.in_duration.is_none() => Ok(CommandParser { + in_duration: string, + ..self + }), + Msg if self.message.is_none() => Ok(CommandParser { + message: string, + ..self + }), + Every if self.every_time.is_none() => Ok(CommandParser { + every_time: string, + ..self + }), _ => Err(ErrorKind::MissingMessage.into()), } } diff --git a/src/plugins/sed.rs b/src/plugins/sed.rs index f766809..368f5d4 100644 --- a/src/plugins/sed.rs +++ b/src/plugins/sed.rs @@ -26,7 +26,7 @@ pub struct Sed { impl Sed { pub fn new(per_channel: usize) -> Sed { Sed { - per_channel: per_channel, + per_channel, channel_messages: RwLock::new(HashMap::new()), } } @@ -35,7 +35,7 @@ impl Sed { let mut channel_messages = self.channel_messages.write(); let messages = channel_messages .entry(channel) - .or_insert(CircularQueue::with_capacity(self.per_channel)); + .or_insert_with(|| CircularQueue::with_capacity(self.per_channel)); messages.push(message); } @@ -150,12 +150,14 @@ impl Plugin for Sed { } fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client + client .send_notice( &command.source, "Currently this Plugin does not implement any commands.", ) - .context(FrippyErrorKind::Connection)?) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/tell/database.rs b/src/plugins/tell/database.rs index 75789e4..cbcb93d 100644 --- a/src/plugins/tell/database.rs +++ b/src/plugins/tell/database.rs @@ -45,7 +45,7 @@ pub trait Database: Send + Sync { } // HashMap -impl Database for HashMap> { +impl Database for HashMap, S> { fn insert_tell(&mut self, tell: &NewTellMessage) -> Result<(), TellError> { let tell = TellMessage { id: 0, diff --git a/src/plugins/tell/mod.rs b/src/plugins/tell/mod.rs index c681d43..225373e 100644 --- a/src/plugins/tell/mod.rs +++ b/src/plugins/tell/mod.rs @@ -1,4 +1,5 @@ use antidote::RwLock; +use irc::client::data::User; use irc::client::prelude::*; use chrono::NaiveDateTime; @@ -56,17 +57,19 @@ impl Tell { .list_channels() .expect("The irc crate should not be compiled with the \"nochanlists\" feature"); - if let Some(_) = channels + let find_receiver = |option: Option>| { + option.and_then(|users| { + users + .into_iter() + .find(|user| user.get_nickname().eq_ignore_ascii_case(&receiver)) + }) + }; + + if channels .iter() .map(|channel| client.list_users(&channel)) - .map(|option| { - option.and_then(|users| { - users - .into_iter() - .find(|user| user.get_nickname().eq_ignore_ascii_case(&receiver)) - }) - }) - .find(|option| option.is_some()) + .map(find_receiver) + .any(|option| option.is_some()) { online.push(receiver); continue; @@ -87,7 +90,7 @@ impl Tell { } Ok(if no_receiver && online.is_empty() { - format!("Invalid receiver.") + String::from("Invalid receiver.") } else { match online.len() { 0 => format!("Got it!"), @@ -207,28 +210,29 @@ impl Plugin for Tell { fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { if command.tokens.is_empty() { - return Ok(client + client .send_notice(&command.source, &self.invalid_command()) - .context(FrippyErrorKind::Connection)?); + .context(FrippyErrorKind::Connection)?; + return Ok(()); } let sender = command.source.to_owned(); - Ok(match command.tokens[0].as_ref() { + match command.tokens[0].as_ref() { "help" => client .send_notice(&command.source, &self.help()) - .context(FrippyErrorKind::Connection) - .into(), + .context(FrippyErrorKind::Connection), _ => match self.tell_command(client, command) { Ok(msg) => client .send_notice(&sender, &msg) .context(FrippyErrorKind::Connection), Err(e) => client .send_notice(&sender, &e.to_string()) - .context(FrippyErrorKind::Connection) - .into(), + .context(FrippyErrorKind::Connection), }, - }?) + }?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { diff --git a/src/plugins/url.rs b/src/plugins/url.rs index 9724d70..971597d 100644 --- a/src/plugins/url.rs +++ b/src/plugins/url.rs @@ -64,11 +64,11 @@ impl Title { .map_err(|_| ErrorKind::HtmlDecoding.into()) } - fn find_ogtitle<'a>(body: &str) -> Result { + fn find_ogtitle(body: &str) -> Result { Self::find_by_delimiters(body, ["property=\"og:title\"", "content=\"", "\""]) } - fn find_title<'a>(body: &str) -> Result { + fn find_title(body: &str) -> Result { Self::find_by_delimiters(body, ["", ""]) } @@ -93,12 +93,12 @@ impl Title { Title(self.0.trim().replace('\n', "|").replace('\r', "|"), self.1) } - pub fn find_clean_ogtitle<'a>(body: &str, url: &str) -> Result { + pub fn find_clean_ogtitle(body: &str, url: &str) -> Result { let title = Self::find_ogtitle(body)?; Ok(title.get_usefulness(url).clean_up()) } - pub fn find_clean_title<'a>(body: &str, url: &str) -> Result { + pub fn find_clean_title(body: &str, url: &str) -> Result { let title = Self::find_title(body)?; Ok(title.get_usefulness(url).clean_up()) } @@ -107,7 +107,7 @@ impl Title { impl UrlTitles { /// If a file is larger than `max_kib` KiB the download is stopped pub fn new(max_kib: usize) -> Self { - UrlTitles { max_kib: max_kib } + UrlTitles { max_kib } } fn grep_url<'a>(&self, msg: &'a str) -> Option> { @@ -161,28 +161,27 @@ impl Plugin for UrlTitles { } fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), FrippyError> { - match message.command { - Command::PRIVMSG(_, ref content) => { - let title = self.url(content).context(FrippyErrorKind::Url)?; - let response = format!("[URL] {}", title); + if let Command::PRIVMSG(_, ref content) = message.command { + let title = self.url(content).context(FrippyErrorKind::Url)?; + let response = format!("[URL] {}", title); - client - .send_privmsg(message.response_target().unwrap(), &response) - .context(FrippyErrorKind::Connection)?; - } - _ => (), + client + .send_privmsg(message.response_target().unwrap(), &response) + .context(FrippyErrorKind::Connection)?; } Ok(()) } fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client + client .send_notice( &command.source, "This Plugin does not implement any commands.", ) - .context(FrippyErrorKind::Connection)?) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result { diff --git a/src/utils.rs b/src/utils.rs index e64b329..3275e62 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -53,10 +53,7 @@ impl<'a> Url<'a> { /// that the limit set by max_kib() was reached. pub fn request(&self) -> Result { let client = if let Some(timeout) = self.timeout { - ClientBuilder::new() - .timeout(timeout) - .build() - .unwrap() + ClientBuilder::new().timeout(timeout).build().unwrap() } else { Client::new() }; -- cgit v1.2.3-70-g09d2 From 3929022952ffbd5be0a9ba4ff074a735dea2aed1 Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 30 Jun 2018 19:57:37 +0200 Subject: Plugins: Replace IrcClient with a trait This is to make it simpler to replace the client in the future. --- src/lib.rs | 67 +++++++++++++++++++++++++++++-------------- src/plugin.rs | 10 ++++--- src/plugins/emoji.rs | 25 ++++++++++------ src/plugins/factoids/mod.rs | 31 ++++++++++++++------ src/plugins/factoids/utils.rs | 8 ++++-- src/plugins/help.rs | 26 +++++++++++------ src/plugins/keepnick.rs | 28 +++++++++++------- src/plugins/remind/mod.rs | 33 ++++++++++++++------- src/plugins/sed.rs | 27 ++++++++++------- src/plugins/tell/mod.rs | 34 +++++++++++----------- src/plugins/url.rs | 27 +++++++++++------ 11 files changed, 206 insertions(+), 110 deletions(-) (limited to 'src/plugins/emoji.rs') diff --git a/src/lib.rs b/src/lib.rs index 9b49644..b8662e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,23 +60,37 @@ pub mod plugin; pub mod plugins; pub mod utils; +use plugin::*; + +use error::*; +use failure::ResultExt; + +pub use irc::client::data::Config; +use irc::client::ext::ClientExt; +use irc::client::reactor::IrcReactor; +use irc::client::{Client, IrcClient}; +use irc::error::IrcError; +use irc::proto::{command::Command, Message}; + use std::collections::HashMap; use std::fmt; use std::sync::Arc; use std::thread; -use error::*; -use failure::ResultExt; -pub use irc::client::prelude::*; -pub use irc::error::IrcError; +pub trait FrippyClient: Client + Send + Sync + Clone + fmt::Debug { + fn current_nickname(&self) -> &str; +} -use plugin::*; +impl FrippyClient for IrcClient { + fn current_nickname(&self) -> &str { + self.current_nickname() + } +} /// The bot which contains the main logic. -#[derive(Default)] pub struct Bot<'a> { prefix: &'a str, - plugins: ThreadedPlugins, + plugins: ThreadedPlugins, } impl<'a> Bot<'a> { @@ -93,7 +107,7 @@ impl<'a> Bot<'a> { /// use frippy::Bot; /// let mut bot = Bot::new("."); /// ``` - pub fn new(cmd_prefix: &'a str) -> Bot<'a> { + pub fn new(cmd_prefix: &'a str) -> Self { Bot { prefix: cmd_prefix, plugins: ThreadedPlugins::new(), @@ -110,7 +124,10 @@ impl<'a> Bot<'a> { /// let mut bot = frippy::Bot::new("."); /// bot.add_plugin(plugins::help::Help::new()); /// ``` - pub fn add_plugin(&mut self, plugin: T) { + pub fn add_plugin(&mut self, plugin: T) + where + T: Plugin + 'static, + { self.plugins.add(plugin); } @@ -179,12 +196,15 @@ impl<'a> Bot<'a> { } } -fn process_msg( - client: &IrcClient, - mut plugins: ThreadedPlugins, +fn process_msg( + client: &C, + mut plugins: ThreadedPlugins, prefix: &str, message: Message, -) -> Result<(), IrcError> { +) -> Result<(), IrcError> +where + C: FrippyClient + 'static, +{ // Log any channels we join if let Command::JOIN(ref channel, _, _) = message.command { if message.source_nickname().unwrap() == client.current_nickname() { @@ -207,19 +227,22 @@ fn process_msg( Ok(()) } -#[derive(Clone, Default, Debug)] -struct ThreadedPlugins { - plugins: HashMap>, +#[derive(Clone, Debug)] +struct ThreadedPlugins { + plugins: HashMap>>, } -impl ThreadedPlugins { - pub fn new() -> ThreadedPlugins { +impl ThreadedPlugins { + pub fn new() -> Self { ThreadedPlugins { plugins: HashMap::new(), } } - pub fn add(&mut self, plugin: T) { + pub fn add(&mut self, plugin: T) + where + T: Plugin + 'static, + { let name = plugin.name().to_lowercase(); let safe_plugin = Arc::new(plugin); @@ -232,7 +255,7 @@ impl ThreadedPlugins { /// Runs the execute functions on all plugins. /// Any errors that occur are printed right away. - pub fn execute_plugins(&mut self, client: &IrcClient, message: Message) { + pub fn execute_plugins(&mut self, client: &C, message: Message) { let message = Arc::new(message); for (name, plugin) in self.plugins.clone() { @@ -273,7 +296,7 @@ impl ThreadedPlugins { pub fn handle_command( &mut self, - client: &IrcClient, + client: &C, mut command: PluginCommand, ) -> Result<(), FrippyError> { // Check if there is a plugin for this command @@ -300,7 +323,7 @@ impl ThreadedPlugins { } } -impl fmt::Display for ThreadedPlugins { +impl fmt::Display for ThreadedPlugins { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let plugin_names = self.plugins .iter() diff --git a/src/plugin.rs b/src/plugin.rs index 5538313..65bfe1f 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -20,17 +20,19 @@ pub enum ExecutionStatus { /// `Plugin` has to be implemented for any struct that should be usable /// as a `Plugin` in frippy. pub trait Plugin: PluginName + Send + Sync + fmt::Debug { + type Client; /// Handles messages which are not commands or returns /// [`RequiresThread`](enum.ExecutionStatus.html#variant.RequiresThread) /// if [`execute_threaded()`](trait.Plugin.html#tymethod.execute_threaded) should be used instead. - fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus; + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus; /// Handles messages which are not commands in a new thread. - fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), FrippyError>; + fn execute_threaded(&self, client: &Self::Client, message: &Message) + -> Result<(), FrippyError>; /// Handles any command directed at this plugin. - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError>; + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError>; /// Similar to [`command()`](trait.Plugin.html#tymethod.command) but return a String instead of /// sending messages directly to IRC. - fn evaluate(&self, client: &IrcClient, command: PluginCommand) -> Result; + fn evaluate(&self, client: &Self::Client, command: PluginCommand) -> Result; } /// `PluginName` is required by [`Plugin`](trait.Plugin.html). diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index e4dffdb..01fb39c 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -1,10 +1,12 @@ extern crate unicode_names; use std::fmt; +use std::marker::PhantomData; use irc::client::prelude::*; use plugin::*; +use FrippyClient; use error::ErrorKind as FrippyErrorKind; use error::FrippyError; @@ -33,11 +35,15 @@ impl fmt::Display for EmojiHandle { } #[derive(PluginName, Default, Debug)] -pub struct Emoji; +pub struct Emoji { + phantom: PhantomData, +} -impl Emoji { - pub fn new() -> Emoji { - Emoji {} +impl Emoji { + pub fn new() -> Self { + Emoji { + phantom: PhantomData, + } } fn emoji(&self, content: &str) -> Option { @@ -102,8 +108,9 @@ impl Emoji { } } -impl Plugin for Emoji { - fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for Emoji { + type Client = C; + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { Command::PRIVMSG(_, ref content) => { if let Some(emojis) = self.emoji(content) { @@ -121,11 +128,11 @@ impl Plugin for Emoji { } } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Emoji should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { client .send_notice( &command.source, @@ -136,7 +143,7 @@ impl Plugin for Emoji { Ok(()) } - fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, command: PluginCommand) -> Result { if let Some(emojis) = self.emoji(&command.tokens[0]) { Ok(emojis) } else { diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs index 6ff2132..10f5131 100644 --- a/src/plugins/factoids/mod.rs +++ b/src/plugins/factoids/mod.rs @@ -4,12 +4,14 @@ use self::rlua::prelude::*; use antidote::RwLock; use irc::client::prelude::*; use std::fmt; +use std::marker::PhantomData; use std::str::FromStr; use chrono::NaiveDateTime; use time; use plugin::*; +use FrippyClient; pub mod database; use self::database::Database; @@ -30,14 +32,16 @@ enum FactoidResponse { } #[derive(PluginName)] -pub struct Factoids { +pub struct Factoids { factoids: RwLock, + phantom: PhantomData, } -impl Factoids { - pub fn new(db: T) -> Factoids { +impl Factoids { + pub fn new(db: T) -> Self { Factoids { factoids: RwLock::new(db), + phantom: PhantomData, } } @@ -228,8 +232,9 @@ impl Factoids { } } -impl Plugin for Factoids { - fn execute(&self, _: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for Factoids { + type Client = C; + fn execute(&self, _: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { Command::PRIVMSG(_, ref content) => if content.starts_with('!') { ExecutionStatus::RequiresThread @@ -240,7 +245,11 @@ impl Plugin for Factoids { } } - fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), FrippyError> { + fn execute_threaded( + &self, + client: &Self::Client, + message: &Message, + ) -> Result<(), FrippyError> { if let Command::PRIVMSG(_, mut content) = message.command.clone() { content.remove(0); @@ -262,7 +271,11 @@ impl Plugin for Factoids { Ok(()) } - fn command(&self, client: &IrcClient, mut command: PluginCommand) -> Result<(), FrippyError> { + fn command( + &self, + client: &Self::Client, + mut command: PluginCommand, + ) -> Result<(), FrippyError> { use self::FactoidResponse::{Private, Public}; if command.tokens.is_empty() { @@ -310,14 +323,14 @@ impl Plugin for Factoids { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from( "Evaluation of commands is not implemented for Factoids at this time", )) } } -impl fmt::Debug for Factoids { +impl fmt::Debug for Factoids { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Factoids {{ ... }}") } diff --git a/src/plugins/factoids/utils.rs b/src/plugins/factoids/utils.rs index 9352a43..a7bf04a 100644 --- a/src/plugins/factoids/utils.rs +++ b/src/plugins/factoids/utils.rs @@ -38,7 +38,9 @@ pub fn download(_: &Lua, url: String) -> Result { fn convert_value(lua: &Lua, sval: SerdeValue, max_recurs: usize) -> Result { if max_recurs == 0 { - return Err(RuntimeError(String::from("Reached max recursion level - json is nested too deep"))); + return Err(RuntimeError(String::from( + "Reached max recursion level - json is nested too deep", + ))); } let lval = match sval { @@ -46,7 +48,9 @@ fn convert_value(lua: &Lua, sval: SerdeValue, max_recurs: usize) -> Result LuaValue::Boolean(b), SerdeValue::String(s) => LuaValue::String(lua.create_string(&s)?), SerdeValue::Number(n) => { - let f = n.as_f64().ok_or(RuntimeError(String::from("Failed to convert number into double",)))?; + let f = n.as_f64().ok_or(RuntimeError(String::from( + "Failed to convert number into double", + )))?; LuaValue::Number(f) } SerdeValue::Array(arr) => { diff --git a/src/plugins/help.rs b/src/plugins/help.rs index f048a8e..9a67c99 100644 --- a/src/plugins/help.rs +++ b/src/plugins/help.rs @@ -1,30 +1,38 @@ +use std::marker::PhantomData; + use irc::client::prelude::*; use plugin::*; +use FrippyClient; use error::ErrorKind as FrippyErrorKind; use error::FrippyError; use failure::ResultExt; #[derive(PluginName, Default, Debug)] -pub struct Help; +pub struct Help { + phantom: PhantomData, +} -impl Help { - pub fn new() -> Help { - Help {} +impl Help { + pub fn new() -> Self { + Help { + phantom: PhantomData, + } } } -impl Plugin for Help { - fn execute(&self, _: &IrcClient, _: &Message) -> ExecutionStatus { +impl Plugin for Help { + type Client = C; + fn execute(&self, _: &Self::Client, _: &Message) -> ExecutionStatus { ExecutionStatus::Done } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Help should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { client .send_notice( &command.source, @@ -37,7 +45,7 @@ impl Plugin for Help { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from("Help has not been added yet.")) } } diff --git a/src/plugins/keepnick.rs b/src/plugins/keepnick.rs index a728c63..6ba16c1 100644 --- a/src/plugins/keepnick.rs +++ b/src/plugins/keepnick.rs @@ -1,20 +1,27 @@ +use std::marker::PhantomData; + use irc::client::prelude::*; use plugin::*; +use FrippyClient; use error::ErrorKind as FrippyErrorKind; use error::FrippyError; use failure::ResultExt; #[derive(PluginName, Default, Debug)] -pub struct KeepNick; +pub struct KeepNick { + phantom: PhantomData, +} -impl KeepNick { - pub fn new() -> KeepNick { - KeepNick {} +impl KeepNick { + pub fn new() -> Self { + KeepNick { + phantom: PhantomData, + } } - fn check_nick(&self, client: &IrcClient, leaver: &str) -> ExecutionStatus { + fn check_nick(&self, client: &C, leaver: &str) -> ExecutionStatus { let cfg_nick = match client.config().nickname { Some(ref nick) => nick.clone(), None => return ExecutionStatus::Done, @@ -41,8 +48,9 @@ impl KeepNick { } } -impl Plugin for KeepNick { - fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for KeepNick { + type Client = C; + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { Command::QUIT(ref nick) => { self.check_nick(client, &nick.clone().unwrap_or_else(String::new)) @@ -51,11 +59,11 @@ impl Plugin for KeepNick { } } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Tell should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { client .send_notice( &command.source, @@ -66,7 +74,7 @@ impl Plugin for KeepNick { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from("This Plugin does not implement any commands.")) } } diff --git a/src/plugins/remind/mod.rs b/src/plugins/remind/mod.rs index fa7cf70..fa44b0b 100644 --- a/src/plugins/remind/mod.rs +++ b/src/plugins/remind/mod.rs @@ -1,12 +1,16 @@ -use antidote::RwLock; -use irc::client::prelude::*; +use std::marker::PhantomData; use std::thread::{sleep, spawn}; use std::{fmt, sync::Arc, time::Duration}; +use antidote::RwLock; +use irc::client::prelude::*; + use chrono::{self, NaiveDateTime}; use time; use plugin::*; +use FrippyClient; + pub mod database; mod parser; use self::database::Database; @@ -38,7 +42,7 @@ fn get_events(db: &RwLock, in_next: chrono::Duration) -> Vec(client: &IrcClient, db: Arc>) { +fn run(client: &C, db: Arc>) { let look_ahead = chrono::Duration::minutes(2); let mut events = get_events(&db, look_ahead); @@ -88,18 +92,20 @@ fn run(client: &IrcClient, db: Arc>) { } #[derive(PluginName)] -pub struct Remind { +pub struct Remind { events: Arc>, has_reminder: RwLock, + phantom: PhantomData, } -impl Remind { +impl Remind { pub fn new(db: T) -> Self { let events = Arc::new(RwLock::new(db)); Remind { events, has_reminder: RwLock::new(false), + phantom: PhantomData, } } @@ -188,8 +194,9 @@ impl Remind { } } -impl Plugin for Remind { - fn execute(&self, client: &IrcClient, msg: &Message) -> ExecutionStatus { +impl Plugin for Remind { + type Client = C; + fn execute(&self, client: &Self::Client, msg: &Message) -> ExecutionStatus { if let Command::JOIN(_, _, _) = msg.command { let mut has_reminder = self.has_reminder.write(); @@ -206,11 +213,15 @@ impl Plugin for Remind { ExecutionStatus::Done } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Remind should not use frippy's threading") } - fn command(&self, client: &IrcClient, mut command: PluginCommand) -> Result<(), FrippyError> { + fn command( + &self, + client: &Self::Client, + mut command: PluginCommand, + ) -> Result<(), FrippyError> { if command.tokens.is_empty() { client .send_notice(&command.source, &ErrorKind::InvalidCommand.to_string()) @@ -248,14 +259,14 @@ impl Plugin for Remind { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from( "Evaluation of commands is not implemented for remind at this time", )) } } -impl fmt::Debug for Remind { +impl fmt::Debug for Remind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Remind {{ ... }}") } diff --git a/src/plugins/sed.rs b/src/plugins/sed.rs index 368f5d4..cf7f9d5 100644 --- a/src/plugins/sed.rs +++ b/src/plugins/sed.rs @@ -1,11 +1,14 @@ +use std::collections::HashMap; +use std::marker::PhantomData; + use antidote::RwLock; use circular_queue::CircularQueue; use regex::{Regex, RegexBuilder}; -use std::collections::HashMap; use irc::client::prelude::*; use plugin::*; +use FrippyClient; use self::error::*; use error::ErrorKind as FrippyErrorKind; @@ -14,20 +17,23 @@ use failure::Fail; use failure::ResultExt; lazy_static! { - static ref RE: Regex = Regex::new(r"^s/((?:\\/|[^/])+)/((?:\\/|[^/])*)/(?:(\w+))?\s*$").unwrap(); + static ref RE: Regex = + Regex::new(r"^s/((?:\\/|[^/])+)/((?:\\/|[^/])*)/(?:(\w+))?\s*$").unwrap(); } #[derive(PluginName, Debug)] -pub struct Sed { +pub struct Sed { per_channel: usize, channel_messages: RwLock>>, + phantom: PhantomData, } -impl Sed { - pub fn new(per_channel: usize) -> Sed { +impl Sed { + pub fn new(per_channel: usize) -> Self { Sed { per_channel, channel_messages: RwLock::new(HashMap::new()), + phantom: PhantomData, } } @@ -108,8 +114,9 @@ impl Sed { } } -impl Plugin for Sed { - fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for Sed { + type Client = C; + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { Command::PRIVMSG(_, ref content) => { let channel = message.response_target().unwrap(); @@ -145,11 +152,11 @@ impl Plugin for Sed { } } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Sed should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { client .send_notice( &command.source, @@ -160,7 +167,7 @@ impl Plugin for Sed { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from( "Evaluation of commands is not implemented for sed at this time", )) diff --git a/src/plugins/tell/mod.rs b/src/plugins/tell/mod.rs index 07b2478..eb7a244 100644 --- a/src/plugins/tell/mod.rs +++ b/src/plugins/tell/mod.rs @@ -1,3 +1,5 @@ +use std::marker::PhantomData; + use antidote::RwLock; use irc::client::data::User; use irc::client::prelude::*; @@ -8,6 +10,7 @@ use std::time::Duration; use time; use plugin::*; +use FrippyClient; use self::error::*; use error::ErrorKind as FrippyErrorKind; @@ -19,22 +22,20 @@ pub mod database; use self::database::Database; #[derive(PluginName)] -pub struct Tell { +pub struct Tell { tells: RwLock, + phantom: PhantomData, } -impl Tell { - pub fn new(db: T) -> Tell { +impl Tell { + pub fn new(db: T) -> Self { Tell { tells: RwLock::new(db), + phantom: PhantomData, } } - fn tell_command( - &self, - client: &IrcClient, - command: PluginCommand, - ) -> Result { + fn tell_command(&self, client: &C, command: PluginCommand) -> Result { if command.tokens.len() < 2 { return Ok(self.invalid_command().to_owned()); } @@ -105,7 +106,7 @@ impl Tell { }) } - fn on_namelist(&self, client: &IrcClient, channel: &str) -> Result<(), FrippyError> { + fn on_namelist(&self, client: &C, channel: &str) -> Result<(), FrippyError> { let receivers = self.tells .read() .get_receivers() @@ -128,7 +129,7 @@ impl Tell { } } - fn send_tells(&self, client: &IrcClient, receiver: &str) -> Result<(), FrippyError> { + fn send_tells(&self, client: &C, receiver: &str) -> Result<(), FrippyError> { if client.current_nickname() == receiver { return Ok(()); } @@ -187,8 +188,9 @@ impl Tell { } } -impl Plugin for Tell { - fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for Tell { + type Client = C; + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { let res = match message.command { Command::JOIN(_, _, _) => self.send_tells(client, message.source_nickname().unwrap()), Command::NICK(ref nick) => self.send_tells(client, nick), @@ -211,11 +213,11 @@ impl Plugin for Tell { } } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Tell should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { if command.tokens.is_empty() { client .send_notice(&command.source, &self.invalid_command()) @@ -242,13 +244,13 @@ impl Plugin for Tell { Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { Err(String::from("This Plugin does not implement any commands.")) } } use std::fmt; -impl fmt::Debug for Tell { +impl fmt::Debug for Tell { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Tell {{ ... }}") } diff --git a/src/plugins/url.rs b/src/plugins/url.rs index 971597d..24b2948 100644 --- a/src/plugins/url.rs +++ b/src/plugins/url.rs @@ -1,5 +1,6 @@ extern crate htmlescape; +use std::marker::PhantomData; use std::time::Duration; use irc::client::prelude::*; @@ -8,6 +9,7 @@ use regex::Regex; use plugin::*; use utils::Url; +use FrippyClient; use self::error::*; use error::ErrorKind as FrippyErrorKind; @@ -21,8 +23,9 @@ lazy_static! { } #[derive(PluginName, Debug)] -pub struct UrlTitles { +pub struct UrlTitles { max_kib: usize, + phantom: PhantomData, } #[derive(Clone, Debug)] @@ -104,10 +107,13 @@ impl Title { } } -impl UrlTitles { +impl UrlTitles { /// If a file is larger than `max_kib` KiB the download is stopped pub fn new(max_kib: usize) -> Self { - UrlTitles { max_kib } + UrlTitles { + max_kib, + phantom: PhantomData, + } } fn grep_url<'a>(&self, msg: &'a str) -> Option> { @@ -148,8 +154,9 @@ impl UrlTitles { } } -impl Plugin for UrlTitles { - fn execute(&self, _: &IrcClient, message: &Message) -> ExecutionStatus { +impl Plugin for UrlTitles { + type Client = C; + fn execute(&self, _: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { Command::PRIVMSG(_, ref msg) => if URL_RE.is_match(msg) { ExecutionStatus::RequiresThread @@ -160,7 +167,11 @@ impl Plugin for UrlTitles { } } - fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), FrippyError> { + fn execute_threaded( + &self, + client: &Self::Client, + message: &Message, + ) -> Result<(), FrippyError> { if let Command::PRIVMSG(_, ref content) = message.command { let title = self.url(content).context(FrippyErrorKind::Url)?; let response = format!("[URL] {}", title); @@ -173,7 +184,7 @@ impl Plugin for UrlTitles { Ok(()) } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { client .send_notice( &command.source, @@ -184,7 +195,7 @@ impl Plugin for UrlTitles { Ok(()) } - fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result { + fn evaluate(&self, _: &Self::Client, command: PluginCommand) -> Result { self.url(&command.tokens[0]) .map_err(|e| e.cause().unwrap().to_string()) } -- cgit v1.2.3-70-g09d2 From 399edf8f800100a7a15d1c272897bf232d0c5bb3 Mon Sep 17 00:00:00 2001 From: Jokler Date: Thu, 20 Sep 2018 00:42:20 +0200 Subject: Main: Remove diesel_infer_schema dep & run clippy This should fix travis-ci since diesel_infer_schema is deprecated. --- Cargo.lock | 80 -------------------------------------------- Cargo.toml | 8 +---- src/plugins/emoji.rs | 6 ++-- src/plugins/remind/parser.rs | 6 ++-- 4 files changed, 7 insertions(+), 93 deletions(-) (limited to 'src/plugins/emoji.rs') diff --git a/Cargo.lock b/Cargo.lock index 2b17557..a3fcb18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,15 +234,6 @@ name = "crossbeam-utils" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "derive-error-chain" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "diesel" version = "1.3.3" @@ -265,14 +256,6 @@ dependencies = [ "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "diesel_infer_schema" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "infer_schema_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "diesel_migrations" version = "1.3.0" @@ -282,16 +265,6 @@ dependencies = [ "migrations_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "dotenv" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "derive-error-chain 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "dtoa" version = "0.4.3" @@ -367,11 +340,6 @@ dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "error-chain" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "error-chain" version = "0.11.0" @@ -436,7 +404,6 @@ dependencies = [ "circular-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.212 (registry+https://github.com/rust-lang/crates.io-index)", "diesel 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "diesel_infer_schema 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "diesel_migrations 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "frippy_derive 0.1.0", @@ -611,25 +578,6 @@ name = "indexmap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "infer_schema_internals" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "diesel 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "infer_schema_macros" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "infer_schema_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "iovec" version = "0.1.2" @@ -1161,18 +1109,6 @@ name = "redox_syscall" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "regex" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" version = "1.0.5" @@ -1185,14 +1121,6 @@ dependencies = [ "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "regex-syntax" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex-syntax" version = "0.6.2" @@ -1936,12 +1864,9 @@ dependencies = [ "checksum crossbeam-deque 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3486aefc4c0487b9cb52372c97df0a48b8c249514af1ee99703bf70d2f2ceda1" "checksum crossbeam-epoch 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30fecfcac6abfef8771151f8be4abc9e4edc112c2bcb233314cafde2680536e9" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" -"checksum derive-error-chain 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3c9ca9ade651388daad7c993f005d0d20c4f6fe78c1cdc93e95f161c6f5ede4a" "checksum diesel 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "164080ac16a4d1d80a50f0a623e4ddef41cb2779eee85bcc76907d340dfc98cc" "checksum diesel_derives 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03bcaf77491f53e400d5ee3bdd57142ea4e1c47fe9217b3361ff9a76ca0e3d37" -"checksum diesel_infer_schema 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8a1dd088bb77bc1cdc144c3085068a61c4d9bd0780b77b2c1eb102c6aad986c" "checksum diesel_migrations 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b42c35d1ce9e8d57a3e7001b4127f2bc1b073a89708bb7019f5be27c991c28" -"checksum dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d6f0e2bb24d163428d8031d3ebd2d2bd903ad933205a97d0f18c7c1aade380f3" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" @@ -1952,7 +1877,6 @@ dependencies = [ "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" "checksum encoding_rs 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2a91912d6f37c6a8fef8a2316a862542d036f13c923ad518b5aca7bcaac7544c" -"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" @@ -1976,8 +1900,6 @@ dependencies = [ "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" "checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" -"checksum infer_schema_internals 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e0f1e381ff29feef92a7a4037d4d564007a43daca9aa79c578d99538e2a6623" -"checksum infer_schema_macros 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2394a0407ac25980f6259e56f947e02748dbef3ecd44cf46f0a4f60bd369b599" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum irc 0.13.5 (git+https://github.com/aatxe/irc/?branch=develop)" = "" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" @@ -2039,9 +1961,7 @@ dependencies = [ "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" -"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" -"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum reqwest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1cd396ef9387a076401c19701a86bc08d349ce45eab331247632b4bc9d0bd592" diff --git a/Cargo.toml b/Cargo.toml index 208f733..a8c264f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ doc = false [features] mysql = [ "diesel", - "diesel_infer_schema", "diesel_migrations", "r2d2", "r2d2-diesel" @@ -57,11 +56,6 @@ version = "1.3.3" optional = true features = ["mysql", "chrono"] -[dependencies.diesel_infer_schema] -version = "1.3.0" -optional = true -features = ["mysql"] - [dependencies.diesel_migrations] version = "1.3.0" optional = true @@ -76,5 +70,5 @@ version = "1.0.0" optional = true [dependencies.clippy] -version = "*" +version = "0.0.212" optional = true diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index 01fb39c..d738110 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -67,7 +67,7 @@ impl Emoji { let mut current = EmojiHandle::default(); for c in string.chars() { - if !self.is_emoji(&c) { + if !self.is_emoji(c) { continue; } @@ -92,10 +92,10 @@ impl Emoji { emojis } - fn is_emoji(&self, c: &char) -> bool { + fn is_emoji(&self, c: char) -> bool { // Emoji ranges from stackoverflow: // https://stackoverflow.com/questions/30757193/find-out-if-character-in-string-is-emoji - match *c { '\u{1F600}'...'\u{1F64F}' // Emoticons + match c { '\u{1F600}'...'\u{1F64F}' // Emoticons | '\u{1F300}'...'\u{1F5FF}' // Misc Symbols and Pictographs | '\u{1F680}'...'\u{1F6FF}' // Transport and Map | '\u{2600}' ...'\u{26FF}' // Misc symbols diff --git a/src/plugins/remind/parser.rs b/src/plugins/remind/parser.rs index d6e8574..965ad99 100644 --- a/src/plugins/remind/parser.rs +++ b/src/plugins/remind/parser.rs @@ -68,7 +68,7 @@ impl CommandParser { if next_state != state { if state != ParseState::None { - self = self.add_string_by_state(&state, cur_str)?; + self = self.add_string_by_state(state, cur_str)?; cur_str = String::new(); } @@ -76,7 +76,7 @@ impl CommandParser { } } - self = self.add_string_by_state(&state, cur_str)?; + self = self.add_string_by_state(state, cur_str)?; if self.message.is_none() { return Err(ErrorKind::MissingMessage.into()); @@ -95,7 +95,7 @@ impl CommandParser { Ok(self) } - fn add_string_by_state(self, state: &ParseState, string: String) -> Result { + fn add_string_by_state(self, state: ParseState, string: String) -> Result { use self::ParseState::*; let string = Some(string); match state { -- cgit v1.2.3-70-g09d2 From f9e3022756ea454a31f797bfc9cfdc1d81ee86cf Mon Sep 17 00:00:00 2001 From: Jokler Date: Mon, 22 Oct 2018 03:14:51 +0200 Subject: Factoids: Rename to Factoid --- src/error.rs | 9 +- src/main.rs | 15 +- src/plugins/emoji.rs | 3 +- src/plugins/factoid/database.rs | 161 +++++++++++++++++ src/plugins/factoid/mod.rs | 376 +++++++++++++++++++++++++++++++++++++++ src/plugins/factoid/sandbox.lua | 126 +++++++++++++ src/plugins/factoid/utils.rs | 82 +++++++++ src/plugins/factoids/database.rs | 160 ----------------- src/plugins/factoids/mod.rs | 373 -------------------------------------- src/plugins/factoids/sandbox.lua | 126 ------------- src/plugins/factoids/utils.rs | 81 --------- src/plugins/mod.rs | 4 +- 12 files changed, 761 insertions(+), 755 deletions(-) create mode 100644 src/plugins/factoid/database.rs create mode 100644 src/plugins/factoid/mod.rs create mode 100644 src/plugins/factoid/sandbox.lua create mode 100644 src/plugins/factoid/utils.rs delete mode 100644 src/plugins/factoids/database.rs delete mode 100644 src/plugins/factoids/mod.rs delete mode 100644 src/plugins/factoids/sandbox.lua delete mode 100644 src/plugins/factoids/utils.rs (limited to 'src/plugins/emoji.rs') diff --git a/src/error.rs b/src/error.rs index 70a7724..039b71d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,7 +3,8 @@ use failure::Fail; pub fn log_error(e: &FrippyError) { - let text = e.causes() + let text = e + .causes() .skip(1) .fold(format!("{}", e), |acc, err| format!("{}: {}", acc, err)); error!("{}", text); @@ -29,9 +30,9 @@ pub enum ErrorKind { #[fail(display = "A Tell error has occured")] Tell, - /// A Factoids error - #[fail(display = "A Factoids error has occured")] - Factoids, + /// A Factoid error + #[fail(display = "A Factoid error has occured")] + Factoid, /// A Quote error #[fail(display = "A Quote error has occured")] diff --git a/src/main.rs b/src/main.rs index c337a46..03f3c7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,10 +30,10 @@ use glob::glob; use irc::client::reactor::IrcReactor; use frippy::plugins::emoji::Emoji; -use frippy::plugins::factoids::Factoids; -use frippy::plugins::quote::Quote; +use frippy::plugins::factoid::Factoid; use frippy::plugins::help::Help; use frippy::plugins::keepnick::KeepNick; +use frippy::plugins::quote::Quote; use frippy::plugins::remind::Remind; use frippy::plugins::sed::Sed; use frippy::plugins::tell::Tell; @@ -58,7 +58,8 @@ fn main() { // Print any errors that caused frippy to shut down if let Err(e) = run() { - let text = e.iter_causes() + let text = e + .iter_causes() .fold(format!("{}", e), |acc, err| format!("{}: {}", acc, err)); error!("{}", text); } @@ -122,14 +123,14 @@ fn run() -> Result<(), Error> { Ok(pool) => match embedded_migrations::run(&*pool.get()?) { Ok(_) => { let pool = Arc::new(pool); - bot.add_plugin(Factoids::new(pool.clone())); + bot.add_plugin(Factoid::new(pool.clone())); bot.add_plugin(Quote::new(pool.clone())); bot.add_plugin(Tell::new(pool.clone())); bot.add_plugin(Remind::new(pool.clone())); info!("Connected to MySQL server") } Err(e) => { - bot.add_plugin(Factoids::new(HashMap::new())); + bot.add_plugin(Factoid::new(HashMap::new())); bot.add_plugin(Quote::new(HashMap::new())); bot.add_plugin(Tell::new(HashMap::new())); bot.add_plugin(Remind::new(HashMap::new())); @@ -139,7 +140,7 @@ fn run() -> Result<(), Error> { Err(e) => error!("Failed to connect to database: {}", e), } } else { - bot.add_plugin(Factoids::new(HashMap::new())); + bot.add_plugin(Factoid::new(HashMap::new())); bot.add_plugin(Quote::new(HashMap::new())); bot.add_plugin(Tell::new(HashMap::new())); bot.add_plugin(Remind::new(HashMap::new())); @@ -150,7 +151,7 @@ fn run() -> Result<(), Error> { if mysql_url.is_some() { error!("frippy was not built with the mysql feature") } - bot.add_plugin(Factoids::new(HashMap::new())); + bot.add_plugin(Factoid::new(HashMap::new())); bot.add_plugin(Quote::new(HashMap::new())); bot.add_plugin(Tell::new(HashMap::new())); bot.add_plugin(Remind::new(HashMap::new())); diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs index d738110..aee61b1 100644 --- a/src/plugins/emoji.rs +++ b/src/plugins/emoji.rs @@ -137,8 +137,7 @@ impl Plugin for Emoji { .send_notice( &command.source, "This Plugin does not implement any commands.", - ) - .context(FrippyErrorKind::Connection)?; + ).context(FrippyErrorKind::Connection)?; Ok(()) } diff --git a/src/plugins/factoid/database.rs b/src/plugins/factoid/database.rs new file mode 100644 index 0000000..5e7e24c --- /dev/null +++ b/src/plugins/factoid/database.rs @@ -0,0 +1,161 @@ +use std::collections::HashMap; +#[cfg(feature = "mysql")] +use std::sync::Arc; + +#[cfg(feature = "mysql")] +use diesel::mysql::MysqlConnection; +#[cfg(feature = "mysql")] +use diesel::prelude::*; +#[cfg(feature = "mysql")] +use failure::ResultExt; +#[cfg(feature = "mysql")] +use r2d2::Pool; +#[cfg(feature = "mysql")] +use r2d2_diesel::ConnectionManager; + +use chrono::NaiveDateTime; + +use super::error::*; + +#[cfg_attr(feature = "mysql", derive(Queryable))] +#[derive(Clone, Debug)] +pub struct Factoid { + pub name: String, + pub idx: i32, + pub content: String, + pub author: String, + pub created: NaiveDateTime, +} + +#[cfg_attr(feature = "mysql", derive(Insertable))] +#[cfg_attr(feature = "mysql", table_name = "factoids")] +pub struct NewFactoid<'a> { + pub name: &'a str, + pub idx: i32, + pub content: &'a str, + pub author: &'a str, + pub created: NaiveDateTime, +} + +pub trait Database: Send + Sync { + fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidError>; + fn get_factoid(&self, name: &str, idx: i32) -> Result; + fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidError>; + fn count_factoids(&self, name: &str) -> Result; +} + +// HashMap +impl Database for HashMap<(String, i32), Factoid, S> { + fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidError> { + let factoid = Factoid { + name: factoid.name.to_owned(), + idx: factoid.idx, + content: factoid.content.to_owned(), + author: factoid.author.to_owned(), + created: factoid.created, + }; + + let name = factoid.name.clone(); + match self.insert((name, factoid.idx), factoid) { + None => Ok(()), + Some(_) => Err(ErrorKind::Duplicate)?, + } + } + + fn get_factoid(&self, name: &str, idx: i32) -> Result { + Ok(self + .get(&(name.to_owned(), idx)) + .cloned() + .ok_or(ErrorKind::NotFound)?) + } + + fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidError> { + match self.remove(&(name.to_owned(), idx)) { + Some(_) => Ok(()), + None => Err(ErrorKind::NotFound)?, + } + } + + fn count_factoids(&self, name: &str) -> Result { + Ok(self.iter().filter(|&(&(ref n, _), _)| n == name).count() as i32) + } +} + +// Diesel automatically defines the factoids module as public. +// We create a schema module to keep it private. +#[cfg(feature = "mysql")] +mod schema { + table! { + factoids (name, idx) { + name -> Varchar, + idx -> Integer, + content -> Text, + author -> Varchar, + created -> Timestamp, + } + } +} + +#[cfg(feature = "mysql")] +use self::schema::factoids; + +#[cfg(feature = "mysql")] +impl Database for Arc>> { + fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidError> { + use diesel; + + let conn = &*self.get().context(ErrorKind::NoConnection)?; + diesel::insert_into(factoids::table) + .values(factoid) + .execute(conn) + .context(ErrorKind::MysqlError)?; + + Ok(()) + } + + fn get_factoid(&self, name: &str, idx: i32) -> Result { + let conn = &*self.get().context(ErrorKind::NoConnection)?; + Ok(factoids::table + .find((name, idx)) + .first(conn) + .context(ErrorKind::MysqlError)?) + } + + fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidError> { + use self::factoids::columns; + use diesel; + + let conn = &*self.get().context(ErrorKind::NoConnection)?; + match diesel::delete( + factoids::table + .filter(columns::name.eq(name)) + .filter(columns::idx.eq(idx)), + ).execute(conn) + { + Ok(v) => { + if v > 0 { + Ok(()) + } else { + Err(ErrorKind::NotFound)? + } + } + Err(e) => Err(e).context(ErrorKind::MysqlError)?, + } + } + + fn count_factoids(&self, name: &str) -> Result { + use diesel; + + let conn = &*self.get().context(ErrorKind::NoConnection)?; + let count: Result = factoids::table + .filter(factoids::columns::name.eq(name)) + .count() + .get_result(conn); + + match count { + Ok(c) => Ok(c as i32), + Err(diesel::NotFound) => Ok(0), + Err(e) => Err(e).context(ErrorKind::MysqlError)?, + } + } +} diff --git a/src/plugins/factoid/mod.rs b/src/plugins/factoid/mod.rs new file mode 100644 index 0000000..4fcc7a0 --- /dev/null +++ b/src/plugins/factoid/mod.rs @@ -0,0 +1,376 @@ +extern crate rlua; + +use self::rlua::prelude::*; +use antidote::RwLock; +use irc::client::prelude::*; +use std::fmt; +use std::marker::PhantomData; +use std::str::FromStr; + +use chrono::NaiveDateTime; +use time; + +use plugin::*; +use FrippyClient; +pub mod database; +use self::database::Database; + +mod utils; +use self::utils::*; +use utils::Url; + +use self::error::*; +use error::ErrorKind as FrippyErrorKind; +use error::FrippyError; +use failure::ResultExt; + +static LUA_SANDBOX: &'static str = include_str!("sandbox.lua"); + +enum FactoidResponse { + Public(String), + Private(String), +} + +#[derive(PluginName)] +pub struct Factoid { + factoids: RwLock, + phantom: PhantomData, +} + +impl Factoid { + pub fn new(db: T) -> Self { + Factoid { + factoids: RwLock::new(db), + phantom: PhantomData, + } + } + + fn create_factoid( + &self, + name: &str, + content: &str, + author: &str, + ) -> Result<&str, FactoidError> { + let count = self.factoids.read().count_factoids(name)?; + let tm = time::now().to_timespec(); + + let factoid = database::NewFactoid { + name, + idx: count, + content, + author, + created: NaiveDateTime::from_timestamp(tm.sec, 0u32), + }; + + Ok(self + .factoids + .write() + .insert_factoid(&factoid) + .map(|()| "Successfully added!")?) + } + + fn add(&self, command: &mut PluginCommand) -> Result<&str, FactoidError> { + if command.tokens.len() < 2 { + Err(ErrorKind::InvalidCommand)?; + } + + let name = command.tokens.remove(0); + let content = command.tokens.join(" "); + + Ok(self.create_factoid(&name, &content, &command.source)?) + } + + fn add_from_url(&self, command: &mut PluginCommand) -> Result<&str, FactoidError> { + if command.tokens.len() < 2 { + Err(ErrorKind::InvalidCommand)?; + } + + let name = command.tokens.remove(0); + let url = &command.tokens[0]; + let content = Url::from(url.as_ref()) + .max_kib(1024) + .request() + .context(ErrorKind::Download)?; + + Ok(self.create_factoid(&name, &content, &command.source)?) + } + + fn remove(&self, command: &mut PluginCommand) -> Result<&str, FactoidError> { + if command.tokens.is_empty() { + Err(ErrorKind::InvalidCommand)?; + } + + let name = command.tokens.remove(0); + let count = self.factoids.read().count_factoids(&name)?; + + match self.factoids.write().delete_factoid(&name, count - 1) { + Ok(()) => Ok("Successfully removed"), + Err(e) => Err(e)?, + } + } + + fn get(&self, command: &PluginCommand) -> Result { + let (name, idx) = match command.tokens.len() { + 0 => Err(ErrorKind::InvalidCommand)?, + 1 => { + let name = &command.tokens[0]; + let count = self.factoids.read().count_factoids(name)?; + + if count < 1 { + Err(ErrorKind::NotFound)?; + } + + (name, count - 1) + } + _ => { + let name = &command.tokens[0]; + let idx = match i32::from_str(&command.tokens[1]) { + Ok(i) => i, + Err(_) => Err(ErrorKind::InvalidCommand)?, + }; + + (name, idx) + } + }; + + let factoid = self + .factoids + .read() + .get_factoid(name, idx) + .context(ErrorKind::NotFound)?; + + let message = factoid.content.replace("\n", "|").replace("\r", ""); + + Ok(format!("{}: {}", factoid.name, message)) + } + + fn info(&self, command: &PluginCommand) -> Result { + match command.tokens.len() { + 0 => Err(ErrorKind::InvalidCommand)?, + 1 => { + let name = &command.tokens[0]; + let count = self.factoids.read().count_factoids(name)?; + + Ok(match count { + 0 => Err(ErrorKind::NotFound)?, + 1 => format!("There is 1 version of {}", name), + _ => format!("There are {} versions of {}", count, name), + }) + } + _ => { + let name = &command.tokens[0]; + let idx = i32::from_str(&command.tokens[1]).context(ErrorKind::InvalidIndex)?; + let factoid = self.factoids.read().get_factoid(name, idx)?; + + Ok(format!( + "{}: Added by {} at {} UTC", + name, factoid.author, factoid.created + )) + } + } + } + + fn exec(&self, mut command: PluginCommand) -> Result { + if command.tokens.is_empty() { + Err(ErrorKind::InvalidIndex)? + } else { + let name = command.tokens.remove(0); + let count = self.factoids.read().count_factoids(&name)?; + let factoid = self.factoids.read().get_factoid(&name, count - 1)?; + + let content = factoid.content; + let value = if content.starts_with('>') { + let content = String::from(&content[1..]); + + if content.starts_with('>') { + content + } else { + match self.run_lua(&name, &content, &command) { + Ok(v) => v, + Err(e) => match e { + LuaError::CallbackError { cause, .. } => cause.to_string(), + _ => e.to_string(), + }, + } + } + } else { + content + }; + + Ok(value.replace("\n", "|").replace("\r", "")) + } + } + + fn run_lua(&self, name: &str, code: &str, command: &PluginCommand) -> Result { + let args = command + .tokens + .iter() + .filter(|x| !x.is_empty()) + .map(ToOwned::to_owned) + .collect::>(); + + let lua = unsafe { Lua::new_with_debug() }; + let globals = lua.globals(); + + globals.set("factoid", code)?; + globals.set("download", lua.create_function(download)?)?; + globals.set("json_decode", lua.create_function(json_decode)?)?; + globals.set("sleep", lua.create_function(sleep)?)?; + globals.set("args", args)?; + globals.set("input", command.tokens.join(" "))?; + globals.set("user", command.source.clone())?; + globals.set("channel", command.target.clone())?; + globals.set("output", lua.create_table()?)?; + + lua.exec::<()>(LUA_SANDBOX, Some(name))?; + let output: Vec = globals.get::<_, Vec>("output")?; + + Ok(output.join("|")) + } + + fn help(&self) -> &str { + "usage: factoids \r\n\ + subcommands: add, fromurl, remove, get, info, exec, help" + } +} + +impl Plugin for Factoid { + type Client = C; + fn execute(&self, _: &Self::Client, message: &Message) -> ExecutionStatus { + match message.command { + Command::PRIVMSG(_, ref content) => if content.starts_with('!') { + ExecutionStatus::RequiresThread + } else { + ExecutionStatus::Done + }, + _ => ExecutionStatus::Done, + } + } + + fn execute_threaded( + &self, + client: &Self::Client, + message: &Message, + ) -> Result<(), FrippyError> { + if let Command::PRIVMSG(_, mut content) = message.command.clone() { + content.remove(0); + + let t: Vec = content.split(' ').map(ToOwned::to_owned).collect(); + + let c = PluginCommand { + source: message.source_nickname().unwrap().to_owned(), + target: message.response_target().unwrap().to_owned(), + tokens: t, + }; + + if let Ok(f) = self.exec(c) { + client + .send_privmsg(&message.response_target().unwrap(), &f) + .context(FrippyErrorKind::Connection)?; + } + } + + Ok(()) + } + + fn command( + &self, + client: &Self::Client, + mut command: PluginCommand, + ) -> Result<(), FrippyError> { + use self::FactoidResponse::{Private, Public}; + + if command.tokens.is_empty() { + client + .send_notice(&command.source, "Invalid command") + .context(FrippyErrorKind::Connection)?; + + return Ok(()); + } + + let target = command.target.clone(); + let source = command.source.clone(); + + let sub_command = command.tokens.remove(0); + let result = match sub_command.as_ref() { + "add" => self.add(&mut command).map(|s| Private(s.to_owned())), + "fromurl" => self + .add_from_url(&mut command) + .map(|s| Private(s.to_owned())), + "remove" => self.remove(&mut command).map(|s| Private(s.to_owned())), + "get" => self.get(&command).map(Public), + "info" => self.info(&command).map(Public), + "exec" => self.exec(command).map(Public), + "help" => Ok(Private(self.help().to_owned())), + _ => Err(ErrorKind::InvalidCommand.into()), + }; + + match result { + Ok(v) => match v { + Public(m) => client + .send_privmsg(&target, &m) + .context(FrippyErrorKind::Connection)?, + Private(m) => client + .send_notice(&source, &m) + .context(FrippyErrorKind::Connection)?, + }, + Err(e) => { + let message = e.to_string(); + client + .send_notice(&source, &message) + .context(FrippyErrorKind::Connection)?; + Err(e).context(FrippyErrorKind::Factoid)? + } + } + + Ok(()) + } + + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { + Err(String::from( + "Evaluation of commands is not implemented for Factoid at this time", + )) + } +} + +impl fmt::Debug for Factoid { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Factoid {{ ... }}") + } +} + +pub mod error { + #[derive(Copy, Clone, Eq, PartialEq, Debug, Fail, Error)] + #[error = "FactoidError"] + pub enum ErrorKind { + /// Invalid command error + #[fail(display = "Invalid Command")] + InvalidCommand, + + /// Invalid index error + #[fail(display = "Invalid index")] + InvalidIndex, + + /// Download error + #[fail(display = "Download failed")] + Download, + + /// Duplicate error + #[fail(display = "Entry already exists")] + Duplicate, + + /// Not found error + #[fail(display = "Factoid was not found")] + NotFound, + + /// MySQL error + #[cfg(feature = "mysql")] + #[fail(display = "Failed to execute MySQL Query")] + MysqlError, + + /// No connection error + #[cfg(feature = "mysql")] + #[fail(display = "No connection to the database")] + NoConnection, + } +} diff --git a/src/plugins/factoid/sandbox.lua b/src/plugins/factoid/sandbox.lua new file mode 100644 index 0000000..a927535 --- /dev/null +++ b/src/plugins/factoid/sandbox.lua @@ -0,0 +1,126 @@ +function send(text) + local text = tostring(text) + local len = #output + if len < 1 then + output = { text } + else + output[len] = output[len] .. text + end +end + +function sendln(text) + send(text) + table.insert(output, "") +end + +function trim(s) + local from = s:match"^%s*()" + return from > #s and "" or s:match(".*%S", from) +end + +trimmedInput = trim(input) + +if trimmedInput == "" then + ioru = user +else + ioru = trimmedInput +end + +local sandbox_env = { + print = send, + println = sendln, + trim = trim, + eval = nil, + sleep = nil, + json = {decode = json_decode}, + args = args, + input = input, + user = user, + ioru = ioru, + channel = channel, + request = download, + string = string, + math = math, + table = table, + pairs = pairs, + ipairs = ipairs, + next = next, + select = select, + unpack = unpack, + tostring = tostring, + tonumber = tonumber, + type = type, + assert = assert, + error = error, + pcall = pcall, + xpcall = xpcall, + _VERSION = _VERSION +} + +sandbox_env.os = { + clock = os.clock, + time = os.time, + difftime = os.difftime +} + +sandbox_env.string.rep = nil +sandbox_env.string.dump = nil +sandbox_env.math.randomseed = nil + +-- Temporary evaluation function +function eval(code) + local c, e = load(code, nil, nil, sandbox_env) + if c then + return c() + else + error(e) + end +end + +-- Only sleeps for 1 second at a time +-- This ensures that the timeout check can still run +function safesleep(dur) + while dur > 1000 do + dur = dur - 1000 + sleep(1000) + end + sleep(dur) +end + +sandbox_env.eval = eval +sandbox_env.sleep = safesleep + +-- Check if the factoid timed out +function checktime() + if os.time() - time >= timeout then + error("Timed out after " .. timeout .. " seconds", 0) + else + -- Limit the cpu usage of factoids + sleep(1) + end +end + +-- Check if the factoid uses too much memory +function checkmem() + if collectgarbage("count") > maxmem then + error("Factoid used over " .. maxmem .. " kbyte of ram") + end +end + +local f, e = load(factoid, nil, nil, sandbox_env) + +-- Add timeout hook +time = os.time() +-- The timeout is defined in seconds +timeout = 30 +debug.sethook(checktime, "l") +-- Add memory check hook +-- The max memory is defined in kilobytes +maxmem = 1000 +debug.sethook(checkmem, "l") + +if f then + f() +else + error(e) +end diff --git a/src/plugins/factoid/utils.rs b/src/plugins/factoid/utils.rs new file mode 100644 index 0000000..7bd9b20 --- /dev/null +++ b/src/plugins/factoid/utils.rs @@ -0,0 +1,82 @@ +use std::thread; +use std::time::Duration; + +use serde_json::{self, Value as SerdeValue}; + +use super::rlua::Error as LuaError; +use super::rlua::Error::RuntimeError; +use super::rlua::{Lua, Value as LuaValue}; + +use utils::error::ErrorKind::Connection; +use utils::Url; + +use failure::Fail; + +pub fn sleep(_: &Lua, dur: u64) -> Result<(), LuaError> { + thread::sleep(Duration::from_millis(dur)); + Ok(()) +} + +pub fn download(_: &Lua, url: String) -> Result { + let url = Url::from(url).max_kib(1024); + match url.request() { + Ok(v) => Ok(v), + Err(e) => { + let error = match e.kind() { + Connection => e.cause().unwrap().to_string(), + _ => e.to_string(), + }; + + Err(RuntimeError(format!( + "Failed to download {} - {}", + url.as_str(), + error + ))) + } + } +} + +fn convert_value(lua: &Lua, sval: SerdeValue, max_recurs: usize) -> Result { + if max_recurs == 0 { + return Err(RuntimeError(String::from( + "Reached max recursion level - json is nested too deep", + ))); + } + + let lval = match sval { + SerdeValue::Null => LuaValue::Nil, + SerdeValue::Bool(b) => LuaValue::Boolean(b), + SerdeValue::String(s) => LuaValue::String(lua.create_string(&s)?), + SerdeValue::Number(n) => { + let f = n.as_f64().ok_or_else(|| { + RuntimeError(String::from("Failed to convert number into double")) + })?; + LuaValue::Number(f) + } + SerdeValue::Array(arr) => { + let table = lua.create_table()?; + for (i, val) in arr.into_iter().enumerate() { + table.set(i + 1, convert_value(lua, val, max_recurs - 1)?)?; + } + + LuaValue::Table(table) + } + SerdeValue::Object(obj) => { + let table = lua.create_table()?; + for (key, val) in obj { + table.set(key, convert_value(lua, val, max_recurs - 1)?)?; + } + + LuaValue::Table(table) + } + }; + + Ok(lval) +} + +pub fn json_decode(lua: &Lua, json: String) -> Result { + let ser_val: SerdeValue = + serde_json::from_str(&json).map_err(|e| RuntimeError(e.to_string()))?; + + convert_value(lua, ser_val, 25) +} diff --git a/src/plugins/factoids/database.rs b/src/plugins/factoids/database.rs deleted file mode 100644 index ec8ed3e..0000000 --- a/src/plugins/factoids/database.rs +++ /dev/null @@ -1,160 +0,0 @@ -use std::collections::HashMap; -#[cfg(feature = "mysql")] -use std::sync::Arc; - -#[cfg(feature = "mysql")] -use diesel::mysql::MysqlConnection; -#[cfg(feature = "mysql")] -use diesel::prelude::*; -#[cfg(feature = "mysql")] -use failure::ResultExt; -#[cfg(feature = "mysql")] -use r2d2::Pool; -#[cfg(feature = "mysql")] -use r2d2_diesel::ConnectionManager; - -use chrono::NaiveDateTime; - -use super::error::*; - -#[cfg_attr(feature = "mysql", derive(Queryable))] -#[derive(Clone, Debug)] -pub struct Factoid { - pub name: String, - pub idx: i32, - pub content: String, - pub author: String, - pub created: NaiveDateTime, -} - -#[cfg_attr(feature = "mysql", derive(Insertable))] -#[cfg_attr(feature = "mysql", table_name = "factoids")] -pub struct NewFactoid<'a> { - pub name: &'a str, - pub idx: i32, - pub content: &'a str, - pub author: &'a str, - pub created: NaiveDateTime, -} - -pub trait Database: Send + Sync { - fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidsError>; - fn get_factoid(&self, name: &str, idx: i32) -> Result; - fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidsError>; - fn count_factoids(&self, name: &str) -> Result; -} - -// HashMap -impl Database for HashMap<(String, i32), Factoid, S> { - fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidsError> { - let factoid = Factoid { - name: factoid.name.to_owned(), - idx: factoid.idx, - content: factoid.content.to_owned(), - author: factoid.author.to_owned(), - created: factoid.created, - }; - - let name = factoid.name.clone(); - match self.insert((name, factoid.idx), factoid) { - None => Ok(()), - Some(_) => Err(ErrorKind::Duplicate)?, - } - } - - fn get_factoid(&self, name: &str, idx: i32) -> Result { - Ok(self.get(&(name.to_owned(), idx)) - .cloned() - .ok_or(ErrorKind::NotFound)?) - } - - fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidsError> { - match self.remove(&(name.to_owned(), idx)) { - Some(_) => Ok(()), - None => Err(ErrorKind::NotFound)?, - } - } - - fn count_factoids(&self, name: &str) -> Result { - Ok(self.iter().filter(|&(&(ref n, _), _)| n == name).count() as i32) - } -} - -// Diesel automatically defines the factoids module as public. -// We create a schema module to keep it private. -#[cfg(feature = "mysql")] -mod schema { - table! { - factoids (name, idx) { - name -> Varchar, - idx -> Integer, - content -> Text, - author -> Varchar, - created -> Timestamp, - } - } -} - -#[cfg(feature = "mysql")] -use self::schema::factoids; - -#[cfg(feature = "mysql")] -impl Database for Arc>> { - fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidsError> { - use diesel; - - let conn = &*self.get().context(ErrorKind::NoConnection)?; - diesel::insert_into(factoids::table) - .values(factoid) - .execute(conn) - .context(ErrorKind::MysqlError)?; - - Ok(()) - } - - fn get_factoid(&self, name: &str, idx: i32) -> Result { - let conn = &*self.get().context(ErrorKind::NoConnection)?; - Ok(factoids::table - .find((name, idx)) - .first(conn) - .context(ErrorKind::MysqlError)?) - } - - fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidsError> { - use self::factoids::columns; - use diesel; - - let conn = &*self.get().context(ErrorKind::NoConnection)?; - match diesel::delete( - factoids::table - .filter(columns::name.eq(name)) - .filter(columns::idx.eq(idx)), - ).execute(conn) - { - Ok(v) => { - if v > 0 { - Ok(()) - } else { - Err(ErrorKind::NotFound)? - } - } - Err(e) => Err(e).context(ErrorKind::MysqlError)?, - } - } - - fn count_factoids(&self, name: &str) -> Result { - use diesel; - - let conn = &*self.get().context(ErrorKind::NoConnection)?; - let count: Result = factoids::table - .filter(factoids::columns::name.eq(name)) - .count() - .get_result(conn); - - match count { - Ok(c) => Ok(c as i32), - Err(diesel::NotFound) => Ok(0), - Err(e) => Err(e).context(ErrorKind::MysqlError)?, - } - } -} diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs deleted file mode 100644 index a3d521a..0000000 --- a/src/plugins/factoids/mod.rs +++ /dev/null @@ -1,373 +0,0 @@ -extern crate rlua; - -use self::rlua::prelude::*; -use antidote::RwLock; -use irc::client::prelude::*; -use std::fmt; -use std::marker::PhantomData; -use std::str::FromStr; - -use chrono::NaiveDateTime; -use time; - -use plugin::*; -use FrippyClient; -pub mod database; -use self::database::Database; - -mod utils; -use self::utils::*; -use utils::Url; - -use self::error::*; -use error::ErrorKind as FrippyErrorKind; -use error::FrippyError; -use failure::ResultExt; - -static LUA_SANDBOX: &'static str = include_str!("sandbox.lua"); - -enum FactoidResponse { - Public(String), - Private(String), -} - -#[derive(PluginName)] -pub struct Factoids { - factoids: RwLock, - phantom: PhantomData, -} - -impl Factoids { - pub fn new(db: T) -> Self { - Factoids { - factoids: RwLock::new(db), - phantom: PhantomData, - } - } - - fn create_factoid( - &self, - name: &str, - content: &str, - author: &str, - ) -> Result<&str, FactoidsError> { - let count = self.factoids.read().count_factoids(name)?; - let tm = time::now().to_timespec(); - - let factoid = database::NewFactoid { - name, - idx: count, - content, - author, - created: NaiveDateTime::from_timestamp(tm.sec, 0u32), - }; - - Ok(self.factoids - .write() - .insert_factoid(&factoid) - .map(|()| "Successfully added!")?) - } - - fn add(&self, command: &mut PluginCommand) -> Result<&str, FactoidsError> { - if command.tokens.len() < 2 { - Err(ErrorKind::InvalidCommand)?; - } - - let name = command.tokens.remove(0); - let content = command.tokens.join(" "); - - Ok(self.create_factoid(&name, &content, &command.source)?) - } - - fn add_from_url(&self, command: &mut PluginCommand) -> Result<&str, FactoidsError> { - if command.tokens.len() < 2 { - Err(ErrorKind::InvalidCommand)?; - } - - let name = command.tokens.remove(0); - let url = &command.tokens[0]; - let content = Url::from(url.as_ref()) - .max_kib(1024) - .request() - .context(ErrorKind::Download)?; - - Ok(self.create_factoid(&name, &content, &command.source)?) - } - - fn remove(&self, command: &mut PluginCommand) -> Result<&str, FactoidsError> { - if command.tokens.is_empty() { - Err(ErrorKind::InvalidCommand)?; - } - - let name = command.tokens.remove(0); - let count = self.factoids.read().count_factoids(&name)?; - - match self.factoids.write().delete_factoid(&name, count - 1) { - Ok(()) => Ok("Successfully removed"), - Err(e) => Err(e)?, - } - } - - fn get(&self, command: &PluginCommand) -> Result { - let (name, idx) = match command.tokens.len() { - 0 => Err(ErrorKind::InvalidCommand)?, - 1 => { - let name = &command.tokens[0]; - let count = self.factoids.read().count_factoids(name)?; - - if count < 1 { - Err(ErrorKind::NotFound)?; - } - - (name, count - 1) - } - _ => { - let name = &command.tokens[0]; - let idx = match i32::from_str(&command.tokens[1]) { - Ok(i) => i, - Err(_) => Err(ErrorKind::InvalidCommand)?, - }; - - (name, idx) - } - }; - - let factoid = self.factoids - .read() - .get_factoid(name, idx) - .context(ErrorKind::NotFound)?; - - let message = factoid.content.replace("\n", "|").replace("\r", ""); - - Ok(format!("{}: {}", factoid.name, message)) - } - - fn info(&self, command: &PluginCommand) -> Result { - match command.tokens.len() { - 0 => Err(ErrorKind::InvalidCommand)?, - 1 => { - let name = &command.tokens[0]; - let count = self.factoids.read().count_factoids(name)?; - - Ok(match count { - 0 => Err(ErrorKind::NotFound)?, - 1 => format!("There is 1 version of {}", name), - _ => format!("There are {} versions of {}", count, name), - }) - } - _ => { - let name = &command.tokens[0]; - let idx = i32::from_str(&command.tokens[1]).context(ErrorKind::InvalidIndex)?; - let factoid = self.factoids.read().get_factoid(name, idx)?; - - Ok(format!( - "{}: Added by {} at {} UTC", - name, factoid.author, factoid.created - )) - } - } - } - - fn exec(&self, mut command: PluginCommand) -> Result { - if command.tokens.is_empty() { - Err(ErrorKind::InvalidIndex)? - } else { - let name = command.tokens.remove(0); - let count = self.factoids.read().count_factoids(&name)?; - let factoid = self.factoids.read().get_factoid(&name, count - 1)?; - - let content = factoid.content; - let value = if content.starts_with('>') { - let content = String::from(&content[1..]); - - if content.starts_with('>') { - content - } else { - match self.run_lua(&name, &content, &command) { - Ok(v) => v, - Err(e) => match e { - LuaError::CallbackError { cause, .. } => cause.to_string(), - _ => e.to_string(), - }, - } - } - } else { - content - }; - - Ok(value.replace("\n", "|").replace("\r", "")) - } - } - - fn run_lua(&self, name: &str, code: &str, command: &PluginCommand) -> Result { - let args = command - .tokens - .iter() - .filter(|x| !x.is_empty()) - .map(ToOwned::to_owned) - .collect::>(); - - let lua = unsafe { Lua::new_with_debug() }; - let globals = lua.globals(); - - globals.set("factoid", code)?; - globals.set("download", lua.create_function(download)?)?; - globals.set("json_decode", lua.create_function(json_decode)?)?; - globals.set("sleep", lua.create_function(sleep)?)?; - globals.set("args", args)?; - globals.set("input", command.tokens.join(" "))?; - globals.set("user", command.source.clone())?; - globals.set("channel", command.target.clone())?; - globals.set("output", lua.create_table()?)?; - - lua.exec::<()>(LUA_SANDBOX, Some(name))?; - let output: Vec = globals.get::<_, Vec>("output")?; - - Ok(output.join("|")) - } - - fn help(&self) -> &str { - "usage: factoids \r\n\ - subcommands: add, fromurl, remove, get, info, exec, help" - } -} - -impl Plugin for Factoids { - type Client = C; - fn execute(&self, _: &Self::Client, message: &Message) -> ExecutionStatus { - match message.command { - Command::PRIVMSG(_, ref content) => if content.starts_with('!') { - ExecutionStatus::RequiresThread - } else { - ExecutionStatus::Done - }, - _ => ExecutionStatus::Done, - } - } - - fn execute_threaded( - &self, - client: &Self::Client, - message: &Message, - ) -> Result<(), FrippyError> { - if let Command::PRIVMSG(_, mut content) = message.command.clone() { - content.remove(0); - - let t: Vec = content.split(' ').map(ToOwned::to_owned).collect(); - - let c = PluginCommand { - source: message.source_nickname().unwrap().to_owned(), - target: message.response_target().unwrap().to_owned(), - tokens: t, - }; - - if let Ok(f) = self.exec(c) { - client - .send_privmsg(&message.response_target().unwrap(), &f) - .context(FrippyErrorKind::Connection)?; - } - } - - Ok(()) - } - - fn command( - &self, - client: &Self::Client, - mut command: PluginCommand, - ) -> Result<(), FrippyError> { - use self::FactoidResponse::{Private, Public}; - - if command.tokens.is_empty() { - client - .send_notice(&command.source, "Invalid command") - .context(FrippyErrorKind::Connection)?; - - return Ok(()); - } - - let target = command.target.clone(); - let source = command.source.clone(); - - let sub_command = command.tokens.remove(0); - let result = match sub_command.as_ref() { - "add" => self.add(&mut command).map(|s| Private(s.to_owned())), - "fromurl" => self.add_from_url(&mut command) - .map(|s| Private(s.to_owned())), - "remove" => self.remove(&mut command).map(|s| Private(s.to_owned())), - "get" => self.get(&command).map(Public), - "info" => self.info(&command).map(Public), - "exec" => self.exec(command).map(Public), - "help" => Ok(Private(self.help().to_owned())), - _ => Err(ErrorKind::InvalidCommand.into()), - }; - - match result { - Ok(v) => match v { - Public(m) => client - .send_privmsg(&target, &m) - .context(FrippyErrorKind::Connection)?, - Private(m) => client - .send_notice(&source, &m) - .context(FrippyErrorKind::Connection)?, - }, - Err(e) => { - let message = e.to_string(); - client - .send_notice(&source, &message) - .context(FrippyErrorKind::Connection)?; - Err(e).context(FrippyErrorKind::Factoids)? - } - } - - Ok(()) - } - - fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result { - Err(String::from( - "Evaluation of commands is not implemented for Factoids at this time", - )) - } -} - -impl fmt::Debug for Factoids { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Factoids {{ ... }}") - } -} - -pub mod error { - #[derive(Copy, Clone, Eq, PartialEq, Debug, Fail, Error)] - #[error = "FactoidsError"] - pub enum ErrorKind { - /// Invalid command error - #[fail(display = "Invalid Command")] - InvalidCommand, - - /// Invalid index error - #[fail(display = "Invalid index")] - InvalidIndex, - - /// Download error - #[fail(display = "Download failed")] - Download, - - /// Duplicate error - #[fail(display = "Entry already exists")] - Duplicate, - - /// Not found error - #[fail(display = "Factoid was not found")] - NotFound, - - /// MySQL error - #[cfg(feature = "mysql")] - #[fail(display = "Failed to execute MySQL Query")] - MysqlError, - - /// No connection error - #[cfg(feature = "mysql")] - #[fail(display = "No connection to the database")] - NoConnection, - } -} diff --git a/src/plugins/factoids/sandbox.lua b/src/plugins/factoids/sandbox.lua deleted file mode 100644 index a927535..0000000 --- a/src/plugins/factoids/sandbox.lua +++ /dev/null @@ -1,126 +0,0 @@ -function send(text) - local text = tostring(text) - local len = #output - if len < 1 then - output = { text } - else - output[len] = output[len] .. text - end -end - -function sendln(text) - send(text) - table.insert(output, "") -end - -function trim(s) - local from = s:match"^%s*()" - return from > #s and "" or s:match(".*%S", from) -end - -trimmedInput = trim(input) - -if trimmedInput == "" then - ioru = user -else - ioru = trimmedInput -end - -local sandbox_env = { - print = send, - println = sendln, - trim = trim, - eval = nil, - sleep = nil, - json = {decode = json_decode}, - args = args, - input = input, - user = user, - ioru = ioru, - channel = channel, - request = download, - string = string, - math = math, - table = table, - pairs = pairs, - ipairs = ipairs, - next = next, - select = select, - unpack = unpack, - tostring = tostring, - tonumber = tonumber, - type = type, - assert = assert, - error = error, - pcall = pcall, - xpcall = xpcall, - _VERSION = _VERSION -} - -sandbox_env.os = { - clock = os.clock, - time = os.time, - difftime = os.difftime -} - -sandbox_env.string.rep = nil -sandbox_env.string.dump = nil -sandbox_env.math.randomseed = nil - --- Temporary evaluation function -function eval(code) - local c, e = load(code, nil, nil, sandbox_env) - if c then - return c() - else - error(e) - end -end - --- Only sleeps for 1 second at a time --- This ensures that the timeout check can still run -function safesleep(dur) - while dur > 1000 do - dur = dur - 1000 - sleep(1000) - end - sleep(dur) -end - -sandbox_env.eval = eval -sandbox_env.sleep = safesleep - --- Check if the factoid timed out -function checktime() - if os.time() - time >= timeout then - error("Timed out after " .. timeout .. " seconds", 0) - else - -- Limit the cpu usage of factoids - sleep(1) - end -end - --- Check if the factoid uses too much memory -function checkmem() - if collectgarbage("count") > maxmem then - error("Factoid used over " .. maxmem .. " kbyte of ram") - end -end - -local f, e = load(factoid, nil, nil, sandbox_env) - --- Add timeout hook -time = os.time() --- The timeout is defined in seconds -timeout = 30 -debug.sethook(checktime, "l") --- Add memory check hook --- The max memory is defined in kilobytes -maxmem = 1000 -debug.sethook(checkmem, "l") - -if f then - f() -else - error(e) -end diff --git a/src/plugins/factoids/utils.rs b/src/plugins/factoids/utils.rs deleted file mode 100644 index a35dd27..0000000 --- a/src/plugins/factoids/utils.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::thread; -use std::time::Duration; - -use serde_json::{self, Value as SerdeValue}; - -use super::rlua::Error as LuaError; -use super::rlua::Error::RuntimeError; -use super::rlua::{Lua, Value as LuaValue}; - -use utils::error::ErrorKind::Connection; -use utils::Url; - -use failure::Fail; - -pub fn sleep(_: &Lua, dur: u64) -> Result<(), LuaError> { - thread::sleep(Duration::from_millis(dur)); - Ok(()) -} - -pub fn download(_: &Lua, url: String) -> Result { - let url = Url::from(url).max_kib(1024); - match url.request() { - Ok(v) => Ok(v), - Err(e) => { - let error = match e.kind() { - Connection => e.cause().unwrap().to_string(), - _ => e.to_string(), - }; - - Err(RuntimeError(format!( - "Failed to download {} - {}", - url.as_str(), - error - ))) - } - } -} - -fn convert_value(lua: &Lua, sval: SerdeValue, max_recurs: usize) -> Result { - if max_recurs == 0 { - return Err(RuntimeError(String::from( - "Reached max recursion level - json is nested too deep", - ))); - } - - let lval = match sval { - SerdeValue::Null => LuaValue::Nil, - SerdeValue::Bool(b) => LuaValue::Boolean(b), - SerdeValue::String(s) => LuaValue::String(lua.create_string(&s)?), - SerdeValue::Number(n) => { - let f = n.as_f64().ok_or_else(|| RuntimeError(String::from( - "Failed to convert number into double", - )))?; - LuaValue::Number(f) - } - SerdeValue::Array(arr) => { - let table = lua.create_table()?; - for (i, val) in arr.into_iter().enumerate() { - table.set(i + 1, convert_value(lua, val, max_recurs - 1)?)?; - } - - LuaValue::Table(table) - } - SerdeValue::Object(obj) => { - let table = lua.create_table()?; - for (key, val) in obj { - table.set(key, convert_value(lua, val, max_recurs - 1)?)?; - } - - LuaValue::Table(table) - } - }; - - Ok(lval) -} - -pub fn json_decode(lua: &Lua, json: String) -> Result { - let ser_val: SerdeValue = serde_json::from_str(&json).map_err(|e| RuntimeError(e.to_string()))?; - - convert_value(lua, ser_val, 25) -} diff --git a/src/plugins/mod.rs b/src/plugins/mod.rs index e3bda60..8aa19a0 100644 --- a/src/plugins/mod.rs +++ b/src/plugins/mod.rs @@ -1,9 +1,9 @@ //! Collection of plugins included pub mod emoji; -pub mod factoids; -pub mod quote; +pub mod factoid; pub mod help; pub mod keepnick; +pub mod quote; pub mod remind; pub mod sed; pub mod tell; -- cgit v1.2.3-70-g09d2 From 869b22874fb64935bff0f25f9a5dacb18b9d1548 Mon Sep 17 00:00:00 2001 From: Jokler Date: Wed, 20 Feb 2019 22:53:56 +0100 Subject: Plugins: Replace Emoji with Unicode The new plugin adds a command which allows checking the name and some info of a character. --- src/main.rs | 4 +- src/plugins/emoji.rs | 152 ------------------------------------------------- src/plugins/mod.rs | 2 +- src/plugins/unicode.rs | 100 ++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 155 deletions(-) delete mode 100644 src/plugins/emoji.rs create mode 100644 src/plugins/unicode.rs (limited to 'src/plugins/emoji.rs') diff --git a/src/main.rs b/src/main.rs index 03f3c7e..ef24e4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ use std::sync::Arc; use glob::glob; use irc::client::reactor::IrcReactor; -use frippy::plugins::emoji::Emoji; +use frippy::plugins::unicode::Unicode; use frippy::plugins::factoid::Factoid; use frippy::plugins::help::Help; use frippy::plugins::keepnick::KeepNick; @@ -108,7 +108,7 @@ fn run() -> Result<(), Error> { bot.add_plugin(Help::new()); bot.add_plugin(UrlTitles::new(1024)); bot.add_plugin(Sed::new(60)); - bot.add_plugin(Emoji::new()); + bot.add_plugin(Unicode::new()); bot.add_plugin(KeepNick::new()); #[cfg(feature = "mysql")] diff --git a/src/plugins/emoji.rs b/src/plugins/emoji.rs deleted file mode 100644 index aee61b1..0000000 --- a/src/plugins/emoji.rs +++ /dev/null @@ -1,152 +0,0 @@ -extern crate unicode_names; - -use std::fmt; -use std::marker::PhantomData; - -use irc::client::prelude::*; - -use plugin::*; -use FrippyClient; - -use error::ErrorKind as FrippyErrorKind; -use error::FrippyError; -use failure::Fail; -use failure::ResultExt; - -#[derive(Default, Debug)] -struct EmojiHandle { - symbol: char, - count: i32, -} - -impl fmt::Display for EmojiHandle { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let name = match unicode_names::name(self.symbol) { - Some(sym) => sym.to_string().to_lowercase(), - None => String::from("UNKNOWN"), - }; - - if self.count > 1 { - write!(f, "{}x {}", self.count, name) - } else { - write!(f, "{}", name) - } - } -} - -#[derive(PluginName, Default, Debug)] -pub struct Emoji { - phantom: PhantomData, -} - -impl Emoji { - pub fn new() -> Self { - Emoji { - phantom: PhantomData, - } - } - - fn emoji(&self, content: &str) -> Option { - let emojis = self.return_emojis(content); - if emojis.is_empty() { - None - } else { - Some( - emojis - .iter() - .map(|e| e.to_string()) - .collect::>() - .join(", "), - ) - } - } - - fn return_emojis(&self, string: &str) -> Vec { - let mut emojis: Vec = Vec::new(); - - let mut current = EmojiHandle::default(); - - for c in string.chars() { - if !self.is_emoji(c) { - continue; - } - - if current.symbol == c { - current.count += 1; - } else { - if current.count > 0 { - emojis.push(current); - } - - current = EmojiHandle { - symbol: c, - count: 1, - } - } - } - - if current.count > 0 { - emojis.push(current); - } - - emojis - } - - fn is_emoji(&self, c: char) -> bool { - // Emoji ranges from stackoverflow: - // https://stackoverflow.com/questions/30757193/find-out-if-character-in-string-is-emoji - match c { '\u{1F600}'...'\u{1F64F}' // Emoticons - | '\u{1F300}'...'\u{1F5FF}' // Misc Symbols and Pictographs - | '\u{1F680}'...'\u{1F6FF}' // Transport and Map - | '\u{2600}' ...'\u{26FF}' // Misc symbols - | '\u{2700}' ...'\u{27BF}' // Dingbats - | '\u{FE00}' ...'\u{FE0F}' // Variation Selectors - | '\u{1F900}'...'\u{1F9FF}' // Supplemental Symbols and Pictographs - | '\u{20D0}' ...'\u{20FF}' => true, // Combining Diacritical Marks for Symbols - _ => false, - } - } -} - -impl Plugin for Emoji { - type Client = C; - fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { - match message.command { - Command::PRIVMSG(_, ref content) => { - if let Some(emojis) = self.emoji(content) { - match client.send_privmsg(message.response_target().unwrap(), &emojis) { - Ok(_) => ExecutionStatus::Done, - Err(e) => { - ExecutionStatus::Err(e.context(FrippyErrorKind::Connection).into()) - } - } - } else { - ExecutionStatus::Done - } - } - _ => ExecutionStatus::Done, - } - } - - fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { - panic!("Emoji should not use threading") - } - - fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { - client - .send_notice( - &command.source, - "This Plugin does not implement any commands.", - ).context(FrippyErrorKind::Connection)?; - - Ok(()) - } - - fn evaluate(&self, _: &Self::Client, command: PluginCommand) -> Result { - if let Some(emojis) = self.emoji(&command.tokens[0]) { - Ok(emojis) - } else { - Err(String::from("No emojis were found.")) - } - } -} diff --git a/src/plugins/mod.rs b/src/plugins/mod.rs index 8aa19a0..0dfb011 100644 --- a/src/plugins/mod.rs +++ b/src/plugins/mod.rs @@ -1,5 +1,4 @@ //! Collection of plugins included -pub mod emoji; pub mod factoid; pub mod help; pub mod keepnick; @@ -7,4 +6,5 @@ pub mod quote; pub mod remind; pub mod sed; pub mod tell; +pub mod unicode; pub mod url; diff --git a/src/plugins/unicode.rs b/src/plugins/unicode.rs new file mode 100644 index 0000000..7633c2d --- /dev/null +++ b/src/plugins/unicode.rs @@ -0,0 +1,100 @@ +extern crate unicode_names; + +use std::marker::PhantomData; +use std::fmt; + +use irc::client::prelude::*; + +use plugin::*; +use FrippyClient; + +use error::ErrorKind as FrippyErrorKind; +use error::FrippyError; +use failure::Fail; +use failure::ResultExt; + +#[derive(PluginName, Default, Debug)] +pub struct Unicode { + phantom: PhantomData, +} + +impl Unicode { + pub fn new() -> Unicode { + Unicode { + phantom: PhantomData, + } + } + + fn get_name(&self, symbol: char) -> String { + match unicode_names::name(symbol) { + Some(sym) => sym.to_string().to_lowercase(), + None => String::from("UNKNOWN"), + } + } + + fn format_response(&self, content: &str) -> String { + let character = content.chars().next(); + if let Some(c) = character { + let mut buf = [0; 2]; + + let byte_string = c + .encode_utf8(&mut buf) + .as_bytes() + .iter() + .map(|b| format!("{:#b}", b)) + .collect::>() + .join(","); + + let name = self.get_name(c); + + format!( + "{} is '{}' | UTF-8: {2:#x} ({2}), Bytes: [{3}]", + c, name, c as u32, byte_string + ) + } else { + String::from("No non-space character was found.") + } + } +} + +impl Plugin for Unicode { + type Client = C; + + fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus { + ExecutionStatus::Done + } + + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { + panic!("Unicode should not use threading") + } + + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { + if command.tokens.is_empty() { + let msg = "No non-space character was found."; + + if let Err(e) = client.send_notice(command.source, msg) { + Err(e.context(FrippyErrorKind::Connection))?; + } + + return Ok(()); + } + + let content = &command.tokens[0]; + + if let Err(e) = client.send_privmsg(command.target, &self.format_response(&content)) { + Err(e.context(FrippyErrorKind::Connection))?; + } + + Ok(()) + } + + fn evaluate(&self, _: &Self::Client, command: PluginCommand) -> Result { + let tokens = command.tokens; + + if tokens.is_empty() { + return Err(String::from("No non-space character was found.")); + } + + Ok(self.format_response(&tokens[0])) + } +} -- cgit v1.2.3-70-g09d2