Help well formatted

This commit is contained in:
yago 2015-02-04 23:03:42 +01:00
parent bd7264f496
commit 9fc9383ab7
14 changed files with 44 additions and 34 deletions

View File

@ -4,8 +4,8 @@ function run(msg, matches)
end end
return { return {
description = "echoes the msg", description = "Simplest plugin ever!",
usage = "!echo [whatever]", usage = "!echo [whatever]: echoes the msg",
patterns = {"^!echo (.*)$"}, patterns = {"^!echo (.*)$"},
run = run run = run
} }

View File

@ -72,8 +72,8 @@ function lex(msg, text)
end end
return { return {
description = "retrieves variables saved with !set", description = "Retrieves variables saved with !set",
usage = "!get (value_name)", usage = "!get (value_name): Returns the value_name value.",
patterns = { patterns = {
"^!get (%a+)$", "^!get (%a+)$",
"^!get$"}, "^!get$"},

View File

@ -29,7 +29,7 @@ end
return { return {
description = "Searches Google and send results", description = "Searches Google and send results",
usage = "!google [terms]", usage = "!google [terms]: Searches Google and send results",
patterns = { patterns = {
"^!google (.*)$", "^!google (.*)$",
"^%.[g|G]oogle (.*)$" "^%.[g|G]oogle (.*)$"

View File

@ -25,7 +25,7 @@ end
return { return {
description = "generates a map showing the given GPS coordinates", description = "generates a map showing the given GPS coordinates",
usage = "!gps latitude,longitude", usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates",
patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"}, patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"},
run = run run = run
} }

View File

@ -30,18 +30,23 @@ function html_help()
return text return text
end end
function has_usage_data(dict)
if (dict.usage == nil or dict.usage == '') then
return false
end
return true
end
function telegram_help( ) 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 (type(dict.usage) == "table") then if (type(dict.usage) == "table") then
for ku,vu in pairs(dict.usage) do for ku,usage in pairs(dict.usage) do
ret = ret..vu.." " ret = ret..usage..'\n'
end end
else ret = ret..'\n'
ret = ret..dict.usage elseif has_usage_data(dict) then -- Is not empty
end ret = ret..dict.usage..'\n\n'
ret = ret .. " -> " .. dict.description .. "\n"
end end
end end
return ret return ret
@ -56,8 +61,11 @@ function run(msg, matches)
end end
return { return {
description = "Lists all available commands", description = "Help plugin. Get info from other plugins. ",
usage = {"!help", "!help md"}, usage = {
"!help: Show all the help",
"!help md: Generate a GitHub Markdown table"
},
patterns = { patterns = {
"^!help$", "^!help$",
"^!help md$" "^!help md$"

View File

@ -25,8 +25,8 @@ function run(msg, matches)
end end
return { return {
description = "search image with Google API and sends it", description = "Search image with Google API and sends it.",
usage = "!img [topic]", usage = "!img [term]: Random search an image with Google API.",
patterns = {"^!img (.*)$"}, patterns = {"^!img (.*)$"},
run = run run = run
} }

View File

@ -64,7 +64,7 @@ end
return { return {
description = "Gets information about a location, maplink and overview", description = "Gets information about a location, maplink and overview",
usage = "!loc (location)", usage = "!loc (location): Gets information about a location, maplink and overview",
patterns = {"^!loc (.*)$"}, patterns = {"^!loc (.*)$"},
run = run run = run
} }

View File

@ -100,12 +100,12 @@ function run(msg, matches)
end end
return { return {
description = "Enables, disables and reloads plugins. Privileged users only.", description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = { usage = {
"!plugins: list all plugins", "!plugins: list all plugins",
"!plugins enable [plugin]", "!plugins enable [plugin]: enable plugin",
"!plugins disable [plugin]", "!plugins disable [plugin]: disable plugin",
"!plugins reload" }, "!plugins reload: reloads all plugins" },
patterns = { patterns = {
"^!plugins$", "^!plugins$",
"^!plugins? (enable) (.*)$", "^!plugins? (enable) (.*)$",

View File

@ -41,7 +41,7 @@ end
return { return {
description = "Spanish dictionary", description = "Spanish dictionary",
usage = "!rae [word]", usage = "!rae [word]: Search that word in Spanish dictionary. Powered by https://github.com/javierhonduco/dulcinea",
patterns = {"^!rae (.*)$"}, patterns = {"^!rae (.*)$"},
run = run run = run
} }

View File

@ -23,8 +23,8 @@ function run(msg, matches)
end end
return { return {
description = "Set value", description = "Plugin for saving values. get.lua plugin is necesary to retrieve them.",
usage = "!set [value_name] [data]", usage = "!set [value_name] [data]: Saves the data with the value_name name.",
patterns = {"^!set (%a+) (.+)$"}, patterns = {"^!set (%a+) (.+)$"},
run = run run = run
} }

View File

@ -102,8 +102,8 @@ end
_stats = read_file_stats() _stats = read_file_stats()
return { return {
description = "Number of messages by user", description = "Plugin to update user stats.",
usage = "!stats", usage = "!stats: Returns a list of Username [telegram_id]: msg_num",
patterns = { patterns = {
".*", ".*",
"^!(stats)" "^!(stats)"

View File

@ -94,7 +94,7 @@ end
return { return {
description = "Displays the local time in an area", description = "Displays the local time in an area",
usage = "!time [area]", usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"}, patterns = {"^!time (.*)$"},
run = run run = run
} }

View File

@ -44,7 +44,7 @@ end
return { return {
description = "Sends a tweet", description = "Sends a tweet",
usage = "!tw [text]", usage = "!tw [text]: Sends the Tweet with the configured accout.",
patterns = {"^!tw (.+)"}, patterns = {"^!tw (.+)"},
run = run run = run
} }

View File

@ -7,8 +7,10 @@ end
return { return {
description = "Shows bot version", description = "Shows bot version",
usage = "!version", usage = "!version: Shows bot version",
patterns = {"^!version$"}, patterns = {
"^!version$"
},
run = run run = run
} }