diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-03-20 20:06:04 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-03-20 20:06:04 +0100 |
| commit | ad14a3807eef4faa0690c269646142e24934afd0 (patch) | |
| tree | d9cf62109e09f4e594b5fbc93ab4a19c5733ad7a /src | |
| parent | 1ddb6dc9017e599295b768c91c5366ee4727bc28 (diff) | |
| download | frippy-ad14a3807eef4faa0690c269646142e24934afd0.tar.gz frippy-ad14a3807eef4faa0690c269646142e24934afd0.zip | |
Add sleep to factoids
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/factoids/mod.rs | 2 | ||||
| -rw-r--r-- | src/plugins/factoids/sandbox.lua | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs index 2f3690f..d09313c 100644 --- a/src/plugins/factoids/mod.rs +++ b/src/plugins/factoids/mod.rs @@ -179,7 +179,7 @@ impl<T: Database> Factoids<T> { } else { match self.run_lua(&name, &content, &command) { Ok(v) => v, - Err(e) => format!("\"{}\"", e), + Err(e) => format!("{}", e), } } } else { diff --git a/src/plugins/factoids/sandbox.lua b/src/plugins/factoids/sandbox.lua index 3fc74cd..6fcabef 100644 --- a/src/plugins/factoids/sandbox.lua +++ b/src/plugins/factoids/sandbox.lua @@ -17,6 +17,7 @@ local sandbox_env = { print = send, println = sendln, eval = nil, + sleep = nil, args = args, input = input, user = user, @@ -60,7 +61,18 @@ function eval(code) end end +-- Only sleeps for 1 second at a time +-- This ensures that the timeout check can still run +function safesleep(dur) + while dur > 1000 do + dur = dur - 1000 + sleep(1000) + end + sleep(dur) +end + sandbox_env.eval = eval +sandbox_env.sleep = safesleep -- Check if the factoid timed out function checktime(event, line) |
