aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2017-12-15 19:27:43 +0100
committerJokler <jokler.contact@gmail.com>2017-12-15 19:27:43 +0100
commitb4c1722bbee9fa822a6063cbb0540c0a7fb2e430 (patch)
tree35c00055654603d7092b526e761b377e901cc1dd /src/lib.rs
parentd0a417cd9569d135a1dab0d49fe2f5dfbc65bad3 (diff)
downloadfrippy-b4c1722bbee9fa822a6063cbb0540c0a7fb2e430.tar.gz
frippy-b4c1722bbee9fa822a6063cbb0540c0a7fb2e430.zip
Add option for disabled plugins in the toml files
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4a511c3..d34a728 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -90,6 +90,22 @@ impl Bot {
self.plugins.add(plugin);
}
+ /// Removes a plugin based on its name.
+ /// The binary currently uses this to disable plugins
+ /// based on user configuration.
+ ///
+ /// # Examples
+ /// ```
+ /// use frippy::{plugins, Bot};
+ ///
+ /// let mut bot = frippy::Bot::new();
+ /// bot.add_plugin(plugins::Help::new());
+ /// bot.remove_plugin("Help");
+ /// ```
+ pub fn remove_plugin(&mut self, name: &str) -> Option<()> {
+ self.plugins.remove(name)
+ }
+
/// This connects the `Bot` to IRC and adds a task
/// to the Core that was supplied.
///
@@ -189,6 +205,10 @@ impl ThreadedPlugins {
self.plugins.insert(name, safe_plugin);
}
+ pub fn remove(&mut self, name: &str) -> Option<()> {
+ self.plugins.remove(&name.to_lowercase()).map(|_| ())
+ }
+
pub fn execute_plugins(&mut self, server: &IrcServer, message: Message) {
let message = Arc::new(message);