From 968448cc21b8df1e9b4652c6f23897c209416d2b Mon Sep 17 00:00:00 2001 From: dupie Date: Sat, 4 Jul 2015 22:51:12 -0400 Subject: [PATCH] added simsimi support --- config.json | 1 + plugins/chatter.lua | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 plugins/chatter.lua diff --git a/config.json b/config.json index a2d24a7..317cd6f 100644 --- a/config.json +++ b/config.json @@ -11,6 +11,7 @@ "bible.lua", "btc.lua", "calc.lua", + "chatter.lua", "commit.lua", "dice.lua", "dogify.lua", diff --git a/plugins/chatter.lua b/plugins/chatter.lua new file mode 100644 index 0000000..cf36d6a --- /dev/null +++ b/plugins/chatter.lua @@ -0,0 +1,30 @@ +local PLUGIN = {} + +PLUGIN.triggers = { + '^@' .. bot.username .. ', ', + '^' .. bot.first_name .. ', ' +} + +function PLUGIN.action(msg) + + local input = get_input(msg.text) + + local url = 'http://www.simsimi.com/requestChat?lc=es&ft=1.0&req=' .. URL.escape(input) + + local jstr, res = HTTP.request(url) + + if res ~= 200 then + return send_message(msg.chat.id, "I don't feel like talking right now.") + end + + local jdat = JSON.decode(jstr) + + if string.match(jdat.res, '^I HAVE NO RESPONSE.') then + jdat.res = "I don't know what to say to that." + end + + send_message(msg.chat.id, jdat.res) + +end + +return PLUGIN