diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-02-12 19:16:59 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-02-12 19:16:59 +0100 |
| commit | da5c2c8e4893bfb095a8e2122b943c4dca61c41d (patch) | |
| tree | 3bf1e64c4a128e6b0cb5d5172daf1e3398406715 /src/plugins/url.rs | |
| parent | ddf42bc0292b0befe2b2f47f3284d9ffeaf6f4b4 (diff) | |
| download | frippy-da5c2c8e4893bfb095a8e2122b943c4dca61c41d.tar.gz frippy-da5c2c8e4893bfb095a8e2122b943c4dca61c41d.zip | |
Replace is_allowed with a single-threaded execute function
The old execute got renamed to exeute_threaded.
Diffstat (limited to 'src/plugins/url.rs')
| -rw-r--r-- | src/plugins/url.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/plugins/url.rs b/src/plugins/url.rs index b980d3e..9ce5a6a 100644 --- a/src/plugins/url.rs +++ b/src/plugins/url.rs @@ -90,7 +90,7 @@ impl Url { } Err(e) => { debug!("Bad response from {:?}: ({})", url, e); - return None; + None } } } @@ -126,18 +126,22 @@ impl Url { } impl Plugin for Url { - fn is_allowed(&self, _: &IrcClient, message: &Message) -> bool { + fn execute(&self, _: &IrcClient, message: &Message) -> ExecutionStatus { match message.command { - Command::PRIVMSG(_, ref msg) => RE.is_match(msg), - _ => false, + Command::PRIVMSG(_, ref msg) => if RE.is_match(msg) { + ExecutionStatus::RequiresThread + } else { + ExecutionStatus::Done + }, + _ => ExecutionStatus::Done, } } - fn execute(&self, server: &IrcClient, message: &Message) -> Result<(), IrcError> { + fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), IrcError> { match message.command { Command::PRIVMSG(_, ref content) => { match self.url(content) { - Ok(title) => server.send_privmsg(&message.response_target().unwrap(), &title), + Ok(title) => client.send_privmsg(message.response_target().unwrap(), &title), Err(_) => Ok(()), } } @@ -145,13 +149,13 @@ impl Plugin for Url { } } - fn command(&self, server: &IrcClient, command: PluginCommand) -> Result<(), IrcError> { - server.send_notice(&command.source, + fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), IrcError> { + client.send_notice(&command.source, "This Plugin does not implement any commands.") } fn evaluate(&self, _: &IrcClient, command: PluginCommand) -> Result<String, String> { - self.url(&command.tokens[0]).map_err(|e| String::from(e)) + self.url(&command.tokens[0]).map_err(String::from) } } |
