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/help.lua

38 lines
796 B
Lua
Raw Normal View History

-- This plugin should go at the end of your plugin list in
-- config.lua, but not after greetings.lua.
2015-07-03 00:15:52 +02:00
local help_text = 'Available commands:\n'
2015-07-03 00:15:52 +02:00
for i,v in ipairs(plugins) do
if v.doc then
local a = string.sub(v.doc, 1, string.find(v.doc, '\n')-1)
help_text = help_text .. a .. '\n'
end
end
2015-07-08 04:24:12 +02:00
local help_text = help_text .. 'Arguments: <required> [optional]'
2015-07-03 00:15:52 +02:00
local triggers = {
'^/h[elp]*[@'..bot.username..']*$',
'^/start[@'..bot.username..']*'
}
2015-07-03 00:15:52 +02:00
local action = function(msg)
2015-07-04 16:54:41 +02:00
2015-07-03 00:15:52 +02:00
if msg.from.id ~= msg.chat.id then
if sendMessage(msg.from.id, help_text) then
sendReply(msg, 'I have sent you the requested information in a private message.')
else
sendReply(msg, help_text)
2015-07-03 00:15:52 +02:00
end
else
sendReply(msg, help_text)
2015-07-03 00:15:52 +02:00
end
end
return {
action = action,
triggers = triggers
}