Neu: Yoda-Plugin (Only english)
This commit is contained in:
parent
0e2991b9ea
commit
d656ffca98
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ plugins/dantest.lua
|
|||||||
plugins/stats2.lua
|
plugins/stats2.lua
|
||||||
plugins/help2.lua
|
plugins/help2.lua
|
||||||
plugins/pegelf_img.lua
|
plugins/pegelf_img.lua
|
||||||
plugins/plex.lua
|
plugins/plex.lua
|
||||||
|
plugins/chantalle.lua
|
44
plugins/yoda.lua
Normal file
44
plugins/yoda.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
local ltn12 = require "ltn12"
|
||||||
|
local https = require "ssl.https"
|
||||||
|
|
||||||
|
local function request(text)
|
||||||
|
local api = "https://yoda.p.mashape.com/yoda?"
|
||||||
|
text = string.gsub(text, " ", "+")
|
||||||
|
local parameters = "sentence="..(text or "")
|
||||||
|
local url = api..parameters
|
||||||
|
|
||||||
|
local api_key = cred_data.x_mashape_key
|
||||||
|
if api_key:isempty() then
|
||||||
|
return 'Configure your Mashape API Key'
|
||||||
|
end
|
||||||
|
|
||||||
|
local headers = {
|
||||||
|
["X-Mashape-Key"] = api_key,
|
||||||
|
["Accept"] = "text/plain"
|
||||||
|
}
|
||||||
|
|
||||||
|
local respbody = {}
|
||||||
|
local body, code = https.request{
|
||||||
|
url = url,
|
||||||
|
method = "GET",
|
||||||
|
headers = headers,
|
||||||
|
sink = ltn12.sink.table(respbody),
|
||||||
|
protocol = "tlsv1"
|
||||||
|
}
|
||||||
|
if code ~= 200 then return code end
|
||||||
|
local body = table.concat(respbody)
|
||||||
|
return body
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run(msg, matches)
|
||||||
|
return request(matches[1])
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
description = "Listen to Yoda and learn from his words!",
|
||||||
|
usage = "/yoda You will learn how to speak like me someday.",
|
||||||
|
patterns = {
|
||||||
|
"^/[Yy][Oo][Dd][Aa] (.*)$"
|
||||||
|
},
|
||||||
|
run = run
|
||||||
|
}
|
Reference in New Issue
Block a user