local cleverbot = {}
function cleverbot:init(config)
cleverbot.triggers = {
"^/cbot (.+)$",
"^[Bb]rawlbot, (.+)$",
"^[Bb]ot, (.+)$"
}
cleverbot.url = config.cleverbot.cleverbot_api
end
cleverbot.command = 'cbot <Text>'
function cleverbot:action(msg, config, matches)
utilities.send_typing(msg.chat.id, 'typing')
local text = matches[1]
local query, code = https.request(cleverbot.url..URL.escape(text))
if code ~= 200 then
utilities.send_reply(msg, config.cleverbot.connection)
return
local data = json.decode(query)
if not data.clever then
utilities.send_reply(msg, config.cleverbot.response)
local answer = string.gsub(data.clever, "Ä", "Ä")
local answer = string.gsub(answer, "ä", "ä")
local answer = string.gsub(answer, "Ö", "Ö")
local answer = string.gsub(answer, "ö", "ö")
local answer = string.gsub(answer, "Ü", "Ü")
local answer = string.gsub(answer, "ü", "ü")
local answer = string.gsub(answer, "ß", "ß")
utilities.send_reply(msg, answer)
return cleverbot