Help table generator

This commit is contained in:
yago 2015-01-23 23:49:51 +01:00
parent d9d96ed81c
commit a35bddc076
6 changed files with 74 additions and 17 deletions

View File

@ -27,8 +27,8 @@ function run(msg, matches)
end
return {
description = "send random image from 9gag",
usage = "!9gag",
description = "9GAG for telegram",
usage = "!9gag: Send random image from 9gag",
patterns = {"^!9gag$"},
run = run
}

View File

@ -34,8 +34,11 @@ function run(msg, matches)
end
return {
description = "Sends you a laughable gif",
usage = "",
description = "GIFs from telegram with Giphy API",
usage = {
"!gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.",
"!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF."
},
patterns = {
"^!gif$",
"^!gif (.*)",

View File

@ -28,8 +28,8 @@ function run(msg, matches)
end
return {
description = "Searches Google",
usage = "!google terms",
description = "Searches Google and send results",
usage = "!google [terms]",
patterns = {
"^!google (.*)$",
"^%.[g|G]oogle (.*)$"

View File

@ -1,17 +1,66 @@
-- Generate an HTML table for GitHub
function html_help()
local text = [[<table>
<thead>
<tr>
<td><strong>Name</strong></td>
<td><strong>Description</strong></td>
<td><strong>Usage</strong></td>
</tr>
</thead>
<tbody>]]
function run(msg, matches)
for k,v in pairs(plugins_names()) do
t = loadfile("plugins/"..v)()
text = text.."<tr>"
text = text.."<td>"..v.."</td>"
text = text.."<td>"..t.description.."</td>"
text = text.."<td>"
if (type(t.usage) == "table") then
for ku,vu in pairs(t.usage) do
text = text..vu.."<br>"
end
else
text = text..t.usage
end
text = text.."</td>"
text = text.."</tr>"
end
text = text.."</tbody></table>"
return text
end
function telegram_help( )
local ret = ""
for k, dict in pairs(plugins) do
if dict.usage ~= "" then
ret = ret .. dict.usage .. " -> " .. dict.description .. "\n"
end
if dict.usage ~= "" then
if (type(dict.usage) == "table") then
for ku,vu in pairs(dict.usage) do
ret = ret..vu.." "
end
else
ret = ret..dict.usage
end
ret = ret .. " -> " .. dict.description .. "\n"
end
end
return ret
end
function run(msg, matches)
if matches[1] == "!help md" then
return html_help()
else
return telegram_help()
end
end
return {
description = "Lists all available commands",
usage = "!help",
patterns = {"^!help$"},
usage = {"!help", "!help md"},
patterns = {
"^!help$",
"^!help md$"
},
run = run
}

View File

@ -31,7 +31,9 @@ end
return {
description = "Invite other user to the chat group",
usage = "!invite name [user_name], !invite id [user_id]",
usage = {
"!invite name [user_name]",
"!invite id [user_id]" },
patterns = {
"^!invite (name) (.*)$",
"^!invite (id) (%d+)$"

View File

@ -100,14 +100,17 @@ function run(msg, matches)
end
return {
description = "Enables, disables and reloads plugins",
usage = "!plugins, !plugins enable [plugin], !plugins disable [plugin], !plugins reload",
description = "Enables, disables and reloads plugins. Privileged users only.",
usage = {
"!plugins: list all plugins",
"!plugins enable [plugin]",
"!plugins disable [plugin]",
"!plugins reload" },
patterns = {
"^!plugins$",
"^!plugins? (enable) (.*)$",
"^!plugins? (disable) (.*)$",
"^!plugins? (reload)$"
},
"^!plugins? (reload)$" },
run = run,
privileged = true
}