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 end
return { return {
description = "send random image from 9gag", description = "9GAG for telegram",
usage = "!9gag", usage = "!9gag: Send random image from 9gag",
patterns = {"^!9gag$"}, patterns = {"^!9gag$"},
run = run run = run
} }

View File

@ -34,8 +34,11 @@ function run(msg, matches)
end end
return { return {
description = "Sends you a laughable gif", description = "GIFs from telegram with Giphy API",
usage = "", 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 = { patterns = {
"^!gif$", "^!gif$",
"^!gif (.*)", "^!gif (.*)",

View File

@ -28,8 +28,8 @@ function run(msg, matches)
end end
return { return {
description = "Searches Google", description = "Searches Google and send results",
usage = "!google terms", usage = "!google [terms]",
patterns = { patterns = {
"^!google (.*)$", "^!google (.*)$",
"^%.[g|G]oogle (.*)$" "^%.[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 = "" local ret = ""
for k, dict in pairs(plugins) do for k, dict in pairs(plugins) do
if dict.usage ~= "" then if dict.usage ~= "" then
ret = ret .. dict.usage .. " -> " .. dict.description .. "\n" 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
end end
return ret return ret
end end
function run(msg, matches)
if matches[1] == "!help md" then
return html_help()
else
return telegram_help()
end
end
return { return {
description = "Lists all available commands", description = "Lists all available commands",
usage = "!help", usage = {"!help", "!help md"},
patterns = {"^!help$"}, patterns = {
"^!help$",
"^!help md$"
},
run = run run = run
} }

View File

@ -31,7 +31,9 @@ end
return { return {
description = "Invite other user to the chat group", 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 = { patterns = {
"^!invite (name) (.*)$", "^!invite (name) (.*)$",
"^!invite (id) (%d+)$" "^!invite (id) (%d+)$"

View File

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