Nutze neue Cleverbot-API
This commit is contained in:
parent
079592ad83
commit
f3865a2207
@ -59,12 +59,5 @@ Sende /hilfe, um zu starten
|
|||||||
max_duration = 526000,
|
max_duration = 526000,
|
||||||
max_reminders_group = 10,
|
max_reminders_group = 10,
|
||||||
max_reminders_private = 50
|
max_reminders_private = 50
|
||||||
},
|
|
||||||
|
|
||||||
cleverbot = {
|
|
||||||
cleverbot_api = 'https://brawlbot.tk/apis/chatter-bot-api/cleverbot.php?text=',
|
|
||||||
connection = 'Ich möchte jetzt nicht reden.',
|
|
||||||
response = 'Ich weiß nicht, wie ich darauf reagieren soll.'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,34 +6,29 @@ function cleverbot:init(config)
|
|||||||
"^[Bb]rawlbot, (.+)$",
|
"^[Bb]rawlbot, (.+)$",
|
||||||
"^[Bb]ot, (.+)$"
|
"^[Bb]ot, (.+)$"
|
||||||
}
|
}
|
||||||
cleverbot.url = config.cleverbot.cleverbot_api
|
|
||||||
end
|
end
|
||||||
|
|
||||||
cleverbot.command = 'cbot <Text>'
|
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)
|
function cleverbot:action(msg, config, matches)
|
||||||
utilities.send_typing(msg.chat.id, 'typing')
|
utilities.send_typing(msg.chat.id, 'typing')
|
||||||
local text = matches[1]
|
local text = matches[1]
|
||||||
local query, code = https.request(cleverbot.url..URL.escape(text))
|
local query, code = https.request(BASE_URL..'?key='..apikey..'&input='..URL.escape(text))
|
||||||
if code ~= 200 then
|
if code ~= 200 then
|
||||||
utilities.send_reply(msg, config.cleverbot.connection)
|
utilities.send_reply(msg, config.errors.connection)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = json.decode(query)
|
local data = json.decode(query)
|
||||||
if not data.clever then
|
if not data.output then
|
||||||
utilities.send_reply(msg, config.cleverbot.response)
|
utilities.send_reply(msg, 'Ich möchte jetzt nicht reden...')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local answer = string.gsub(data.clever, "Ä", "Ä")
|
utilities.send_reply(msg, data.output)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return cleverbot
|
return cleverbot
|
Reference in New Issue
Block a user