updated rechner.lua
This commit is contained in:
parent
f46036adc4
commit
2c3297f834
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,3 +38,4 @@ plugins/vimeo.lua
|
|||||||
plugins/vine.lua
|
plugins/vine.lua
|
||||||
plugins/youtube_playlist.lua
|
plugins/youtube_playlist.lua
|
||||||
plugins/yandere.lua
|
plugins/yandere.lua
|
||||||
|
plugins/e621.lua
|
@ -3,7 +3,7 @@ socket = require("socket")
|
|||||||
function cron()
|
function cron()
|
||||||
-- Use yours desired web and id
|
-- Use yours desired web and id
|
||||||
local addr = "www.boerse.to"
|
local addr = "www.boerse.to"
|
||||||
local dest = "chat#id12345678"
|
local dest = "chat#id21091846"
|
||||||
-- Checks a TCP connexion
|
-- Checks a TCP connexion
|
||||||
local connexion = socket.connect(addr, 80)
|
local connexion = socket.connect(addr, 80)
|
||||||
if not connexion then
|
if not connexion then
|
||||||
|
@ -1,7 +1,24 @@
|
|||||||
function run(msg, matches)
|
-- Function reference: http://mathjs.org/docs/reference/functions/categorical.html
|
||||||
-- Convert expression to a function and execute it
|
|
||||||
local expression = string.gsub(matches[1], "(%a+)", "math.%1")
|
local function mathjs(exp)
|
||||||
return load('return '..expression)()
|
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])
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user