This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/rechner.lua

29 lines
628 B
Lua
Raw Normal View History

2015-05-11 20:02:19 +02:00
-- Function reference: http://mathjs.org/docs/reference/functions/categorical.html
local function mathjs(exp)
local url = 'http://api.mathjs.org/v1/'
url = url..'?expr='..URL.escape(exp)
local b,c = http.request(url)
local text = nil
if c == 200 then
text = 'Das Ergebnis ist '..b
elseif c == 400 then
text = b
else
text = 'Unexpected error\n'
..'Is api.mathjs.org up?'
end
return text
end
local function run(msg, matches)
return mathjs(matches[1])
2015-04-14 22:20:26 +02:00
end
return {
description = "Ein simpler Taschenrechner",
2015-04-28 17:49:11 +02:00
usage = {"/calc [Rechnung]"},
2015-04-20 18:52:25 +02:00
patterns = {"^/calc (.*)$"},
2015-04-14 22:20:26 +02:00
run = run
}