aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugin.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-02-12 19:16:59 +0100
committerJokler <jokler.contact@gmail.com>2018-02-12 19:16:59 +0100
commitda5c2c8e4893bfb095a8e2122b943c4dca61c41d (patch)
tree3bf1e64c4a128e6b0cb5d5172daf1e3398406715 /src/plugin.rs
parentddf42bc0292b0befe2b2f47f3284d9ffeaf6f4b4 (diff)
downloadfrippy-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/plugin.rs')
-rw-r--r--src/plugin.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugin.rs b/src/plugin.rs
index 8785708..88fe3ce 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -4,13 +4,19 @@ use std::fmt;
use irc::client::prelude::*;
use irc::error::IrcError;
+pub enum ExecutionStatus {
+ Done,
+ Err(IrcError),
+ RequiresThread,
+}
+
/// `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 {
/// This should return true if the `Plugin` wants to do work on the message.
- fn is_allowed(&self, server: &IrcClient, message: &Message) -> bool;
+ fn execute(&self, server: &IrcClient, message: &Message) -> ExecutionStatus;
/// Handles messages which are not commands but still necessary.
- fn execute(&self, server: &IrcClient, message: &Message) -> Result<(), IrcError>;
+ fn execute_threaded(&self, server: &IrcClient, message: &Message) -> Result<(), IrcError>;
/// Handles any command directed at this plugin.
fn command(&self, server: &IrcClient, command: PluginCommand) -> Result<(), IrcError>;
/// Should work like command but return a String instead of sending messages to IRC.