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-2/miku/plugins/cleverbot.lua
Akamaru fadd16e2c0 Nutze neue Cleverbot-API (by @Brawl345)
Plugin für Pi-Hole
Weitere kleine fixes
2017-02-15 16:49:23 +01:00

34 lines
875 B
Lua

local cleverbot = {}
function cleverbot:init(config)
cleverbot.triggers = {
"^/[Cc][Bb][Oo][Tt] (.*)$",
"^[Mm][Ii][Kk][Uu][Bb][Oo][Tt], (.+)$",
"^[Mm][Ii][Kk][Uu], (.+)$"
}
end
cleverbot.command = 'cbot <Text>'
local BASE_URL = 'https://www.cleverbot.com/getreply'
local apikey = cred_data.cleverbot_apikey -- get your key here: https://www.cleverbot.com/api/
function cleverbot:action(msg, config, matches)
utilities.send_typing(msg.chat.id, 'typing')
local text = matches[1]
local query, code = https.request(BASE_URL..'?key='..apikey..'&input='..URL.escape(text))
if code ~= 200 then
utilities.send_reply(msg, config.errors.connection)
return
end
local data = json.decode(query)
if not data.output then
utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...')
return
end
utilities.send_reply(msg, data.output)
end
return cleverbot