From 5928afc3bf83661cd3b11130a31a2d97ef135a9e Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 4 Nov 2017 22:46:39 +0100 Subject: Add MySql as a possible database for the Factoids plugin --- src/plugins/factoids/mod.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/plugins/factoids/mod.rs') diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs index a13bba6..5f9f99a 100644 --- a/src/plugins/factoids/mod.rs +++ b/src/plugins/factoids/mod.rs @@ -1,5 +1,6 @@ extern crate rlua; +use std::fmt; use self::rlua::prelude::*; use irc::client::prelude::*; use irc::error::Error as IrcError; @@ -8,11 +9,11 @@ use std::sync::Mutex; use plugin::*; mod database; -use self::database::*; +use self::database::Database; static LUA_SANDBOX: &'static str = include_str!("sandbox.lua"); -#[derive(PluginName, Debug)] +#[derive(PluginName)] pub struct Factoids { factoids: Mutex, } @@ -40,7 +41,7 @@ impl Factoids { let name = command.tokens.remove(0); try_lock!(self.factoids) - .insert(name, command.tokens.join(" ")); + .insert(&name, &command.tokens.join(" ")); server.send_notice(&command.source, "Successfully added") } @@ -63,7 +64,6 @@ impl Factoids { } fn exec(&self, server: &IrcServer, mut command: PluginCommand) -> Result<(), IrcError> { - if command.tokens.len() < 1 { self.invalid_command(server, &command) @@ -88,7 +88,7 @@ impl Factoids { } } } else { - String::from(factoid) + factoid }; server.send_privmsg(&command.target, &value) @@ -170,3 +170,9 @@ impl Plugin for Factoids { } } } + +impl fmt::Debug for Factoids { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Factoids {{ ... }}") + } +} -- cgit v1.2.3-70-g09d2