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/plugins/chatter.lua
topkecleon 4c72543315 no typing by default
various bugfixes
blacklisting support (blacklist.lua)
	json file created automatically
	users are blacklisted and unblacklisted via reply with /blacklist
nicknames support (nick.lua)
	json file created automatically
	users set nick by /nick
	"people" section of config deprecated
moderation.lua improvements
	administrators can now run mod commands
	administrators are now listed with moderators
	modlist improved to be smarter and look better
	administrators can no longer be promoted to moderator
	/hammer command for admins to perform realm-wide ban
2015-08-18 05:55:25 -04:00

52 lines
1.0 KiB
Lua

-- shout-out to @luksireiku for showing me this site
local PLUGIN = {}
PLUGIN.typing = true
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=en&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.') or not jdat then
jdat.res = "I don't know what to say to that."
end
local message = jdat.res
-- Let's clean up the response a little. Capitalization & punctuation.
filter = {
['%aim%aimi'] = bot.first_name,
['^%s*(.-)%s*$'] = '%1',
['^%l'] = string.upper
}
for k,v in pairs(filter) do
message = string.gsub(message, k, v)
end
if not string.match(message, '%p$') then
message = message .. '.'
end
send_message(msg.chat.id, message)
end
return PLUGIN