summaryrefslogtreecommitdiffstats
path: root/src/plugins/factoids/mod.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2017-11-04 22:46:39 +0100
committerJokler <jokler.contact@gmail.com>2017-12-24 00:40:06 +0100
commit5928afc3bf83661cd3b11130a31a2d97ef135a9e (patch)
tree4d1ad028c3a7130eb98c18ef5b97bea9f52f2e2f /src/plugins/factoids/mod.rs
parentf3d679da59a64711ef96042668b26dffd1e662d5 (diff)
downloadfrippy-5928afc3bf83661cd3b11130a31a2d97ef135a9e.tar.gz
frippy-5928afc3bf83661cd3b11130a31a2d97ef135a9e.zip
Add MySql as a possible database for the Factoids plugin
Diffstat (limited to 'src/plugins/factoids/mod.rs')
-rw-r--r--src/plugins/factoids/mod.rs16
1 files changed, 11 insertions, 5 deletions
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<T: Database> {
factoids: Mutex<T>,
}
@@ -40,7 +41,7 @@ impl<T: Database> Factoids<T> {
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<T: Database> Factoids<T> {
}
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<T: Database> Factoids<T> {
}
}
} else {
- String::from(factoid)
+ factoid
};
server.send_privmsg(&command.target, &value)
@@ -170,3 +170,9 @@ impl<T: Database> Plugin for Factoids<T> {
}
}
}
+
+impl<T: Database> fmt::Debug for Factoids<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "Factoids {{ ... }}")
+ }
+}