Cleverbot: Führe Konversationen weiter (by @Brawl345)

This commit is contained in:
Akamaru 2017-02-18 22:41:23 +01:00
parent 48e8c7e864
commit cf2a7ca85b
2 changed files with 12 additions and 3 deletions

View File

@ -16,7 +16,16 @@ local apikey = cred_data.cleverbot_apikey -- get your key here: https://www.clev
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))
local hash = get_redis_hash(msg, 'cleverbot')
local state = redis:get(hash)
if not state then
query, code = https.request(BASE_URL..'?key='..apikey..'&input='..URL.escape(text))
else
query, code = https.request(BASE_URL..'?key='..apikey..'&input='..URL.escape(text)..'&cs='..state)
end
if code ~= 200 then
utilities.send_reply(msg, config.errors.connection)
return
@ -28,6 +37,7 @@ function cleverbot:action(msg, config, matches)
return
end
redis:set(hash, data.cs)
utilities.send_reply(msg, data.output)
end

View File

@ -1,5 +1,4 @@
-- YOU NEED THE FOLLOWING FOLDERS: photo, document, video, voice
-- PLEASE ADJUST YOUR PATH BELOW
-- YOU NEED THE FOLLOWING FOLDERS IN YOUR SAVE PATH: photo, document, video, voice, audio, sticker
local media_download = {}