aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/factoids/mod.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs
index 68b02e3..c69042f 100644
--- a/src/plugins/factoids/mod.rs
+++ b/src/plugins/factoids/mod.rs
@@ -9,6 +9,8 @@ use std::sync::Mutex;
use plugin::*;
+static LUA_SANDBOX: &'static str = include_str!("sandbox.lua");
+
#[derive(PluginName, Debug)]
pub struct Factoids {
factoids: Mutex<HashMap<String, String>>,
@@ -23,8 +25,6 @@ macro_rules! try_lock {
}
}
-static LUA_SANDBOX: &'static str = include_str!("sandbox.lua");
-
impl Factoids {
pub fn new() -> Factoids {
Factoids { factoids: Mutex::new(HashMap::new()) }
@@ -75,9 +75,19 @@ impl Factoids {
None => return self.invalid_command(server, &command),
};
- let value = match self.run_lua(&name, factoid, &command) {
- Ok(v) => v,
- Err(e) => format!("{}", e),
+ let value = if factoid.starts_with(">") {
+ let factoid = String::from(&factoid[1..]);
+
+ if factoid.starts_with(">") {
+ factoid
+ } else {
+ match self.run_lua(&name, &factoid, &command) {
+ Ok(v) => v,
+ Err(e) => format!("{}", e),
+ }
+ }
+ } else {
+ String::from(factoid)
};
server.send_privmsg(&command.target, &value)