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/cats.lua
topkecleon f529bc9ad8 help.lua and about.lua: /start now triggers about.lua
blacklist.lua: Added username support.
2016-03-04 17:08:21 -05:00

39 lines
786 B
Lua
Executable File

if not config.thecatapi_key then
print('Missing config value: thecatapi_key.')
print('cats.lua will be enabled, but there are more features with a key.')
end
local command = 'cat'
local doc = '`Returns a cat!`'
local triggers = {
'^/cat[@'..bot.username..']*$'
}
local action = function(msg)
local url = 'http://thecatapi.com/api/images/get?format=html&type=jpg'
if config.thecatapi_key then
url = url .. '&api_key=' .. config.thecatapi_key
end
local str, res = HTTP.request(url)
if res ~= 200 then
sendReply(msg, config.errors.connection)
return
end
str = str:match('<img src="(.-)">')
local output = '[Cat!]('..str..')'
sendMessage(msg.chat.id, output, false, nil, true)
end
return {
action = action,
triggers = triggers,
doc = doc,
command = command
}