diff --git a/plugins/9gag.lua b/plugins/9gag.lua index a40354f..0d4a4f3 100644 --- a/plugins/9gag.lua +++ b/plugins/9gag.lua @@ -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 } diff --git a/plugins/giphy.lua b/plugins/giphy.lua index ccf8697..a2a4ea1 100644 --- a/plugins/giphy.lua +++ b/plugins/giphy.lua @@ -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 (.*)", diff --git a/plugins/google.lua b/plugins/google.lua index d3b22de..0481962 100644 --- a/plugins/google.lua +++ b/plugins/google.lua @@ -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 (.*)$" diff --git a/plugins/help.lua b/plugins/help.lua index d02e43a..31b29e8 100644 --- a/plugins/help.lua +++ b/plugins/help.lua @@ -1,17 +1,66 @@ +-- Generate an HTML table for GitHub +function html_help() + local text = [[ + + + + + + + + ]] -function run(msg, matches) + for k,v in pairs(plugins_names()) do + t = loadfile("plugins/"..v)() + text = text.."" + text = text.."" + text = text.."" + text = text.."" + text = text.."" + end + text = text.."
NameDescriptionUsage
"..v..""..t.description.."" + if (type(t.usage) == "table") then + for ku,vu in pairs(t.usage) do + text = text..vu.."
" + end + else + text = text..t.usage + end + text = text.."
" + 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 } \ No newline at end of file diff --git a/plugins/invite.lua b/plugins/invite.lua index b47e848..cd5f452 100644 --- a/plugins/invite.lua +++ b/plugins/invite.lua @@ -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+)$" diff --git a/plugins/plugins.lua b/plugins/plugins.lua index af729a7..323b6c6 100644 --- a/plugins/plugins.lua +++ b/plugins/plugins.lua @@ -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 } \ No newline at end of file