aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-02-17 23:25:38 +0100
committerJokler <jokler.contact@gmail.com>2018-02-17 23:25:38 +0100
commit806614b5bf00581c9a564fcda4ecb760b6d27c6a (patch)
tree06e07701e20a6ef2055cb4ea97a6c6258ae356c8
parent0892425bf833c03765e2edba8d6fdb338ae68ed5 (diff)
downloadfrippy-806614b5bf00581c9a564fcda4ecb760b6d27c6a.tar.gz
frippy-806614b5bf00581c9a564fcda4ecb760b6d27c6a.zip
Improve factoid error handling
-rw-r--r--src/plugins/factoids/mod.rs6
-rw-r--r--src/plugins/factoids/sandbox.lua10
2 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs
index f857f85..252ba83 100644
--- a/src/plugins/factoids/mod.rs
+++ b/src/plugins/factoids/mod.rs
@@ -140,8 +140,10 @@ impl<T: Database> Factoids<T> {
}
};
+ let message = factoid.content.replace("\n", "|").replace("\r", "");
+
server.send_privmsg(&command.target,
- &format!("{}: {}", factoid.name, factoid.content))
+ &format!("{}: {}", factoid.name, message))
}
fn info(&self, server: &IrcServer, command: &PluginCommand) -> Result<(), IrcError> {
@@ -156,7 +158,7 @@ impl<T: Database> Factoids<T> {
};
match count {
- 0 => server.send_privmsg(&command.target, &format!("{} does not exist", name)),
+ 0 => server.send_notice(&command.source, &format!("{} does not exist", name)),
1 => {
server.send_privmsg(&command.target,
&format!("There is 1 version of {}", name))
diff --git a/src/plugins/factoids/sandbox.lua b/src/plugins/factoids/sandbox.lua
index 282a903..8ebf518 100644
--- a/src/plugins/factoids/sandbox.lua
+++ b/src/plugins/factoids/sandbox.lua
@@ -1,5 +1,6 @@
function send(text)
- len = #output
+ local text = tostring(text)
+ local len = #output
if len < 1 then
output = { text }
else
@@ -25,4 +26,9 @@ local env = { print = send,
tostring = tostring,
math = math }
-load(factoid, nil, nil, env)()
+local f, e = load(factoid, nil, nil, env)
+if f then
+ f()
+else
+ error(e)
+end