26c1299374
help.lua has been rewritten to support "/help command". New variable "command" has been added to plugins for the syntax (w/out slash) to be displayed in main help message. "doc" will be displayed upon "/help command". Output of >12 plugins has been reformated to utilize markup. There is a fairly standard style throughout plugins. get_word() in utilities.lua now has defaults for nil arguments.
38 lines
729 B
Lua
Executable File
38 lines
729 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="(.*)">')
|
|
|
|
sendMessage(msg.chat.id, str)
|
|
|
|
end
|
|
|
|
return {
|
|
action = action,
|
|
triggers = triggers,
|
|
doc = doc,
|
|
command = command
|
|
}
|